babylon.d.ts 2.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. export const Epsilon = 0.001;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  464. * @param convertedColor defines the Color3 object where to store the linear space version
  465. * @returns the unmodified Color3
  466. */
  467. toLinearSpaceToRef(convertedColor: Color3): Color3;
  468. /**
  469. * Computes a new Color3 converted from the current one to gamma space
  470. * @returns a new Color3 object
  471. */
  472. toGammaSpace(): Color3;
  473. /**
  474. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  475. * @param convertedColor defines the Color3 object where to store the gamma space version
  476. * @returns the unmodified Color3
  477. */
  478. toGammaSpaceToRef(convertedColor: Color3): Color3;
  479. private static _BlackReadOnly;
  480. /**
  481. * Creates a new Color3 from the string containing valid hexadecimal values
  482. * @param hex defines a string containing valid hexadecimal values
  483. * @returns a new Color3 object
  484. */
  485. static FromHexString(hex: string): Color3;
  486. /**
  487. * Creates a new Vector3 from the starting index of the given array
  488. * @param array defines the source array
  489. * @param offset defines an offset in the source array
  490. * @returns a new Color3 object
  491. */
  492. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  493. /**
  494. * Creates a new Color3 from integer values (< 256)
  495. * @param r defines the red component to read from (value between 0 and 255)
  496. * @param g defines the green component to read from (value between 0 and 255)
  497. * @param b defines the blue component to read from (value between 0 and 255)
  498. * @returns a new Color3 object
  499. */
  500. static FromInts(r: number, g: number, b: number): Color3;
  501. /**
  502. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  503. * @param start defines the start Color3 value
  504. * @param end defines the end Color3 value
  505. * @param amount defines the gradient value between start and end
  506. * @returns a new Color3 object
  507. */
  508. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  509. /**
  510. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  511. * @param left defines the start value
  512. * @param right defines the end value
  513. * @param amount defines the gradient factor
  514. * @param result defines the Color3 object where to store the result
  515. */
  516. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  517. /**
  518. * Returns a Color3 value containing a red color
  519. * @returns a new Color3 object
  520. */
  521. static Red(): Color3;
  522. /**
  523. * Returns a Color3 value containing a green color
  524. * @returns a new Color3 object
  525. */
  526. static Green(): Color3;
  527. /**
  528. * Returns a Color3 value containing a blue color
  529. * @returns a new Color3 object
  530. */
  531. static Blue(): Color3;
  532. /**
  533. * Returns a Color3 value containing a black color
  534. * @returns a new Color3 object
  535. */
  536. static Black(): Color3;
  537. /**
  538. * Gets a Color3 value containing a black color that must not be updated
  539. */
  540. static readonly BlackReadOnly: DeepImmutable<Color3>;
  541. /**
  542. * Returns a Color3 value containing a white color
  543. * @returns a new Color3 object
  544. */
  545. static White(): Color3;
  546. /**
  547. * Returns a Color3 value containing a purple color
  548. * @returns a new Color3 object
  549. */
  550. static Purple(): Color3;
  551. /**
  552. * Returns a Color3 value containing a magenta color
  553. * @returns a new Color3 object
  554. */
  555. static Magenta(): Color3;
  556. /**
  557. * Returns a Color3 value containing a yellow color
  558. * @returns a new Color3 object
  559. */
  560. static Yellow(): Color3;
  561. /**
  562. * Returns a Color3 value containing a gray color
  563. * @returns a new Color3 object
  564. */
  565. static Gray(): Color3;
  566. /**
  567. * Returns a Color3 value containing a teal color
  568. * @returns a new Color3 object
  569. */
  570. static Teal(): Color3;
  571. /**
  572. * Returns a Color3 value containing a random color
  573. * @returns a new Color3 object
  574. */
  575. static Random(): Color3;
  576. }
  577. /**
  578. * Class used to hold a RBGA color
  579. */
  580. export class Color4 {
  581. /**
  582. * Defines the red component (between 0 and 1, default is 0)
  583. */
  584. r: number;
  585. /**
  586. * Defines the green component (between 0 and 1, default is 0)
  587. */
  588. g: number;
  589. /**
  590. * Defines the blue component (between 0 and 1, default is 0)
  591. */
  592. b: number;
  593. /**
  594. * Defines the alpha component (between 0 and 1, default is 1)
  595. */
  596. a: number;
  597. /**
  598. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  599. * @param r defines the red component (between 0 and 1, default is 0)
  600. * @param g defines the green component (between 0 and 1, default is 0)
  601. * @param b defines the blue component (between 0 and 1, default is 0)
  602. * @param a defines the alpha component (between 0 and 1, default is 1)
  603. */
  604. constructor(
  605. /**
  606. * Defines the red component (between 0 and 1, default is 0)
  607. */
  608. r?: number,
  609. /**
  610. * Defines the green component (between 0 and 1, default is 0)
  611. */
  612. g?: number,
  613. /**
  614. * Defines the blue component (between 0 and 1, default is 0)
  615. */
  616. b?: number,
  617. /**
  618. * Defines the alpha component (between 0 and 1, default is 1)
  619. */
  620. a?: number);
  621. /**
  622. * Adds in place the given Color4 values to the current Color4 object
  623. * @param right defines the second operand
  624. * @returns the current updated Color4 object
  625. */
  626. addInPlace(right: DeepImmutable<Color4>): Color4;
  627. /**
  628. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  629. * @returns the new array
  630. */
  631. asArray(): number[];
  632. /**
  633. * Stores from the starting index in the given array the Color4 successive values
  634. * @param array defines the array where to store the r,g,b components
  635. * @param index defines an optional index in the target array to define where to start storing values
  636. * @returns the current Color4 object
  637. */
  638. toArray(array: number[], index?: number): Color4;
  639. /**
  640. * Determines equality between Color4 objects
  641. * @param otherColor defines the second operand
  642. * @returns true if the rgba values are equal to the given ones
  643. */
  644. equals(otherColor: DeepImmutable<Color4>): boolean;
  645. /**
  646. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  647. * @param right defines the second operand
  648. * @returns a new Color4 object
  649. */
  650. add(right: DeepImmutable<Color4>): Color4;
  651. /**
  652. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  653. * @param right defines the second operand
  654. * @returns a new Color4 object
  655. */
  656. subtract(right: DeepImmutable<Color4>): Color4;
  657. /**
  658. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  659. * @param right defines the second operand
  660. * @param result defines the Color4 object where to store the result
  661. * @returns the current Color4 object
  662. */
  663. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  664. /**
  665. * Creates a new Color4 with the current Color4 values multiplied by scale
  666. * @param scale defines the scaling factor to apply
  667. * @returns a new Color4 object
  668. */
  669. scale(scale: number): Color4;
  670. /**
  671. * Multiplies the current Color4 values by scale and stores the result in "result"
  672. * @param scale defines the scaling factor to apply
  673. * @param result defines the Color4 object where to store the result
  674. * @returns the current unmodified Color4
  675. */
  676. scaleToRef(scale: number, result: Color4): Color4;
  677. /**
  678. * Scale the current Color4 values by a factor and add the result to a given Color4
  679. * @param scale defines the scale factor
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the unmodified current Color4
  682. */
  683. scaleAndAddToRef(scale: number, result: Color4): Color4;
  684. /**
  685. * Clamps the rgb values by the min and max values and stores the result into "result"
  686. * @param min defines minimum clamping value (default is 0)
  687. * @param max defines maximum clamping value (default is 1)
  688. * @param result defines color to store the result into.
  689. * @returns the cuurent Color4
  690. */
  691. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  692. /**
  693. * Multipy an Color4 value by another and return a new Color4 object
  694. * @param color defines the Color4 value to multiply by
  695. * @returns a new Color4 object
  696. */
  697. multiply(color: Color4): Color4;
  698. /**
  699. * Multipy a Color4 value by another and push the result in a reference value
  700. * @param color defines the Color4 value to multiply by
  701. * @param result defines the Color4 to fill the result in
  702. * @returns the result Color4
  703. */
  704. multiplyToRef(color: Color4, result: Color4): Color4;
  705. /**
  706. * Creates a string with the Color4 current values
  707. * @returns the string representation of the Color4 object
  708. */
  709. toString(): string;
  710. /**
  711. * Returns the string "Color4"
  712. * @returns "Color4"
  713. */
  714. getClassName(): string;
  715. /**
  716. * Compute the Color4 hash code
  717. * @returns an unique number that can be used to hash Color4 objects
  718. */
  719. getHashCode(): number;
  720. /**
  721. * Creates a new Color4 copied from the current one
  722. * @returns a new Color4 object
  723. */
  724. clone(): Color4;
  725. /**
  726. * Copies the given Color4 values into the current one
  727. * @param source defines the source Color4 object
  728. * @returns the current updated Color4 object
  729. */
  730. copyFrom(source: Color4): Color4;
  731. /**
  732. * Copies the given float values into the current one
  733. * @param r defines the red component to read from
  734. * @param g defines the green component to read from
  735. * @param b defines the blue component to read from
  736. * @param a defines the alpha component to read from
  737. * @returns the current updated Color4 object
  738. */
  739. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  740. /**
  741. * Copies the given float values into the current one
  742. * @param r defines the red component to read from
  743. * @param g defines the green component to read from
  744. * @param b defines the blue component to read from
  745. * @param a defines the alpha component to read from
  746. * @returns the current updated Color4 object
  747. */
  748. set(r: number, g: number, b: number, a: number): Color4;
  749. /**
  750. * Compute the Color4 hexadecimal code as a string
  751. * @returns a string containing the hexadecimal representation of the Color4 object
  752. */
  753. toHexString(): string;
  754. /**
  755. * Computes a new Color4 converted from the current one to linear space
  756. * @returns a new Color4 object
  757. */
  758. toLinearSpace(): Color4;
  759. /**
  760. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  761. * @param convertedColor defines the Color4 object where to store the linear space version
  762. * @returns the unmodified Color4
  763. */
  764. toLinearSpaceToRef(convertedColor: Color4): Color4;
  765. /**
  766. * Computes a new Color4 converted from the current one to gamma space
  767. * @returns a new Color4 object
  768. */
  769. toGammaSpace(): Color4;
  770. /**
  771. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  772. * @param convertedColor defines the Color4 object where to store the gamma space version
  773. * @returns the unmodified Color4
  774. */
  775. toGammaSpaceToRef(convertedColor: Color4): Color4;
  776. /**
  777. * Creates a new Color4 from the string containing valid hexadecimal values
  778. * @param hex defines a string containing valid hexadecimal values
  779. * @returns a new Color4 object
  780. */
  781. static FromHexString(hex: string): Color4;
  782. /**
  783. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  784. * @param left defines the start value
  785. * @param right defines the end value
  786. * @param amount defines the gradient factor
  787. * @returns a new Color4 object
  788. */
  789. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  790. /**
  791. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  792. * @param left defines the start value
  793. * @param right defines the end value
  794. * @param amount defines the gradient factor
  795. * @param result defines the Color4 object where to store data
  796. */
  797. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  798. /**
  799. * Creates a new Color4 from a Color3 and an alpha value
  800. * @param color3 defines the source Color3 to read from
  801. * @param alpha defines the alpha component (1.0 by default)
  802. * @returns a new Color4 object
  803. */
  804. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  805. /**
  806. * Creates a new Color4 from the starting index element of the given array
  807. * @param array defines the source array to read from
  808. * @param offset defines the offset in the source array
  809. * @returns a new Color4 object
  810. */
  811. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  812. /**
  813. * Creates a new Color3 from integer values (< 256)
  814. * @param r defines the red component to read from (value between 0 and 255)
  815. * @param g defines the green component to read from (value between 0 and 255)
  816. * @param b defines the blue component to read from (value between 0 and 255)
  817. * @param a defines the alpha component to read from (value between 0 and 255)
  818. * @returns a new Color3 object
  819. */
  820. static FromInts(r: number, g: number, b: number, a: number): Color4;
  821. /**
  822. * Check the content of a given array and convert it to an array containing RGBA data
  823. * If the original array was already containing count * 4 values then it is returned directly
  824. * @param colors defines the array to check
  825. * @param count defines the number of RGBA data to expect
  826. * @returns an array containing count * 4 values (RGBA)
  827. */
  828. static CheckColors4(colors: number[], count: number): number[];
  829. }
  830. /**
  831. * Class representing a vector containing 2 coordinates
  832. */
  833. export class Vector2 {
  834. /** defines the first coordinate */
  835. x: number;
  836. /** defines the second coordinate */
  837. y: number;
  838. /**
  839. * Creates a new Vector2 from the given x and y coordinates
  840. * @param x defines the first coordinate
  841. * @param y defines the second coordinate
  842. */
  843. constructor(
  844. /** defines the first coordinate */
  845. x?: number,
  846. /** defines the second coordinate */
  847. y?: number);
  848. /**
  849. * Gets a string with the Vector2 coordinates
  850. * @returns a string with the Vector2 coordinates
  851. */
  852. toString(): string;
  853. /**
  854. * Gets class name
  855. * @returns the string "Vector2"
  856. */
  857. getClassName(): string;
  858. /**
  859. * Gets current vector hash code
  860. * @returns the Vector2 hash code as a number
  861. */
  862. getHashCode(): number;
  863. /**
  864. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  865. * @param array defines the source array
  866. * @param index defines the offset in source array
  867. * @returns the current Vector2
  868. */
  869. toArray(array: FloatArray, index?: number): Vector2;
  870. /**
  871. * Copy the current vector to an array
  872. * @returns a new array with 2 elements: the Vector2 coordinates.
  873. */
  874. asArray(): number[];
  875. /**
  876. * Sets the Vector2 coordinates with the given Vector2 coordinates
  877. * @param source defines the source Vector2
  878. * @returns the current updated Vector2
  879. */
  880. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  881. /**
  882. * Sets the Vector2 coordinates with the given floats
  883. * @param x defines the first coordinate
  884. * @param y defines the second coordinate
  885. * @returns the current updated Vector2
  886. */
  887. copyFromFloats(x: number, y: number): Vector2;
  888. /**
  889. * Sets the Vector2 coordinates with the given floats
  890. * @param x defines the first coordinate
  891. * @param y defines the second coordinate
  892. * @returns the current updated Vector2
  893. */
  894. set(x: number, y: number): Vector2;
  895. /**
  896. * Add another vector with the current one
  897. * @param otherVector defines the other vector
  898. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  899. */
  900. add(otherVector: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  903. * @param otherVector defines the other vector
  904. * @param result defines the target vector
  905. * @returns the unmodified current Vector2
  906. */
  907. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  908. /**
  909. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  910. * @param otherVector defines the other vector
  911. * @returns the current updated Vector2
  912. */
  913. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  916. * @param otherVector defines the other vector
  917. * @returns a new Vector2
  918. */
  919. addVector3(otherVector: Vector3): Vector2;
  920. /**
  921. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  922. * @param otherVector defines the other vector
  923. * @returns a new Vector2
  924. */
  925. subtract(otherVector: Vector2): Vector2;
  926. /**
  927. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  928. * @param otherVector defines the other vector
  929. * @param result defines the target vector
  930. * @returns the unmodified current Vector2
  931. */
  932. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  933. /**
  934. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  935. * @param otherVector defines the other vector
  936. * @returns the current updated Vector2
  937. */
  938. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  939. /**
  940. * Multiplies in place the current Vector2 coordinates by the given ones
  941. * @param otherVector defines the other vector
  942. * @returns the current updated Vector2
  943. */
  944. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  945. /**
  946. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  947. * @param otherVector defines the other vector
  948. * @returns a new Vector2
  949. */
  950. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  951. /**
  952. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @param result defines the target vector
  955. * @returns the unmodified current Vector2
  956. */
  957. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  958. /**
  959. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  960. * @param x defines the first coordinate
  961. * @param y defines the second coordinate
  962. * @returns a new Vector2
  963. */
  964. multiplyByFloats(x: number, y: number): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. divide(otherVector: Vector2): Vector2;
  971. /**
  972. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Divides the current Vector2 coordinates by the given ones
  980. * @param otherVector defines the other vector
  981. * @returns the current updated Vector2
  982. */
  983. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  984. /**
  985. * Gets a new Vector2 with current Vector2 negated coordinates
  986. * @returns a new Vector2
  987. */
  988. negate(): Vector2;
  989. /**
  990. * Multiply the Vector2 coordinates by scale
  991. * @param scale defines the scaling factor
  992. * @returns the current updated Vector2
  993. */
  994. scaleInPlace(scale: number): Vector2;
  995. /**
  996. * Returns a new Vector2 scaled by "scale" from the current Vector2
  997. * @param scale defines the scaling factor
  998. * @returns a new Vector2
  999. */
  1000. scale(scale: number): Vector2;
  1001. /**
  1002. * Scale the current Vector2 values by a factor to a given Vector2
  1003. * @param scale defines the scale factor
  1004. * @param result defines the Vector2 object where to store the result
  1005. * @returns the unmodified current Vector2
  1006. */
  1007. scaleToRef(scale: number, result: Vector2): Vector2;
  1008. /**
  1009. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1010. * @param scale defines the scale factor
  1011. * @param result defines the Vector2 object where to store the result
  1012. * @returns the unmodified current Vector2
  1013. */
  1014. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1015. /**
  1016. * Gets a boolean if two vectors are equals
  1017. * @param otherVector defines the other vector
  1018. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1019. */
  1020. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1021. /**
  1022. * Gets a boolean if two vectors are equals (using an epsilon value)
  1023. * @param otherVector defines the other vector
  1024. * @param epsilon defines the minimal distance to consider equality
  1025. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1026. */
  1027. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1028. /**
  1029. * Gets a new Vector2 from current Vector2 floored values
  1030. * @returns a new Vector2
  1031. */
  1032. floor(): Vector2;
  1033. /**
  1034. * Gets a new Vector2 from current Vector2 floored values
  1035. * @returns a new Vector2
  1036. */
  1037. fract(): Vector2;
  1038. /**
  1039. * Gets the length of the vector
  1040. * @returns the vector length (float)
  1041. */
  1042. length(): number;
  1043. /**
  1044. * Gets the vector squared length
  1045. * @returns the vector squared length (float)
  1046. */
  1047. lengthSquared(): number;
  1048. /**
  1049. * Normalize the vector
  1050. * @returns the current updated Vector2
  1051. */
  1052. normalize(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 copied from the Vector2
  1055. * @returns a new Vector2
  1056. */
  1057. clone(): Vector2;
  1058. /**
  1059. * Gets a new Vector2(0, 0)
  1060. * @returns a new Vector2
  1061. */
  1062. static Zero(): Vector2;
  1063. /**
  1064. * Gets a new Vector2(1, 1)
  1065. * @returns a new Vector2
  1066. */
  1067. static One(): Vector2;
  1068. /**
  1069. * Gets a new Vector2 set from the given index element of the given array
  1070. * @param array defines the data source
  1071. * @param offset defines the offset in the data source
  1072. * @returns a new Vector2
  1073. */
  1074. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1075. /**
  1076. * Sets "result" from the given index element of the given array
  1077. * @param array defines the data source
  1078. * @param offset defines the offset in the data source
  1079. * @param result defines the target vector
  1080. */
  1081. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1082. /**
  1083. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1084. * @param value1 defines 1st point of control
  1085. * @param value2 defines 2nd point of control
  1086. * @param value3 defines 3rd point of control
  1087. * @param value4 defines 4th point of control
  1088. * @param amount defines the interpolation factor
  1089. * @returns a new Vector2
  1090. */
  1091. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1092. /**
  1093. * 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".
  1094. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1095. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1096. * @param value defines the value to clamp
  1097. * @param min defines the lower limit
  1098. * @param max defines the upper limit
  1099. * @returns a new Vector2
  1100. */
  1101. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1102. /**
  1103. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1104. * @param value1 defines the 1st control point
  1105. * @param tangent1 defines the outgoing tangent
  1106. * @param value2 defines the 2nd control point
  1107. * @param tangent2 defines the incoming tangent
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1114. * @param start defines the start vector
  1115. * @param end defines the end vector
  1116. * @param amount defines the interpolation factor
  1117. * @returns a new Vector2
  1118. */
  1119. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1120. /**
  1121. * Gets the dot product of the vector "left" and the vector "right"
  1122. * @param left defines first vector
  1123. * @param right defines second vector
  1124. * @returns the dot product (float)
  1125. */
  1126. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1127. /**
  1128. * Returns a new Vector2 equal to the normalized given vector
  1129. * @param vector defines the vector to normalize
  1130. * @returns a new Vector2
  1131. */
  1132. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1133. /**
  1134. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1135. * @param left defines 1st vector
  1136. * @param right defines 2nd vector
  1137. * @returns a new Vector2
  1138. */
  1139. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1140. /**
  1141. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1142. * @param left defines 1st vector
  1143. * @param right defines 2nd vector
  1144. * @returns a new Vector2
  1145. */
  1146. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1147. /**
  1148. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1149. * @param vector defines the vector to transform
  1150. * @param transformation defines the matrix to apply
  1151. * @returns a new Vector2
  1152. */
  1153. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1154. /**
  1155. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1156. * @param vector defines the vector to transform
  1157. * @param transformation defines the matrix to apply
  1158. * @param result defines the target vector
  1159. */
  1160. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1161. /**
  1162. * Determines if a given vector is included in a triangle
  1163. * @param p defines the vector to test
  1164. * @param p0 defines 1st triangle point
  1165. * @param p1 defines 2nd triangle point
  1166. * @param p2 defines 3rd triangle point
  1167. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1168. */
  1169. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1170. /**
  1171. * Gets the distance between the vectors "value1" and "value2"
  1172. * @param value1 defines first vector
  1173. * @param value2 defines second vector
  1174. * @returns the distance between vectors
  1175. */
  1176. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1177. /**
  1178. * Returns the squared distance between the vectors "value1" and "value2"
  1179. * @param value1 defines first vector
  1180. * @param value2 defines second vector
  1181. * @returns the squared distance between vectors
  1182. */
  1183. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1184. /**
  1185. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1186. * @param value1 defines first vector
  1187. * @param value2 defines second vector
  1188. * @returns a new Vector2
  1189. */
  1190. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1191. /**
  1192. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1193. * @param p defines the middle point
  1194. * @param segA defines one point of the segment
  1195. * @param segB defines the other point of the segment
  1196. * @returns the shortest distance
  1197. */
  1198. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1199. }
  1200. /**
  1201. * Classed used to store (x,y,z) vector representation
  1202. * A Vector3 is the main object used in 3D geometry
  1203. * It can represent etiher the coordinates of a point the space, either a direction
  1204. * Reminder: js uses a left handed forward facing system
  1205. */
  1206. export class Vector3 {
  1207. /**
  1208. * Defines the first coordinates (on X axis)
  1209. */
  1210. x: number;
  1211. /**
  1212. * Defines the second coordinates (on Y axis)
  1213. */
  1214. y: number;
  1215. /**
  1216. * Defines the third coordinates (on Z axis)
  1217. */
  1218. z: number;
  1219. private static _UpReadOnly;
  1220. /**
  1221. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1222. * @param x defines the first coordinates (on X axis)
  1223. * @param y defines the second coordinates (on Y axis)
  1224. * @param z defines the third coordinates (on Z axis)
  1225. */
  1226. constructor(
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x?: number,
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y?: number,
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z?: number);
  1239. /**
  1240. * Creates a string representation of the Vector3
  1241. * @returns a string with the Vector3 coordinates.
  1242. */
  1243. toString(): string;
  1244. /**
  1245. * Gets the class name
  1246. * @returns the string "Vector3"
  1247. */
  1248. getClassName(): string;
  1249. /**
  1250. * Creates the Vector3 hash code
  1251. * @returns a number which tends to be unique between Vector3 instances
  1252. */
  1253. getHashCode(): number;
  1254. /**
  1255. * Creates an array containing three elements : the coordinates of the Vector3
  1256. * @returns a new array of numbers
  1257. */
  1258. asArray(): number[];
  1259. /**
  1260. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1261. * @param array defines the destination array
  1262. * @param index defines the offset in the destination array
  1263. * @returns the current Vector3
  1264. */
  1265. toArray(array: FloatArray, index?: number): Vector3;
  1266. /**
  1267. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1268. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1269. */
  1270. toQuaternion(): Quaternion;
  1271. /**
  1272. * Adds the given vector to the current Vector3
  1273. * @param otherVector defines the second operand
  1274. * @returns the current updated Vector3
  1275. */
  1276. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1277. /**
  1278. * Adds the given coordinates to the current Vector3
  1279. * @param x defines the x coordinate of the operand
  1280. * @param y defines the y coordinate of the operand
  1281. * @param z defines the z coordinate of the operand
  1282. * @returns the current updated Vector3
  1283. */
  1284. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1285. /**
  1286. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1287. * @param otherVector defines the second operand
  1288. * @returns the resulting Vector3
  1289. */
  1290. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1291. /**
  1292. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1293. * @param otherVector defines the second operand
  1294. * @param result defines the Vector3 object where to store the result
  1295. * @returns the current Vector3
  1296. */
  1297. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1298. /**
  1299. * Subtract the given vector from the current Vector3
  1300. * @param otherVector defines the second operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1304. /**
  1305. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1319. * @param x defines the x coordinate of the operand
  1320. * @param y defines the y coordinate of the operand
  1321. * @param z defines the z coordinate of the operand
  1322. * @returns the resulting Vector3
  1323. */
  1324. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1325. /**
  1326. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1327. * @param x defines the x coordinate of the operand
  1328. * @param y defines the y coordinate of the operand
  1329. * @param z defines the z coordinate of the operand
  1330. * @param result defines the Vector3 object where to store the result
  1331. * @returns the current Vector3
  1332. */
  1333. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1334. /**
  1335. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1336. * @returns a new Vector3
  1337. */
  1338. negate(): Vector3;
  1339. /**
  1340. * Multiplies the Vector3 coordinates by the float "scale"
  1341. * @param scale defines the multiplier factor
  1342. * @returns the current updated Vector3
  1343. */
  1344. scaleInPlace(scale: number): Vector3;
  1345. /**
  1346. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1347. * @param scale defines the multiplier factor
  1348. * @returns a new Vector3
  1349. */
  1350. scale(scale: number): Vector3;
  1351. /**
  1352. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1353. * @param scale defines the multiplier factor
  1354. * @param result defines the Vector3 object where to store the result
  1355. * @returns the current Vector3
  1356. */
  1357. scaleToRef(scale: number, result: Vector3): Vector3;
  1358. /**
  1359. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1360. * @param scale defines the scale factor
  1361. * @param result defines the Vector3 object where to store the result
  1362. * @returns the unmodified current Vector3
  1363. */
  1364. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1365. /**
  1366. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1367. * @param otherVector defines the second operand
  1368. * @returns true if both vectors are equals
  1369. */
  1370. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1371. /**
  1372. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1373. * @param otherVector defines the second operand
  1374. * @param epsilon defines the minimal distance to define values as equals
  1375. * @returns true if both vectors are distant less than epsilon
  1376. */
  1377. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1378. /**
  1379. * Returns true if the current Vector3 coordinates equals the given floats
  1380. * @param x defines the x coordinate of the operand
  1381. * @param y defines the y coordinate of the operand
  1382. * @param z defines the z coordinate of the operand
  1383. * @returns true if both vectors are equals
  1384. */
  1385. equalsToFloats(x: number, y: number, z: number): boolean;
  1386. /**
  1387. * Multiplies the current Vector3 coordinates by the given ones
  1388. * @param otherVector defines the second operand
  1389. * @returns the current updated Vector3
  1390. */
  1391. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1392. /**
  1393. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1394. * @param otherVector defines the second operand
  1395. * @returns the new Vector3
  1396. */
  1397. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1398. /**
  1399. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1400. * @param otherVector defines the second operand
  1401. * @param result defines the Vector3 object where to store the result
  1402. * @returns the current Vector3
  1403. */
  1404. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1405. /**
  1406. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1407. * @param x defines the x coordinate of the operand
  1408. * @param y defines the y coordinate of the operand
  1409. * @param z defines the z coordinate of the operand
  1410. * @returns the new Vector3
  1411. */
  1412. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1413. /**
  1414. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Divides the current Vector3 coordinates by the given ones.
  1428. * @param otherVector defines the second operand
  1429. * @returns the current updated Vector3
  1430. */
  1431. divideInPlace(otherVector: Vector3): Vector3;
  1432. /**
  1433. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1434. * @param other defines the second operand
  1435. * @returns the current updated Vector3
  1436. */
  1437. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1440. * @param other defines the second operand
  1441. * @returns the current updated Vector3
  1442. */
  1443. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1444. /**
  1445. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1446. * @param x defines the x coordinate of the operand
  1447. * @param y defines the y coordinate of the operand
  1448. * @param z defines the z coordinate of the operand
  1449. * @returns the current updated Vector3
  1450. */
  1451. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1452. /**
  1453. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1454. * @param x defines the x coordinate of the operand
  1455. * @param y defines the y coordinate of the operand
  1456. * @param z defines the z coordinate of the operand
  1457. * @returns the current updated Vector3
  1458. */
  1459. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1460. /**
  1461. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1462. * Check if is non uniform within a certain amount of decimal places to account for this
  1463. * @param epsilon the amount the values can differ
  1464. * @returns if the the vector is non uniform to a certain number of decimal places
  1465. */
  1466. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1467. /**
  1468. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1469. */
  1470. readonly isNonUniform: boolean;
  1471. /**
  1472. * Gets a new Vector3 from current Vector3 floored values
  1473. * @returns a new Vector3
  1474. */
  1475. floor(): Vector3;
  1476. /**
  1477. * Gets a new Vector3 from current Vector3 floored values
  1478. * @returns a new Vector3
  1479. */
  1480. fract(): Vector3;
  1481. /**
  1482. * Gets the length of the Vector3
  1483. * @returns the length of the Vecto3
  1484. */
  1485. length(): number;
  1486. /**
  1487. * Gets the squared length of the Vector3
  1488. * @returns squared length of the Vector3
  1489. */
  1490. lengthSquared(): number;
  1491. /**
  1492. * Normalize the current Vector3.
  1493. * Please note that this is an in place operation.
  1494. * @returns the current updated Vector3
  1495. */
  1496. normalize(): Vector3;
  1497. /**
  1498. * Reorders the x y z properties of the vector in place
  1499. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1500. * @returns the current updated vector
  1501. */
  1502. reorderInPlace(order: string): this;
  1503. /**
  1504. * Rotates the vector around 0,0,0 by a quaternion
  1505. * @param quaternion the rotation quaternion
  1506. * @param result vector to store the result
  1507. * @returns the resulting vector
  1508. */
  1509. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1510. /**
  1511. * Rotates a vector around a given point
  1512. * @param quaternion the rotation quaternion
  1513. * @param point the point to rotate around
  1514. * @param result vector to store the result
  1515. * @returns the resulting vector
  1516. */
  1517. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1518. /**
  1519. * Normalize the current Vector3 with the given input length.
  1520. * Please note that this is an in place operation.
  1521. * @param len the length of the vector
  1522. * @returns the current updated Vector3
  1523. */
  1524. normalizeFromLength(len: number): Vector3;
  1525. /**
  1526. * Normalize the current Vector3 to a new vector
  1527. * @returns the new Vector3
  1528. */
  1529. normalizeToNew(): Vector3;
  1530. /**
  1531. * Normalize the current Vector3 to the reference
  1532. * @param reference define the Vector3 to update
  1533. * @returns the updated Vector3
  1534. */
  1535. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1536. /**
  1537. * Creates a new Vector3 copied from the current Vector3
  1538. * @returns the new Vector3
  1539. */
  1540. clone(): Vector3;
  1541. /**
  1542. * Copies the given vector coordinates to the current Vector3 ones
  1543. * @param source defines the source Vector3
  1544. * @returns the current updated Vector3
  1545. */
  1546. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1547. /**
  1548. * Copies the given floats to the current Vector3 coordinates
  1549. * @param x defines the x coordinate of the operand
  1550. * @param y defines the y coordinate of the operand
  1551. * @param z defines the z coordinate of the operand
  1552. * @returns the current updated Vector3
  1553. */
  1554. copyFromFloats(x: number, y: number, z: number): Vector3;
  1555. /**
  1556. * Copies the given floats to the current Vector3 coordinates
  1557. * @param x defines the x coordinate of the operand
  1558. * @param y defines the y coordinate of the operand
  1559. * @param z defines the z coordinate of the operand
  1560. * @returns the current updated Vector3
  1561. */
  1562. set(x: number, y: number, z: number): Vector3;
  1563. /**
  1564. * Copies the given float to the current Vector3 coordinates
  1565. * @param v defines the x, y and z coordinates of the operand
  1566. * @returns the current updated Vector3
  1567. */
  1568. setAll(v: number): Vector3;
  1569. /**
  1570. * Get the clip factor between two vectors
  1571. * @param vector0 defines the first operand
  1572. * @param vector1 defines the second operand
  1573. * @param axis defines the axis to use
  1574. * @param size defines the size along the axis
  1575. * @returns the clip factor
  1576. */
  1577. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1578. /**
  1579. * Get angle between two vectors
  1580. * @param vector0 angle between vector0 and vector1
  1581. * @param vector1 angle between vector0 and vector1
  1582. * @param normal direction of the normal
  1583. * @return the angle between vector0 and vector1
  1584. */
  1585. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1586. /**
  1587. * Returns a new Vector3 set from the index "offset" of the given array
  1588. * @param array defines the source array
  1589. * @param offset defines the offset in the source array
  1590. * @returns the new Vector3
  1591. */
  1592. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1593. /**
  1594. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1595. * This function is deprecated. Use FromArray instead
  1596. * @param array defines the source array
  1597. * @param offset defines the offset in the source array
  1598. * @returns the new Vector3
  1599. */
  1600. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1601. /**
  1602. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1603. * @param array defines the source array
  1604. * @param offset defines the offset in the source array
  1605. * @param result defines the Vector3 where to store the result
  1606. */
  1607. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1608. /**
  1609. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1610. * This function is deprecated. Use FromArrayToRef instead.
  1611. * @param array defines the source array
  1612. * @param offset defines the offset in the source array
  1613. * @param result defines the Vector3 where to store the result
  1614. */
  1615. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1616. /**
  1617. * Sets the given vector "result" with the given floats.
  1618. * @param x defines the x coordinate of the source
  1619. * @param y defines the y coordinate of the source
  1620. * @param z defines the z coordinate of the source
  1621. * @param result defines the Vector3 where to store the result
  1622. */
  1623. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1624. /**
  1625. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1626. * @returns a new empty Vector3
  1627. */
  1628. static Zero(): Vector3;
  1629. /**
  1630. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1631. * @returns a new unit Vector3
  1632. */
  1633. static One(): Vector3;
  1634. /**
  1635. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1636. * @returns a new up Vector3
  1637. */
  1638. static Up(): Vector3;
  1639. /**
  1640. * Gets a up Vector3 that must not be updated
  1641. */
  1642. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1645. * @returns a new down Vector3
  1646. */
  1647. static Down(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1650. * @returns a new forward Vector3
  1651. */
  1652. static Forward(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1655. * @returns a new forward Vector3
  1656. */
  1657. static Backward(): Vector3;
  1658. /**
  1659. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1660. * @returns a new right Vector3
  1661. */
  1662. static Right(): Vector3;
  1663. /**
  1664. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1665. * @returns a new left Vector3
  1666. */
  1667. static Left(): Vector3;
  1668. /**
  1669. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1670. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1671. * @param vector defines the Vector3 to transform
  1672. * @param transformation defines the transformation matrix
  1673. * @returns the transformed Vector3
  1674. */
  1675. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1676. /**
  1677. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1678. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1679. * @param vector defines the Vector3 to transform
  1680. * @param transformation defines the transformation matrix
  1681. * @param result defines the Vector3 where to store the result
  1682. */
  1683. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1684. /**
  1685. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1686. * This method computes tranformed coordinates only, not transformed direction vectors
  1687. * @param x define the x coordinate of the source vector
  1688. * @param y define the y coordinate of the source vector
  1689. * @param z define the z coordinate of the source vector
  1690. * @param transformation defines the transformation matrix
  1691. * @param result defines the Vector3 where to store the result
  1692. */
  1693. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1694. /**
  1695. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1696. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1697. * @param vector defines the Vector3 to transform
  1698. * @param transformation defines the transformation matrix
  1699. * @returns the new Vector3
  1700. */
  1701. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1702. /**
  1703. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1704. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1705. * @param vector defines the Vector3 to transform
  1706. * @param transformation defines the transformation matrix
  1707. * @param result defines the Vector3 where to store the result
  1708. */
  1709. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1710. /**
  1711. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1712. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1713. * @param x define the x coordinate of the source vector
  1714. * @param y define the y coordinate of the source vector
  1715. * @param z define the z coordinate of the source vector
  1716. * @param transformation defines the transformation matrix
  1717. * @param result defines the Vector3 where to store the result
  1718. */
  1719. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1720. /**
  1721. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1722. * @param value1 defines the first control point
  1723. * @param value2 defines the second control point
  1724. * @param value3 defines the third control point
  1725. * @param value4 defines the fourth control point
  1726. * @param amount defines the amount on the spline to use
  1727. * @returns the new Vector3
  1728. */
  1729. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1730. /**
  1731. * 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"
  1732. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1733. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1734. * @param value defines the current value
  1735. * @param min defines the lower range value
  1736. * @param max defines the upper range value
  1737. * @returns the new Vector3
  1738. */
  1739. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1740. /**
  1741. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1742. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1743. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1744. * @param value defines the current value
  1745. * @param min defines the lower range value
  1746. * @param max defines the upper range value
  1747. * @param result defines the Vector3 where to store the result
  1748. */
  1749. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1750. /**
  1751. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1752. * @param value1 defines the first control point
  1753. * @param tangent1 defines the first tangent vector
  1754. * @param value2 defines the second control point
  1755. * @param tangent2 defines the second tangent vector
  1756. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1757. * @returns the new Vector3
  1758. */
  1759. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1760. /**
  1761. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1762. * @param start defines the start value
  1763. * @param end defines the end value
  1764. * @param amount max defines amount between both (between 0 and 1)
  1765. * @returns the new Vector3
  1766. */
  1767. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1768. /**
  1769. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1770. * @param start defines the start value
  1771. * @param end defines the end value
  1772. * @param amount max defines amount between both (between 0 and 1)
  1773. * @param result defines the Vector3 where to store the result
  1774. */
  1775. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1776. /**
  1777. * Returns the dot product (float) between the vectors "left" and "right"
  1778. * @param left defines the left operand
  1779. * @param right defines the right operand
  1780. * @returns the dot product
  1781. */
  1782. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1783. /**
  1784. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1785. * The cross product is then orthogonal to both "left" and "right"
  1786. * @param left defines the left operand
  1787. * @param right defines the right operand
  1788. * @returns the cross product
  1789. */
  1790. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the cross product of "left" and "right"
  1793. * The cross product is then orthogonal to both "left" and "right"
  1794. * @param left defines the left operand
  1795. * @param right defines the right operand
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1799. /**
  1800. * Returns a new Vector3 as the normalization of the given vector
  1801. * @param vector defines the Vector3 to normalize
  1802. * @returns the new Vector3
  1803. */
  1804. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1805. /**
  1806. * Sets the given vector "result" with the normalization of the given first vector
  1807. * @param vector defines the Vector3 to normalize
  1808. * @param result defines the Vector3 where to store the result
  1809. */
  1810. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1811. /**
  1812. * Project a Vector3 onto screen space
  1813. * @param vector defines the Vector3 to project
  1814. * @param world defines the world matrix to use
  1815. * @param transform defines the transform (view x projection) matrix to use
  1816. * @param viewport defines the screen viewport to use
  1817. * @returns the new Vector3
  1818. */
  1819. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1820. /** @hidden */
  1821. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1822. /**
  1823. * Unproject from screen space to object space
  1824. * @param source defines the screen space Vector3 to use
  1825. * @param viewportWidth defines the current width of the viewport
  1826. * @param viewportHeight defines the current height of the viewport
  1827. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1828. * @param transform defines the transform (view x projection) matrix to use
  1829. * @returns the new Vector3
  1830. */
  1831. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1832. /**
  1833. * Unproject from screen space to object space
  1834. * @param source defines the screen space Vector3 to use
  1835. * @param viewportWidth defines the current width of the viewport
  1836. * @param viewportHeight defines the current height of the viewport
  1837. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1838. * @param view defines the view matrix to use
  1839. * @param projection defines the projection matrix to use
  1840. * @returns the new Vector3
  1841. */
  1842. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1843. /**
  1844. * Unproject from screen space to object space
  1845. * @param source defines the screen space Vector3 to use
  1846. * @param viewportWidth defines the current width of the viewport
  1847. * @param viewportHeight defines the current height of the viewport
  1848. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1849. * @param view defines the view matrix to use
  1850. * @param projection defines the projection matrix to use
  1851. * @param result defines the Vector3 where to store the result
  1852. */
  1853. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1854. /**
  1855. * Unproject from screen space to object space
  1856. * @param sourceX defines the screen space x coordinate to use
  1857. * @param sourceY defines the screen space y coordinate to use
  1858. * @param sourceZ defines the screen space z coordinate to use
  1859. * @param viewportWidth defines the current width of the viewport
  1860. * @param viewportHeight defines the current height of the viewport
  1861. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1862. * @param view defines the view matrix to use
  1863. * @param projection defines the projection matrix to use
  1864. * @param result defines the Vector3 where to store the result
  1865. */
  1866. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1867. /**
  1868. * Gets the minimal coordinate values between two Vector3
  1869. * @param left defines the first operand
  1870. * @param right defines the second operand
  1871. * @returns the new Vector3
  1872. */
  1873. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1874. /**
  1875. * Gets the maximal coordinate values between two Vector3
  1876. * @param left defines the first operand
  1877. * @param right defines the second operand
  1878. * @returns the new Vector3
  1879. */
  1880. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1881. /**
  1882. * Returns the distance between the vectors "value1" and "value2"
  1883. * @param value1 defines the first operand
  1884. * @param value2 defines the second operand
  1885. * @returns the distance
  1886. */
  1887. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1888. /**
  1889. * Returns the squared distance between the vectors "value1" and "value2"
  1890. * @param value1 defines the first operand
  1891. * @param value2 defines the second operand
  1892. * @returns the squared distance
  1893. */
  1894. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1895. /**
  1896. * Returns a new Vector3 located at the center between "value1" and "value2"
  1897. * @param value1 defines the first operand
  1898. * @param value2 defines the second operand
  1899. * @returns the new Vector3
  1900. */
  1901. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1902. /**
  1903. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1904. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1905. * to something in order to rotate it from its local system to the given target system
  1906. * Note: axis1, axis2 and axis3 are normalized during this operation
  1907. * @param axis1 defines the first axis
  1908. * @param axis2 defines the second axis
  1909. * @param axis3 defines the third axis
  1910. * @returns a new Vector3
  1911. */
  1912. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1913. /**
  1914. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1915. * @param axis1 defines the first axis
  1916. * @param axis2 defines the second axis
  1917. * @param axis3 defines the third axis
  1918. * @param ref defines the Vector3 where to store the result
  1919. */
  1920. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1921. }
  1922. /**
  1923. * Vector4 class created for EulerAngle class conversion to Quaternion
  1924. */
  1925. export class Vector4 {
  1926. /** x value of the vector */
  1927. x: number;
  1928. /** y value of the vector */
  1929. y: number;
  1930. /** z value of the vector */
  1931. z: number;
  1932. /** w value of the vector */
  1933. w: number;
  1934. /**
  1935. * Creates a Vector4 object from the given floats.
  1936. * @param x x value of the vector
  1937. * @param y y value of the vector
  1938. * @param z z value of the vector
  1939. * @param w w value of the vector
  1940. */
  1941. constructor(
  1942. /** x value of the vector */
  1943. x: number,
  1944. /** y value of the vector */
  1945. y: number,
  1946. /** z value of the vector */
  1947. z: number,
  1948. /** w value of the vector */
  1949. w: number);
  1950. /**
  1951. * Returns the string with the Vector4 coordinates.
  1952. * @returns a string containing all the vector values
  1953. */
  1954. toString(): string;
  1955. /**
  1956. * Returns the string "Vector4".
  1957. * @returns "Vector4"
  1958. */
  1959. getClassName(): string;
  1960. /**
  1961. * Returns the Vector4 hash code.
  1962. * @returns a unique hash code
  1963. */
  1964. getHashCode(): number;
  1965. /**
  1966. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1967. * @returns the resulting array
  1968. */
  1969. asArray(): number[];
  1970. /**
  1971. * Populates the given array from the given index with the Vector4 coordinates.
  1972. * @param array array to populate
  1973. * @param index index of the array to start at (default: 0)
  1974. * @returns the Vector4.
  1975. */
  1976. toArray(array: FloatArray, index?: number): Vector4;
  1977. /**
  1978. * Adds the given vector to the current Vector4.
  1979. * @param otherVector the vector to add
  1980. * @returns the updated Vector4.
  1981. */
  1982. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1983. /**
  1984. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1985. * @param otherVector the vector to add
  1986. * @returns the resulting vector
  1987. */
  1988. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1989. /**
  1990. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1991. * @param otherVector the vector to add
  1992. * @param result the vector to store the result
  1993. * @returns the current Vector4.
  1994. */
  1995. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1996. /**
  1997. * Subtract in place the given vector from the current Vector4.
  1998. * @param otherVector the vector to subtract
  1999. * @returns the updated Vector4.
  2000. */
  2001. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2002. /**
  2003. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the new vector with the result
  2006. */
  2007. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2010. * @param otherVector the vector to subtract
  2011. * @param result the vector to store the result
  2012. * @returns the current Vector4.
  2013. */
  2014. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2015. /**
  2016. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2017. */
  2018. /**
  2019. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2020. * @param x value to subtract
  2021. * @param y value to subtract
  2022. * @param z value to subtract
  2023. * @param w value to subtract
  2024. * @returns new vector containing the result
  2025. */
  2026. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2027. /**
  2028. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2029. * @param x value to subtract
  2030. * @param y value to subtract
  2031. * @param z value to subtract
  2032. * @param w value to subtract
  2033. * @param result the vector to store the result in
  2034. * @returns the current Vector4.
  2035. */
  2036. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2037. /**
  2038. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2039. * @returns a new vector with the negated values
  2040. */
  2041. negate(): Vector4;
  2042. /**
  2043. * Multiplies the current Vector4 coordinates by scale (float).
  2044. * @param scale the number to scale with
  2045. * @returns the updated Vector4.
  2046. */
  2047. scaleInPlace(scale: number): Vector4;
  2048. /**
  2049. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2050. * @param scale the number to scale with
  2051. * @returns a new vector with the result
  2052. */
  2053. scale(scale: number): Vector4;
  2054. /**
  2055. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2056. * @param scale the number to scale with
  2057. * @param result a vector to store the result in
  2058. * @returns the current Vector4.
  2059. */
  2060. scaleToRef(scale: number, result: Vector4): Vector4;
  2061. /**
  2062. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2063. * @param scale defines the scale factor
  2064. * @param result defines the Vector4 object where to store the result
  2065. * @returns the unmodified current Vector4
  2066. */
  2067. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2068. /**
  2069. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2070. * @param otherVector the vector to compare against
  2071. * @returns true if they are equal
  2072. */
  2073. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2074. /**
  2075. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2076. * @param otherVector vector to compare against
  2077. * @param epsilon (Default: very small number)
  2078. * @returns true if they are equal
  2079. */
  2080. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2081. /**
  2082. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2083. * @param x x value to compare against
  2084. * @param y y value to compare against
  2085. * @param z z value to compare against
  2086. * @param w w value to compare against
  2087. * @returns true if equal
  2088. */
  2089. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2090. /**
  2091. * Multiplies in place the current Vector4 by the given one.
  2092. * @param otherVector vector to multiple with
  2093. * @returns the updated Vector4.
  2094. */
  2095. multiplyInPlace(otherVector: Vector4): Vector4;
  2096. /**
  2097. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2098. * @param otherVector vector to multiple with
  2099. * @returns resulting new vector
  2100. */
  2101. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2102. /**
  2103. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2104. * @param otherVector vector to multiple with
  2105. * @param result vector to store the result
  2106. * @returns the current Vector4.
  2107. */
  2108. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2109. /**
  2110. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2111. * @param x x value multiply with
  2112. * @param y y value multiply with
  2113. * @param z z value multiply with
  2114. * @param w w value multiply with
  2115. * @returns resulting new vector
  2116. */
  2117. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2118. /**
  2119. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2120. * @param otherVector vector to devide with
  2121. * @returns resulting new vector
  2122. */
  2123. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2124. /**
  2125. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2126. * @param otherVector vector to devide with
  2127. * @param result vector to store the result
  2128. * @returns the current Vector4.
  2129. */
  2130. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2131. /**
  2132. * Divides the current Vector3 coordinates by the given ones.
  2133. * @param otherVector vector to devide with
  2134. * @returns the updated Vector3.
  2135. */
  2136. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2137. /**
  2138. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2139. * @param other defines the second operand
  2140. * @returns the current updated Vector4
  2141. */
  2142. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2143. /**
  2144. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2145. * @param other defines the second operand
  2146. * @returns the current updated Vector4
  2147. */
  2148. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Gets a new Vector4 from current Vector4 floored values
  2151. * @returns a new Vector4
  2152. */
  2153. floor(): Vector4;
  2154. /**
  2155. * Gets a new Vector4 from current Vector3 floored values
  2156. * @returns a new Vector4
  2157. */
  2158. fract(): Vector4;
  2159. /**
  2160. * Returns the Vector4 length (float).
  2161. * @returns the length
  2162. */
  2163. length(): number;
  2164. /**
  2165. * Returns the Vector4 squared length (float).
  2166. * @returns the length squared
  2167. */
  2168. lengthSquared(): number;
  2169. /**
  2170. * Normalizes in place the Vector4.
  2171. * @returns the updated Vector4.
  2172. */
  2173. normalize(): Vector4;
  2174. /**
  2175. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2176. * @returns this converted to a new vector3
  2177. */
  2178. toVector3(): Vector3;
  2179. /**
  2180. * Returns a new Vector4 copied from the current one.
  2181. * @returns the new cloned vector
  2182. */
  2183. clone(): Vector4;
  2184. /**
  2185. * Updates the current Vector4 with the given one coordinates.
  2186. * @param source the source vector to copy from
  2187. * @returns the updated Vector4.
  2188. */
  2189. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2190. /**
  2191. * Updates the current Vector4 coordinates with the given floats.
  2192. * @param x float to copy from
  2193. * @param y float to copy from
  2194. * @param z float to copy from
  2195. * @param w float to copy from
  2196. * @returns the updated Vector4.
  2197. */
  2198. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2199. /**
  2200. * Updates the current Vector4 coordinates with the given floats.
  2201. * @param x float to set from
  2202. * @param y float to set from
  2203. * @param z float to set from
  2204. * @param w float to set from
  2205. * @returns the updated Vector4.
  2206. */
  2207. set(x: number, y: number, z: number, w: number): Vector4;
  2208. /**
  2209. * Copies the given float to the current Vector3 coordinates
  2210. * @param v defines the x, y, z and w coordinates of the operand
  2211. * @returns the current updated Vector3
  2212. */
  2213. setAll(v: number): Vector4;
  2214. /**
  2215. * Returns a new Vector4 set from the starting index of the given array.
  2216. * @param array the array to pull values from
  2217. * @param offset the offset into the array to start at
  2218. * @returns the new vector
  2219. */
  2220. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2221. /**
  2222. * Updates the given vector "result" from the starting index of the given array.
  2223. * @param array the array to pull values from
  2224. * @param offset the offset into the array to start at
  2225. * @param result the vector to store the result in
  2226. */
  2227. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2228. /**
  2229. * Updates the given vector "result" from the starting index of the given Float32Array.
  2230. * @param array the array to pull values from
  2231. * @param offset the offset into the array to start at
  2232. * @param result the vector to store the result in
  2233. */
  2234. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2235. /**
  2236. * Updates the given vector "result" coordinates from the given floats.
  2237. * @param x float to set from
  2238. * @param y float to set from
  2239. * @param z float to set from
  2240. * @param w float to set from
  2241. * @param result the vector to the floats in
  2242. */
  2243. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2244. /**
  2245. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2246. * @returns the new vector
  2247. */
  2248. static Zero(): Vector4;
  2249. /**
  2250. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2251. * @returns the new vector
  2252. */
  2253. static One(): Vector4;
  2254. /**
  2255. * Returns a new normalized Vector4 from the given one.
  2256. * @param vector the vector to normalize
  2257. * @returns the vector
  2258. */
  2259. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2260. /**
  2261. * Updates the given vector "result" from the normalization of the given one.
  2262. * @param vector the vector to normalize
  2263. * @param result the vector to store the result in
  2264. */
  2265. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2266. /**
  2267. * Returns a vector with the minimum values from the left and right vectors
  2268. * @param left left vector to minimize
  2269. * @param right right vector to minimize
  2270. * @returns a new vector with the minimum of the left and right vector values
  2271. */
  2272. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2273. /**
  2274. * Returns a vector with the maximum values from the left and right vectors
  2275. * @param left left vector to maximize
  2276. * @param right right vector to maximize
  2277. * @returns a new vector with the maximum of the left and right vector values
  2278. */
  2279. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2280. /**
  2281. * Returns the distance (float) between the vectors "value1" and "value2".
  2282. * @param value1 value to calulate the distance between
  2283. * @param value2 value to calulate the distance between
  2284. * @return the distance between the two vectors
  2285. */
  2286. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2287. /**
  2288. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2289. * @param value1 value to calulate the distance between
  2290. * @param value2 value to calulate the distance between
  2291. * @return the distance between the two vectors squared
  2292. */
  2293. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2294. /**
  2295. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2296. * @param value1 value to calulate the center between
  2297. * @param value2 value to calulate the center between
  2298. * @return the center between the two vectors
  2299. */
  2300. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2301. /**
  2302. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2303. * This methods computes transformed normalized direction vectors only.
  2304. * @param vector the vector to transform
  2305. * @param transformation the transformation matrix to apply
  2306. * @returns the new vector
  2307. */
  2308. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2309. /**
  2310. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2311. * This methods computes transformed normalized direction vectors only.
  2312. * @param vector the vector to transform
  2313. * @param transformation the transformation matrix to apply
  2314. * @param result the vector to store the result in
  2315. */
  2316. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2317. /**
  2318. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2319. * This methods computes transformed normalized direction vectors only.
  2320. * @param x value to transform
  2321. * @param y value to transform
  2322. * @param z value to transform
  2323. * @param w value to transform
  2324. * @param transformation the transformation matrix to apply
  2325. * @param result the vector to store the results in
  2326. */
  2327. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2328. /**
  2329. * Creates a new Vector4 from a Vector3
  2330. * @param source defines the source data
  2331. * @param w defines the 4th component (default is 0)
  2332. * @returns a new Vector4
  2333. */
  2334. static FromVector3(source: Vector3, w?: number): Vector4;
  2335. }
  2336. /**
  2337. * Interface for the size containing width and height
  2338. */
  2339. export interface ISize {
  2340. /**
  2341. * Width
  2342. */
  2343. width: number;
  2344. /**
  2345. * Heighht
  2346. */
  2347. height: number;
  2348. }
  2349. /**
  2350. * Size containing widht and height
  2351. */
  2352. export class Size implements ISize {
  2353. /**
  2354. * Width
  2355. */
  2356. width: number;
  2357. /**
  2358. * Height
  2359. */
  2360. height: number;
  2361. /**
  2362. * Creates a Size object from the given width and height (floats).
  2363. * @param width width of the new size
  2364. * @param height height of the new size
  2365. */
  2366. constructor(width: number, height: number);
  2367. /**
  2368. * Returns a string with the Size width and height
  2369. * @returns a string with the Size width and height
  2370. */
  2371. toString(): string;
  2372. /**
  2373. * "Size"
  2374. * @returns the string "Size"
  2375. */
  2376. getClassName(): string;
  2377. /**
  2378. * Returns the Size hash code.
  2379. * @returns a hash code for a unique width and height
  2380. */
  2381. getHashCode(): number;
  2382. /**
  2383. * Updates the current size from the given one.
  2384. * @param src the given size
  2385. */
  2386. copyFrom(src: Size): void;
  2387. /**
  2388. * Updates in place the current Size from the given floats.
  2389. * @param width width of the new size
  2390. * @param height height of the new size
  2391. * @returns the updated Size.
  2392. */
  2393. copyFromFloats(width: number, height: number): Size;
  2394. /**
  2395. * Updates in place the current Size from the given floats.
  2396. * @param width width to set
  2397. * @param height height to set
  2398. * @returns the updated Size.
  2399. */
  2400. set(width: number, height: number): Size;
  2401. /**
  2402. * Multiplies the width and height by numbers
  2403. * @param w factor to multiple the width by
  2404. * @param h factor to multiple the height by
  2405. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2406. */
  2407. multiplyByFloats(w: number, h: number): Size;
  2408. /**
  2409. * Clones the size
  2410. * @returns a new Size copied from the given one.
  2411. */
  2412. clone(): Size;
  2413. /**
  2414. * True if the current Size and the given one width and height are strictly equal.
  2415. * @param other the other size to compare against
  2416. * @returns True if the current Size and the given one width and height are strictly equal.
  2417. */
  2418. equals(other: Size): boolean;
  2419. /**
  2420. * The surface of the Size : width * height (float).
  2421. */
  2422. readonly surface: number;
  2423. /**
  2424. * Create a new size of zero
  2425. * @returns a new Size set to (0.0, 0.0)
  2426. */
  2427. static Zero(): Size;
  2428. /**
  2429. * Sums the width and height of two sizes
  2430. * @param otherSize size to add to this size
  2431. * @returns a new Size set as the addition result of the current Size and the given one.
  2432. */
  2433. add(otherSize: Size): Size;
  2434. /**
  2435. * Subtracts the width and height of two
  2436. * @param otherSize size to subtract to this size
  2437. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2438. */
  2439. subtract(otherSize: Size): Size;
  2440. /**
  2441. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2442. * @param start starting size to lerp between
  2443. * @param end end size to lerp between
  2444. * @param amount amount to lerp between the start and end values
  2445. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2446. */
  2447. static Lerp(start: Size, end: Size, amount: number): Size;
  2448. }
  2449. /**
  2450. * Class used to store quaternion data
  2451. * @see https://en.wikipedia.org/wiki/Quaternion
  2452. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2453. */
  2454. export class Quaternion {
  2455. /** defines the first component (0 by default) */
  2456. x: number;
  2457. /** defines the second component (0 by default) */
  2458. y: number;
  2459. /** defines the third component (0 by default) */
  2460. z: number;
  2461. /** defines the fourth component (1.0 by default) */
  2462. w: number;
  2463. /**
  2464. * Creates a new Quaternion from the given floats
  2465. * @param x defines the first component (0 by default)
  2466. * @param y defines the second component (0 by default)
  2467. * @param z defines the third component (0 by default)
  2468. * @param w defines the fourth component (1.0 by default)
  2469. */
  2470. constructor(
  2471. /** defines the first component (0 by default) */
  2472. x?: number,
  2473. /** defines the second component (0 by default) */
  2474. y?: number,
  2475. /** defines the third component (0 by default) */
  2476. z?: number,
  2477. /** defines the fourth component (1.0 by default) */
  2478. w?: number);
  2479. /**
  2480. * Gets a string representation for the current quaternion
  2481. * @returns a string with the Quaternion coordinates
  2482. */
  2483. toString(): string;
  2484. /**
  2485. * Gets the class name of the quaternion
  2486. * @returns the string "Quaternion"
  2487. */
  2488. getClassName(): string;
  2489. /**
  2490. * Gets a hash code for this quaternion
  2491. * @returns the quaternion hash code
  2492. */
  2493. getHashCode(): number;
  2494. /**
  2495. * Copy the quaternion to an array
  2496. * @returns a new array populated with 4 elements from the quaternion coordinates
  2497. */
  2498. asArray(): number[];
  2499. /**
  2500. * Check if two quaternions are equals
  2501. * @param otherQuaternion defines the second operand
  2502. * @return true if the current quaternion and the given one coordinates are strictly equals
  2503. */
  2504. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2505. /**
  2506. * Clone the current quaternion
  2507. * @returns a new quaternion copied from the current one
  2508. */
  2509. clone(): Quaternion;
  2510. /**
  2511. * Copy a quaternion to the current one
  2512. * @param other defines the other quaternion
  2513. * @returns the updated current quaternion
  2514. */
  2515. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2516. /**
  2517. * Updates the current quaternion with the given float coordinates
  2518. * @param x defines the x coordinate
  2519. * @param y defines the y coordinate
  2520. * @param z defines the z coordinate
  2521. * @param w defines the w coordinate
  2522. * @returns the updated current quaternion
  2523. */
  2524. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2525. /**
  2526. * Updates the current quaternion from the given float coordinates
  2527. * @param x defines the x coordinate
  2528. * @param y defines the y coordinate
  2529. * @param z defines the z coordinate
  2530. * @param w defines the w coordinate
  2531. * @returns the updated current quaternion
  2532. */
  2533. set(x: number, y: number, z: number, w: number): Quaternion;
  2534. /**
  2535. * Adds two quaternions
  2536. * @param other defines the second operand
  2537. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2538. */
  2539. add(other: DeepImmutable<Quaternion>): Quaternion;
  2540. /**
  2541. * Add a quaternion to the current one
  2542. * @param other defines the quaternion to add
  2543. * @returns the current quaternion
  2544. */
  2545. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2546. /**
  2547. * Subtract two quaternions
  2548. * @param other defines the second operand
  2549. * @returns a new quaternion as the subtraction result of the given one from the current one
  2550. */
  2551. subtract(other: Quaternion): Quaternion;
  2552. /**
  2553. * Multiplies the current quaternion by a scale factor
  2554. * @param value defines the scale factor
  2555. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2556. */
  2557. scale(value: number): Quaternion;
  2558. /**
  2559. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2560. * @param scale defines the scale factor
  2561. * @param result defines the Quaternion object where to store the result
  2562. * @returns the unmodified current quaternion
  2563. */
  2564. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2565. /**
  2566. * Multiplies in place the current quaternion by a scale factor
  2567. * @param value defines the scale factor
  2568. * @returns the current modified quaternion
  2569. */
  2570. scaleInPlace(value: number): Quaternion;
  2571. /**
  2572. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2573. * @param scale defines the scale factor
  2574. * @param result defines the Quaternion object where to store the result
  2575. * @returns the unmodified current quaternion
  2576. */
  2577. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2578. /**
  2579. * Multiplies two quaternions
  2580. * @param q1 defines the second operand
  2581. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2582. */
  2583. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2584. /**
  2585. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2586. * @param q1 defines the second operand
  2587. * @param result defines the target quaternion
  2588. * @returns the current quaternion
  2589. */
  2590. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2591. /**
  2592. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2593. * @param q1 defines the second operand
  2594. * @returns the currentupdated quaternion
  2595. */
  2596. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2597. /**
  2598. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2599. * @param ref defines the target quaternion
  2600. * @returns the current quaternion
  2601. */
  2602. conjugateToRef(ref: Quaternion): Quaternion;
  2603. /**
  2604. * Conjugates in place (1-q) the current quaternion
  2605. * @returns the current updated quaternion
  2606. */
  2607. conjugateInPlace(): Quaternion;
  2608. /**
  2609. * Conjugates in place (1-q) the current quaternion
  2610. * @returns a new quaternion
  2611. */
  2612. conjugate(): Quaternion;
  2613. /**
  2614. * Gets length of current quaternion
  2615. * @returns the quaternion length (float)
  2616. */
  2617. length(): number;
  2618. /**
  2619. * Normalize in place the current quaternion
  2620. * @returns the current updated quaternion
  2621. */
  2622. normalize(): Quaternion;
  2623. /**
  2624. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2625. * @param order is a reserved parameter and is ignore for now
  2626. * @returns a new Vector3 containing the Euler angles
  2627. */
  2628. toEulerAngles(order?: string): Vector3;
  2629. /**
  2630. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2631. * @param result defines the vector which will be filled with the Euler angles
  2632. * @param order is a reserved parameter and is ignore for now
  2633. * @returns the current unchanged quaternion
  2634. */
  2635. toEulerAnglesToRef(result: Vector3): Quaternion;
  2636. /**
  2637. * Updates the given rotation matrix with the current quaternion values
  2638. * @param result defines the target matrix
  2639. * @returns the current unchanged quaternion
  2640. */
  2641. toRotationMatrix(result: Matrix): Quaternion;
  2642. /**
  2643. * Updates the current quaternion from the given rotation matrix values
  2644. * @param matrix defines the source matrix
  2645. * @returns the current updated quaternion
  2646. */
  2647. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2648. /**
  2649. * Creates a new quaternion from a rotation matrix
  2650. * @param matrix defines the source matrix
  2651. * @returns a new quaternion created from the given rotation matrix values
  2652. */
  2653. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2654. /**
  2655. * Updates the given quaternion with the given rotation matrix values
  2656. * @param matrix defines the source matrix
  2657. * @param result defines the target quaternion
  2658. */
  2659. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2660. /**
  2661. * Returns the dot product (float) between the quaternions "left" and "right"
  2662. * @param left defines the left operand
  2663. * @param right defines the right operand
  2664. * @returns the dot product
  2665. */
  2666. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2667. /**
  2668. * Checks if the two quaternions are close to each other
  2669. * @param quat0 defines the first quaternion to check
  2670. * @param quat1 defines the second quaternion to check
  2671. * @returns true if the two quaternions are close to each other
  2672. */
  2673. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2674. /**
  2675. * Creates an empty quaternion
  2676. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2677. */
  2678. static Zero(): Quaternion;
  2679. /**
  2680. * Inverse a given quaternion
  2681. * @param q defines the source quaternion
  2682. * @returns a new quaternion as the inverted current quaternion
  2683. */
  2684. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2685. /**
  2686. * Inverse a given quaternion
  2687. * @param q defines the source quaternion
  2688. * @param result the quaternion the result will be stored in
  2689. * @returns the result quaternion
  2690. */
  2691. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2692. /**
  2693. * Creates an identity quaternion
  2694. * @returns the identity quaternion
  2695. */
  2696. static Identity(): Quaternion;
  2697. /**
  2698. * Gets a boolean indicating if the given quaternion is identity
  2699. * @param quaternion defines the quaternion to check
  2700. * @returns true if the quaternion is identity
  2701. */
  2702. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2703. /**
  2704. * Creates a quaternion from a rotation around an axis
  2705. * @param axis defines the axis to use
  2706. * @param angle defines the angle to use
  2707. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2708. */
  2709. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2710. /**
  2711. * Creates a rotation around an axis and stores it into the given quaternion
  2712. * @param axis defines the axis to use
  2713. * @param angle defines the angle to use
  2714. * @param result defines the target quaternion
  2715. * @returns the target quaternion
  2716. */
  2717. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2718. /**
  2719. * Creates a new quaternion from data stored into an array
  2720. * @param array defines the data source
  2721. * @param offset defines the offset in the source array where the data starts
  2722. * @returns a new quaternion
  2723. */
  2724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2725. /**
  2726. * Create a quaternion from Euler rotation angles
  2727. * @param x Pitch
  2728. * @param y Yaw
  2729. * @param z Roll
  2730. * @returns the new Quaternion
  2731. */
  2732. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2733. /**
  2734. * Updates a quaternion from Euler rotation angles
  2735. * @param x Pitch
  2736. * @param y Yaw
  2737. * @param z Roll
  2738. * @param result the quaternion to store the result
  2739. * @returns the updated quaternion
  2740. */
  2741. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2742. /**
  2743. * Create a quaternion from Euler rotation vector
  2744. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2745. * @returns the new Quaternion
  2746. */
  2747. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2748. /**
  2749. * Updates a quaternion from Euler rotation vector
  2750. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2751. * @param result the quaternion to store the result
  2752. * @returns the updated quaternion
  2753. */
  2754. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2755. /**
  2756. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2757. * @param yaw defines the rotation around Y axis
  2758. * @param pitch defines the rotation around X axis
  2759. * @param roll defines the rotation around Z axis
  2760. * @returns the new quaternion
  2761. */
  2762. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2763. /**
  2764. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2765. * @param yaw defines the rotation around Y axis
  2766. * @param pitch defines the rotation around X axis
  2767. * @param roll defines the rotation around Z axis
  2768. * @param result defines the target quaternion
  2769. */
  2770. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2771. /**
  2772. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2773. * @param alpha defines the rotation around first axis
  2774. * @param beta defines the rotation around second axis
  2775. * @param gamma defines the rotation around third axis
  2776. * @returns the new quaternion
  2777. */
  2778. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2779. /**
  2780. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2781. * @param alpha defines the rotation around first axis
  2782. * @param beta defines the rotation around second axis
  2783. * @param gamma defines the rotation around third axis
  2784. * @param result defines the target quaternion
  2785. */
  2786. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2787. /**
  2788. * 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)
  2789. * @param axis1 defines the first axis
  2790. * @param axis2 defines the second axis
  2791. * @param axis3 defines the third axis
  2792. * @returns the new quaternion
  2793. */
  2794. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2795. /**
  2796. * 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
  2797. * @param axis1 defines the first axis
  2798. * @param axis2 defines the second axis
  2799. * @param axis3 defines the third axis
  2800. * @param ref defines the target quaternion
  2801. */
  2802. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2803. /**
  2804. * Interpolates between two quaternions
  2805. * @param left defines first quaternion
  2806. * @param right defines second quaternion
  2807. * @param amount defines the gradient to use
  2808. * @returns the new interpolated quaternion
  2809. */
  2810. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2811. /**
  2812. * Interpolates between two quaternions and stores it into a target quaternion
  2813. * @param left defines first quaternion
  2814. * @param right defines second quaternion
  2815. * @param amount defines the gradient to use
  2816. * @param result defines the target quaternion
  2817. */
  2818. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2819. /**
  2820. * Interpolate between two quaternions using Hermite interpolation
  2821. * @param value1 defines first quaternion
  2822. * @param tangent1 defines the incoming tangent
  2823. * @param value2 defines second quaternion
  2824. * @param tangent2 defines the outgoing tangent
  2825. * @param amount defines the target quaternion
  2826. * @returns the new interpolated quaternion
  2827. */
  2828. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2829. }
  2830. /**
  2831. * Class used to store matrix data (4x4)
  2832. */
  2833. export class Matrix {
  2834. private static _updateFlagSeed;
  2835. private static _identityReadOnly;
  2836. private _isIdentity;
  2837. private _isIdentityDirty;
  2838. private _isIdentity3x2;
  2839. private _isIdentity3x2Dirty;
  2840. /**
  2841. * Gets the update flag of the matrix which is an unique number for the matrix.
  2842. * It will be incremented every time the matrix data change.
  2843. * You can use it to speed the comparison between two versions of the same matrix.
  2844. */
  2845. updateFlag: number;
  2846. private readonly _m;
  2847. /**
  2848. * Gets the internal data of the matrix
  2849. */
  2850. readonly m: DeepImmutable<Float32Array>;
  2851. /** @hidden */
  2852. _markAsUpdated(): void;
  2853. /** @hidden */
  2854. private _updateIdentityStatus;
  2855. /**
  2856. * Creates an empty matrix (filled with zeros)
  2857. */
  2858. constructor();
  2859. /**
  2860. * Check if the current matrix is identity
  2861. * @returns true is the matrix is the identity matrix
  2862. */
  2863. isIdentity(): boolean;
  2864. /**
  2865. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2866. * @returns true is the matrix is the identity matrix
  2867. */
  2868. isIdentityAs3x2(): boolean;
  2869. /**
  2870. * Gets the determinant of the matrix
  2871. * @returns the matrix determinant
  2872. */
  2873. determinant(): number;
  2874. /**
  2875. * Returns the matrix as a Float32Array
  2876. * @returns the matrix underlying array
  2877. */
  2878. toArray(): DeepImmutable<Float32Array>;
  2879. /**
  2880. * Returns the matrix as a Float32Array
  2881. * @returns the matrix underlying array.
  2882. */
  2883. asArray(): DeepImmutable<Float32Array>;
  2884. /**
  2885. * Inverts the current matrix in place
  2886. * @returns the current inverted matrix
  2887. */
  2888. invert(): Matrix;
  2889. /**
  2890. * Sets all the matrix elements to zero
  2891. * @returns the current matrix
  2892. */
  2893. reset(): Matrix;
  2894. /**
  2895. * Adds the current matrix with a second one
  2896. * @param other defines the matrix to add
  2897. * @returns a new matrix as the addition of the current matrix and the given one
  2898. */
  2899. add(other: DeepImmutable<Matrix>): Matrix;
  2900. /**
  2901. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2902. * @param other defines the matrix to add
  2903. * @param result defines the target matrix
  2904. * @returns the current matrix
  2905. */
  2906. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2907. /**
  2908. * Adds in place the given matrix to the current matrix
  2909. * @param other defines the second operand
  2910. * @returns the current updated matrix
  2911. */
  2912. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2913. /**
  2914. * Sets the given matrix to the current inverted Matrix
  2915. * @param other defines the target matrix
  2916. * @returns the unmodified current matrix
  2917. */
  2918. invertToRef(other: Matrix): Matrix;
  2919. /**
  2920. * add a value at the specified position in the current Matrix
  2921. * @param index the index of the value within the matrix. between 0 and 15.
  2922. * @param value the value to be added
  2923. * @returns the current updated matrix
  2924. */
  2925. addAtIndex(index: number, value: number): Matrix;
  2926. /**
  2927. * mutiply the specified position in the current Matrix by a value
  2928. * @param index the index of the value within the matrix. between 0 and 15.
  2929. * @param value the value to be added
  2930. * @returns the current updated matrix
  2931. */
  2932. multiplyAtIndex(index: number, value: number): Matrix;
  2933. /**
  2934. * Inserts the translation vector (using 3 floats) in the current matrix
  2935. * @param x defines the 1st component of the translation
  2936. * @param y defines the 2nd component of the translation
  2937. * @param z defines the 3rd component of the translation
  2938. * @returns the current updated matrix
  2939. */
  2940. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2941. /**
  2942. * Inserts the translation vector in the current matrix
  2943. * @param vector3 defines the translation to insert
  2944. * @returns the current updated matrix
  2945. */
  2946. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2947. /**
  2948. * Gets the translation value of the current matrix
  2949. * @returns a new Vector3 as the extracted translation from the matrix
  2950. */
  2951. getTranslation(): Vector3;
  2952. /**
  2953. * Fill a Vector3 with the extracted translation from the matrix
  2954. * @param result defines the Vector3 where to store the translation
  2955. * @returns the current matrix
  2956. */
  2957. getTranslationToRef(result: Vector3): Matrix;
  2958. /**
  2959. * Remove rotation and scaling part from the matrix
  2960. * @returns the updated matrix
  2961. */
  2962. removeRotationAndScaling(): Matrix;
  2963. /**
  2964. * Multiply two matrices
  2965. * @param other defines the second operand
  2966. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2967. */
  2968. multiply(other: DeepImmutable<Matrix>): Matrix;
  2969. /**
  2970. * Copy the current matrix from the given one
  2971. * @param other defines the source matrix
  2972. * @returns the current updated matrix
  2973. */
  2974. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2975. /**
  2976. * Populates the given array from the starting index with the current matrix values
  2977. * @param array defines the target array
  2978. * @param offset defines the offset in the target array where to start storing values
  2979. * @returns the current matrix
  2980. */
  2981. copyToArray(array: Float32Array, offset?: number): Matrix;
  2982. /**
  2983. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2984. * @param other defines the second operand
  2985. * @param result defines the matrix where to store the multiplication
  2986. * @returns the current matrix
  2987. */
  2988. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2989. /**
  2990. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2991. * @param other defines the second operand
  2992. * @param result defines the array where to store the multiplication
  2993. * @param offset defines the offset in the target array where to start storing values
  2994. * @returns the current matrix
  2995. */
  2996. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2997. /**
  2998. * Check equality between this matrix and a second one
  2999. * @param value defines the second matrix to compare
  3000. * @returns true is the current matrix and the given one values are strictly equal
  3001. */
  3002. equals(value: DeepImmutable<Matrix>): boolean;
  3003. /**
  3004. * Clone the current matrix
  3005. * @returns a new matrix from the current matrix
  3006. */
  3007. clone(): Matrix;
  3008. /**
  3009. * Returns the name of the current matrix class
  3010. * @returns the string "Matrix"
  3011. */
  3012. getClassName(): string;
  3013. /**
  3014. * Gets the hash code of the current matrix
  3015. * @returns the hash code
  3016. */
  3017. getHashCode(): number;
  3018. /**
  3019. * Decomposes the current Matrix into a translation, rotation and scaling components
  3020. * @param scale defines the scale vector3 given as a reference to update
  3021. * @param rotation defines the rotation quaternion given as a reference to update
  3022. * @param translation defines the translation vector3 given as a reference to update
  3023. * @returns true if operation was successful
  3024. */
  3025. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3026. /**
  3027. * Gets specific row of the matrix
  3028. * @param index defines the number of the row to get
  3029. * @returns the index-th row of the current matrix as a new Vector4
  3030. */
  3031. getRow(index: number): Nullable<Vector4>;
  3032. /**
  3033. * Sets the index-th row of the current matrix to the vector4 values
  3034. * @param index defines the number of the row to set
  3035. * @param row defines the target vector4
  3036. * @returns the updated current matrix
  3037. */
  3038. setRow(index: number, row: Vector4): Matrix;
  3039. /**
  3040. * Compute the transpose of the matrix
  3041. * @returns the new transposed matrix
  3042. */
  3043. transpose(): Matrix;
  3044. /**
  3045. * Compute the transpose of the matrix and store it in a given matrix
  3046. * @param result defines the target matrix
  3047. * @returns the current matrix
  3048. */
  3049. transposeToRef(result: Matrix): Matrix;
  3050. /**
  3051. * Sets the index-th row of the current matrix with the given 4 x float values
  3052. * @param index defines the row index
  3053. * @param x defines the x component to set
  3054. * @param y defines the y component to set
  3055. * @param z defines the z component to set
  3056. * @param w defines the w component to set
  3057. * @returns the updated current matrix
  3058. */
  3059. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3060. /**
  3061. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3062. * @param scale defines the scale factor
  3063. * @returns a new matrix
  3064. */
  3065. scale(scale: number): Matrix;
  3066. /**
  3067. * Scale the current matrix values by a factor to a given result matrix
  3068. * @param scale defines the scale factor
  3069. * @param result defines the matrix to store the result
  3070. * @returns the current matrix
  3071. */
  3072. scaleToRef(scale: number, result: Matrix): Matrix;
  3073. /**
  3074. * Scale the current matrix values by a factor and add the result to a given matrix
  3075. * @param scale defines the scale factor
  3076. * @param result defines the Matrix to store the result
  3077. * @returns the current matrix
  3078. */
  3079. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3080. /**
  3081. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3082. * @param ref matrix to store the result
  3083. */
  3084. toNormalMatrix(ref: Matrix): void;
  3085. /**
  3086. * Gets only rotation part of the current matrix
  3087. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3088. */
  3089. getRotationMatrix(): Matrix;
  3090. /**
  3091. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3092. * @param result defines the target matrix to store data to
  3093. * @returns the current matrix
  3094. */
  3095. getRotationMatrixToRef(result: Matrix): Matrix;
  3096. /**
  3097. * Toggles model matrix from being right handed to left handed in place and vice versa
  3098. */
  3099. toggleModelMatrixHandInPlace(): void;
  3100. /**
  3101. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3102. */
  3103. toggleProjectionMatrixHandInPlace(): void;
  3104. /**
  3105. * Creates a matrix from an array
  3106. * @param array defines the source array
  3107. * @param offset defines an offset in the source array
  3108. * @returns a new Matrix set from the starting index of the given array
  3109. */
  3110. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3111. /**
  3112. * Copy the content of an array into a given matrix
  3113. * @param array defines the source array
  3114. * @param offset defines an offset in the source array
  3115. * @param result defines the target matrix
  3116. */
  3117. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3118. /**
  3119. * Stores an array into a matrix after having multiplied each component by a given factor
  3120. * @param array defines the source array
  3121. * @param offset defines the offset in the source array
  3122. * @param scale defines the scaling factor
  3123. * @param result defines the target matrix
  3124. */
  3125. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3126. /**
  3127. * Gets an identity matrix that must not be updated
  3128. */
  3129. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3130. /**
  3131. * Stores a list of values (16) inside a given matrix
  3132. * @param initialM11 defines 1st value of 1st row
  3133. * @param initialM12 defines 2nd value of 1st row
  3134. * @param initialM13 defines 3rd value of 1st row
  3135. * @param initialM14 defines 4th value of 1st row
  3136. * @param initialM21 defines 1st value of 2nd row
  3137. * @param initialM22 defines 2nd value of 2nd row
  3138. * @param initialM23 defines 3rd value of 2nd row
  3139. * @param initialM24 defines 4th value of 2nd row
  3140. * @param initialM31 defines 1st value of 3rd row
  3141. * @param initialM32 defines 2nd value of 3rd row
  3142. * @param initialM33 defines 3rd value of 3rd row
  3143. * @param initialM34 defines 4th value of 3rd row
  3144. * @param initialM41 defines 1st value of 4th row
  3145. * @param initialM42 defines 2nd value of 4th row
  3146. * @param initialM43 defines 3rd value of 4th row
  3147. * @param initialM44 defines 4th value of 4th row
  3148. * @param result defines the target matrix
  3149. */
  3150. 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;
  3151. /**
  3152. * Creates new matrix from a list of values (16)
  3153. * @param initialM11 defines 1st value of 1st row
  3154. * @param initialM12 defines 2nd value of 1st row
  3155. * @param initialM13 defines 3rd value of 1st row
  3156. * @param initialM14 defines 4th value of 1st row
  3157. * @param initialM21 defines 1st value of 2nd row
  3158. * @param initialM22 defines 2nd value of 2nd row
  3159. * @param initialM23 defines 3rd value of 2nd row
  3160. * @param initialM24 defines 4th value of 2nd row
  3161. * @param initialM31 defines 1st value of 3rd row
  3162. * @param initialM32 defines 2nd value of 3rd row
  3163. * @param initialM33 defines 3rd value of 3rd row
  3164. * @param initialM34 defines 4th value of 3rd row
  3165. * @param initialM41 defines 1st value of 4th row
  3166. * @param initialM42 defines 2nd value of 4th row
  3167. * @param initialM43 defines 3rd value of 4th row
  3168. * @param initialM44 defines 4th value of 4th row
  3169. * @returns the new matrix
  3170. */
  3171. 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;
  3172. /**
  3173. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3174. * @param scale defines the scale vector3
  3175. * @param rotation defines the rotation quaternion
  3176. * @param translation defines the translation vector3
  3177. * @returns a new matrix
  3178. */
  3179. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3180. /**
  3181. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3182. * @param scale defines the scale vector3
  3183. * @param rotation defines the rotation quaternion
  3184. * @param translation defines the translation vector3
  3185. * @param result defines the target matrix
  3186. */
  3187. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3188. /**
  3189. * Creates a new identity matrix
  3190. * @returns a new identity matrix
  3191. */
  3192. static Identity(): Matrix;
  3193. /**
  3194. * Creates a new identity matrix and stores the result in a given matrix
  3195. * @param result defines the target matrix
  3196. */
  3197. static IdentityToRef(result: Matrix): void;
  3198. /**
  3199. * Creates a new zero matrix
  3200. * @returns a new zero matrix
  3201. */
  3202. static Zero(): Matrix;
  3203. /**
  3204. * Creates a new rotation matrix for "angle" radians around the X axis
  3205. * @param angle defines the angle (in radians) to use
  3206. * @return the new matrix
  3207. */
  3208. static RotationX(angle: number): Matrix;
  3209. /**
  3210. * Creates a new matrix as the invert of a given matrix
  3211. * @param source defines the source matrix
  3212. * @returns the new matrix
  3213. */
  3214. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3215. /**
  3216. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3217. * @param angle defines the angle (in radians) to use
  3218. * @param result defines the target matrix
  3219. */
  3220. static RotationXToRef(angle: number, result: Matrix): void;
  3221. /**
  3222. * Creates a new rotation matrix for "angle" radians around the Y axis
  3223. * @param angle defines the angle (in radians) to use
  3224. * @return the new matrix
  3225. */
  3226. static RotationY(angle: number): Matrix;
  3227. /**
  3228. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3229. * @param angle defines the angle (in radians) to use
  3230. * @param result defines the target matrix
  3231. */
  3232. static RotationYToRef(angle: number, result: Matrix): void;
  3233. /**
  3234. * Creates a new rotation matrix for "angle" radians around the Z axis
  3235. * @param angle defines the angle (in radians) to use
  3236. * @return the new matrix
  3237. */
  3238. static RotationZ(angle: number): Matrix;
  3239. /**
  3240. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3241. * @param angle defines the angle (in radians) to use
  3242. * @param result defines the target matrix
  3243. */
  3244. static RotationZToRef(angle: number, result: Matrix): void;
  3245. /**
  3246. * Creates a new rotation matrix for "angle" radians around the given axis
  3247. * @param axis defines the axis to use
  3248. * @param angle defines the angle (in radians) to use
  3249. * @return the new matrix
  3250. */
  3251. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3252. /**
  3253. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3254. * @param axis defines the axis to use
  3255. * @param angle defines the angle (in radians) to use
  3256. * @param result defines the target matrix
  3257. */
  3258. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3259. /**
  3260. * Creates a rotation matrix
  3261. * @param yaw defines the yaw angle in radians (Y axis)
  3262. * @param pitch defines the pitch angle in radians (X axis)
  3263. * @param roll defines the roll angle in radians (X axis)
  3264. * @returns the new rotation matrix
  3265. */
  3266. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3267. /**
  3268. * Creates a rotation matrix and stores it in a given matrix
  3269. * @param yaw defines the yaw angle in radians (Y axis)
  3270. * @param pitch defines the pitch angle in radians (X axis)
  3271. * @param roll defines the roll angle in radians (X axis)
  3272. * @param result defines the target matrix
  3273. */
  3274. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3275. /**
  3276. * Creates a scaling matrix
  3277. * @param x defines the scale factor on X axis
  3278. * @param y defines the scale factor on Y axis
  3279. * @param z defines the scale factor on Z axis
  3280. * @returns the new matrix
  3281. */
  3282. static Scaling(x: number, y: number, z: number): Matrix;
  3283. /**
  3284. * Creates a scaling matrix and stores it in a given matrix
  3285. * @param x defines the scale factor on X axis
  3286. * @param y defines the scale factor on Y axis
  3287. * @param z defines the scale factor on Z axis
  3288. * @param result defines the target matrix
  3289. */
  3290. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3291. /**
  3292. * Creates a translation matrix
  3293. * @param x defines the translation on X axis
  3294. * @param y defines the translation on Y axis
  3295. * @param z defines the translationon Z axis
  3296. * @returns the new matrix
  3297. */
  3298. static Translation(x: number, y: number, z: number): Matrix;
  3299. /**
  3300. * Creates a translation matrix and stores it in a given matrix
  3301. * @param x defines the translation on X axis
  3302. * @param y defines the translation on Y axis
  3303. * @param z defines the translationon Z axis
  3304. * @param result defines the target matrix
  3305. */
  3306. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3307. /**
  3308. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3309. * @param startValue defines the start value
  3310. * @param endValue defines the end value
  3311. * @param gradient defines the gradient factor
  3312. * @returns the new matrix
  3313. */
  3314. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3315. /**
  3316. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3317. * @param startValue defines the start value
  3318. * @param endValue defines the end value
  3319. * @param gradient defines the gradient factor
  3320. * @param result defines the Matrix object where to store data
  3321. */
  3322. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3323. /**
  3324. * Builds a new matrix whose values are computed by:
  3325. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3326. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3327. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3328. * @param startValue defines the first matrix
  3329. * @param endValue defines the second matrix
  3330. * @param gradient defines the gradient between the two matrices
  3331. * @returns the new matrix
  3332. */
  3333. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3334. /**
  3335. * Update a matrix to values which are computed by:
  3336. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3337. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3338. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3339. * @param startValue defines the first matrix
  3340. * @param endValue defines the second matrix
  3341. * @param gradient defines the gradient between the two matrices
  3342. * @param result defines the target matrix
  3343. */
  3344. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3345. /**
  3346. * 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"
  3347. * This function works in left handed mode
  3348. * @param eye defines the final position of the entity
  3349. * @param target defines where the entity should look at
  3350. * @param up defines the up vector for the entity
  3351. * @returns the new matrix
  3352. */
  3353. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3354. /**
  3355. * 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".
  3356. * This function works in left handed mode
  3357. * @param eye defines the final position of the entity
  3358. * @param target defines where the entity should look at
  3359. * @param up defines the up vector for the entity
  3360. * @param result defines the target matrix
  3361. */
  3362. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3363. /**
  3364. * 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"
  3365. * This function works in right handed mode
  3366. * @param eye defines the final position of the entity
  3367. * @param target defines where the entity should look at
  3368. * @param up defines the up vector for the entity
  3369. * @returns the new matrix
  3370. */
  3371. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3372. /**
  3373. * 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".
  3374. * This function works in right handed mode
  3375. * @param eye defines the final position of the entity
  3376. * @param target defines where the entity should look at
  3377. * @param up defines the up vector for the entity
  3378. * @param result defines the target matrix
  3379. */
  3380. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3381. /**
  3382. * Create a left-handed orthographic projection matrix
  3383. * @param width defines the viewport width
  3384. * @param height defines the viewport height
  3385. * @param znear defines the near clip plane
  3386. * @param zfar defines the far clip plane
  3387. * @returns a new matrix as a left-handed orthographic projection matrix
  3388. */
  3389. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3390. /**
  3391. * Store a left-handed orthographic projection to a given matrix
  3392. * @param width defines the viewport width
  3393. * @param height defines the viewport height
  3394. * @param znear defines the near clip plane
  3395. * @param zfar defines the far clip plane
  3396. * @param result defines the target matrix
  3397. */
  3398. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3399. /**
  3400. * Create a left-handed orthographic projection matrix
  3401. * @param left defines the viewport left coordinate
  3402. * @param right defines the viewport right coordinate
  3403. * @param bottom defines the viewport bottom coordinate
  3404. * @param top defines the viewport top coordinate
  3405. * @param znear defines the near clip plane
  3406. * @param zfar defines the far clip plane
  3407. * @returns a new matrix as a left-handed orthographic projection matrix
  3408. */
  3409. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3410. /**
  3411. * Stores a left-handed orthographic projection into a given matrix
  3412. * @param left defines the viewport left coordinate
  3413. * @param right defines the viewport right coordinate
  3414. * @param bottom defines the viewport bottom coordinate
  3415. * @param top defines the viewport top coordinate
  3416. * @param znear defines the near clip plane
  3417. * @param zfar defines the far clip plane
  3418. * @param result defines the target matrix
  3419. */
  3420. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3421. /**
  3422. * Creates a right-handed orthographic projection matrix
  3423. * @param left defines the viewport left coordinate
  3424. * @param right defines the viewport right coordinate
  3425. * @param bottom defines the viewport bottom coordinate
  3426. * @param top defines the viewport top coordinate
  3427. * @param znear defines the near clip plane
  3428. * @param zfar defines the far clip plane
  3429. * @returns a new matrix as a right-handed orthographic projection matrix
  3430. */
  3431. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3432. /**
  3433. * Stores a right-handed orthographic projection into a given matrix
  3434. * @param left defines the viewport left coordinate
  3435. * @param right defines the viewport right coordinate
  3436. * @param bottom defines the viewport bottom coordinate
  3437. * @param top defines the viewport top coordinate
  3438. * @param znear defines the near clip plane
  3439. * @param zfar defines the far clip plane
  3440. * @param result defines the target matrix
  3441. */
  3442. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3443. /**
  3444. * Creates a left-handed perspective projection matrix
  3445. * @param width defines the viewport width
  3446. * @param height defines the viewport height
  3447. * @param znear defines the near clip plane
  3448. * @param zfar defines the far clip plane
  3449. * @returns a new matrix as a left-handed perspective projection matrix
  3450. */
  3451. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3452. /**
  3453. * Creates a left-handed perspective projection matrix
  3454. * @param fov defines the horizontal field of view
  3455. * @param aspect defines the aspect ratio
  3456. * @param znear defines the near clip plane
  3457. * @param zfar defines the far clip plane
  3458. * @returns a new matrix as a left-handed perspective projection matrix
  3459. */
  3460. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3461. /**
  3462. * Stores a left-handed perspective projection into a given matrix
  3463. * @param fov defines the horizontal field of view
  3464. * @param aspect defines the aspect ratio
  3465. * @param znear defines the near clip plane
  3466. * @param zfar defines the far clip plane
  3467. * @param result defines the target matrix
  3468. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3469. */
  3470. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3471. /**
  3472. * Creates a right-handed perspective projection matrix
  3473. * @param fov defines the horizontal field of view
  3474. * @param aspect defines the aspect ratio
  3475. * @param znear defines the near clip plane
  3476. * @param zfar defines the far clip plane
  3477. * @returns a new matrix as a right-handed perspective projection matrix
  3478. */
  3479. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3480. /**
  3481. * Stores a right-handed perspective projection into a given matrix
  3482. * @param fov defines the horizontal field of view
  3483. * @param aspect defines the aspect ratio
  3484. * @param znear defines the near clip plane
  3485. * @param zfar defines the far clip plane
  3486. * @param result defines the target matrix
  3487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3488. */
  3489. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3490. /**
  3491. * Stores a perspective projection for WebVR info a given matrix
  3492. * @param fov defines the field of view
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @param result defines the target matrix
  3496. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3497. */
  3498. static PerspectiveFovWebVRToRef(fov: {
  3499. upDegrees: number;
  3500. downDegrees: number;
  3501. leftDegrees: number;
  3502. rightDegrees: number;
  3503. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3504. /**
  3505. * Computes a complete transformation matrix
  3506. * @param viewport defines the viewport to use
  3507. * @param world defines the world matrix
  3508. * @param view defines the view matrix
  3509. * @param projection defines the projection matrix
  3510. * @param zmin defines the near clip plane
  3511. * @param zmax defines the far clip plane
  3512. * @returns the transformation matrix
  3513. */
  3514. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3515. /**
  3516. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3517. * @param matrix defines the matrix to use
  3518. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3519. */
  3520. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3521. /**
  3522. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3523. * @param matrix defines the matrix to use
  3524. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3525. */
  3526. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3527. /**
  3528. * Compute the transpose of a given matrix
  3529. * @param matrix defines the matrix to transpose
  3530. * @returns the new matrix
  3531. */
  3532. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3533. /**
  3534. * Compute the transpose of a matrix and store it in a target matrix
  3535. * @param matrix defines the matrix to transpose
  3536. * @param result defines the target matrix
  3537. */
  3538. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3539. /**
  3540. * Computes a reflection matrix from a plane
  3541. * @param plane defines the reflection plane
  3542. * @returns a new matrix
  3543. */
  3544. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3545. /**
  3546. * Computes a reflection matrix from a plane
  3547. * @param plane defines the reflection plane
  3548. * @param result defines the target matrix
  3549. */
  3550. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3551. /**
  3552. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3553. * @param xaxis defines the value of the 1st axis
  3554. * @param yaxis defines the value of the 2nd axis
  3555. * @param zaxis defines the value of the 3rd axis
  3556. * @param result defines the target matrix
  3557. */
  3558. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3559. /**
  3560. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3561. * @param quat defines the quaternion to use
  3562. * @param result defines the target matrix
  3563. */
  3564. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3565. }
  3566. /**
  3567. * Represens a plane by the equation ax + by + cz + d = 0
  3568. */
  3569. export class Plane {
  3570. /**
  3571. * Normal of the plane (a,b,c)
  3572. */
  3573. normal: Vector3;
  3574. /**
  3575. * d component of the plane
  3576. */
  3577. d: number;
  3578. /**
  3579. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3580. * @param a a component of the plane
  3581. * @param b b component of the plane
  3582. * @param c c component of the plane
  3583. * @param d d component of the plane
  3584. */
  3585. constructor(a: number, b: number, c: number, d: number);
  3586. /**
  3587. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3588. */
  3589. asArray(): number[];
  3590. /**
  3591. * @returns a new plane copied from the current Plane.
  3592. */
  3593. clone(): Plane;
  3594. /**
  3595. * @returns the string "Plane".
  3596. */
  3597. getClassName(): string;
  3598. /**
  3599. * @returns the Plane hash code.
  3600. */
  3601. getHashCode(): number;
  3602. /**
  3603. * Normalize the current Plane in place.
  3604. * @returns the updated Plane.
  3605. */
  3606. normalize(): Plane;
  3607. /**
  3608. * Applies a transformation the plane and returns the result
  3609. * @param transformation the transformation matrix to be applied to the plane
  3610. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3611. */
  3612. transform(transformation: DeepImmutable<Matrix>): Plane;
  3613. /**
  3614. * Calcualtte the dot product between the point and the plane normal
  3615. * @param point point to calculate the dot product with
  3616. * @returns the dot product (float) of the point coordinates and the plane normal.
  3617. */
  3618. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3619. /**
  3620. * Updates the current Plane from the plane defined by the three given points.
  3621. * @param point1 one of the points used to contruct the plane
  3622. * @param point2 one of the points used to contruct the plane
  3623. * @param point3 one of the points used to contruct the plane
  3624. * @returns the updated Plane.
  3625. */
  3626. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3627. /**
  3628. * Checks if the plane is facing a given direction
  3629. * @param direction the direction to check if the plane is facing
  3630. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3631. * @returns True is the vector "direction" is the same side than the plane normal.
  3632. */
  3633. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3634. /**
  3635. * Calculates the distance to a point
  3636. * @param point point to calculate distance to
  3637. * @returns the signed distance (float) from the given point to the Plane.
  3638. */
  3639. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3640. /**
  3641. * Creates a plane from an array
  3642. * @param array the array to create a plane from
  3643. * @returns a new Plane from the given array.
  3644. */
  3645. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3646. /**
  3647. * Creates a plane from three points
  3648. * @param point1 point used to create the plane
  3649. * @param point2 point used to create the plane
  3650. * @param point3 point used to create the plane
  3651. * @returns a new Plane defined by the three given points.
  3652. */
  3653. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3654. /**
  3655. * Creates a plane from an origin point and a normal
  3656. * @param origin origin of the plane to be constructed
  3657. * @param normal normal of the plane to be constructed
  3658. * @returns a new Plane the normal vector to this plane at the given origin point.
  3659. * Note : the vector "normal" is updated because normalized.
  3660. */
  3661. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3662. /**
  3663. * Calculates the distance from a plane and a point
  3664. * @param origin origin of the plane to be constructed
  3665. * @param normal normal of the plane to be constructed
  3666. * @param point point to calculate distance to
  3667. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3668. */
  3669. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3670. }
  3671. /**
  3672. * Class used to represent a viewport on screen
  3673. */
  3674. export class Viewport {
  3675. /** viewport left coordinate */
  3676. x: number;
  3677. /** viewport top coordinate */
  3678. y: number;
  3679. /**viewport width */
  3680. width: number;
  3681. /** viewport height */
  3682. height: number;
  3683. /**
  3684. * Creates a Viewport object located at (x, y) and sized (width, height)
  3685. * @param x defines viewport left coordinate
  3686. * @param y defines viewport top coordinate
  3687. * @param width defines the viewport width
  3688. * @param height defines the viewport height
  3689. */
  3690. constructor(
  3691. /** viewport left coordinate */
  3692. x: number,
  3693. /** viewport top coordinate */
  3694. y: number,
  3695. /**viewport width */
  3696. width: number,
  3697. /** viewport height */
  3698. height: number);
  3699. /**
  3700. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3701. * @param renderWidth defines the rendering width
  3702. * @param renderHeight defines the rendering height
  3703. * @returns a new Viewport
  3704. */
  3705. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3706. /**
  3707. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3708. * @param renderWidth defines the rendering width
  3709. * @param renderHeight defines the rendering height
  3710. * @param ref defines the target viewport
  3711. * @returns the current viewport
  3712. */
  3713. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3714. /**
  3715. * Returns a new Viewport copied from the current one
  3716. * @returns a new Viewport
  3717. */
  3718. clone(): Viewport;
  3719. }
  3720. /**
  3721. * Reprasents a camera frustum
  3722. */
  3723. export class Frustum {
  3724. /**
  3725. * Gets the planes representing the frustum
  3726. * @param transform matrix to be applied to the returned planes
  3727. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3728. */
  3729. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3730. /**
  3731. * Gets the near frustum plane transformed by the transform matrix
  3732. * @param transform transformation matrix to be applied to the resulting frustum plane
  3733. * @param frustumPlane the resuling frustum plane
  3734. */
  3735. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3736. /**
  3737. * Gets the far frustum plane transformed by the transform matrix
  3738. * @param transform transformation matrix to be applied to the resulting frustum plane
  3739. * @param frustumPlane the resuling frustum plane
  3740. */
  3741. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3742. /**
  3743. * Gets the left frustum plane transformed by the transform matrix
  3744. * @param transform transformation matrix to be applied to the resulting frustum plane
  3745. * @param frustumPlane the resuling frustum plane
  3746. */
  3747. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3748. /**
  3749. * Gets the right frustum plane transformed by the transform matrix
  3750. * @param transform transformation matrix to be applied to the resulting frustum plane
  3751. * @param frustumPlane the resuling frustum plane
  3752. */
  3753. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3754. /**
  3755. * Gets the top frustum plane transformed by the transform matrix
  3756. * @param transform transformation matrix to be applied to the resulting frustum plane
  3757. * @param frustumPlane the resuling frustum plane
  3758. */
  3759. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3760. /**
  3761. * Gets the bottom frustum plane transformed by the transform matrix
  3762. * @param transform transformation matrix to be applied to the resulting frustum plane
  3763. * @param frustumPlane the resuling frustum plane
  3764. */
  3765. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3766. /**
  3767. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3768. * @param transform transformation matrix to be applied to the resulting frustum planes
  3769. * @param frustumPlanes the resuling frustum planes
  3770. */
  3771. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3772. }
  3773. /** Defines supported spaces */
  3774. export enum Space {
  3775. /** Local (object) space */
  3776. LOCAL = 0,
  3777. /** World space */
  3778. WORLD = 1,
  3779. /** Bone space */
  3780. BONE = 2
  3781. }
  3782. /** Defines the 3 main axes */
  3783. export class Axis {
  3784. /** X axis */
  3785. static X: Vector3;
  3786. /** Y axis */
  3787. static Y: Vector3;
  3788. /** Z axis */
  3789. static Z: Vector3;
  3790. }
  3791. /** Class used to represent a Bezier curve */
  3792. export class BezierCurve {
  3793. /**
  3794. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3795. * @param t defines the time
  3796. * @param x1 defines the left coordinate on X axis
  3797. * @param y1 defines the left coordinate on Y axis
  3798. * @param x2 defines the right coordinate on X axis
  3799. * @param y2 defines the right coordinate on Y axis
  3800. * @returns the interpolated value
  3801. */
  3802. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3803. }
  3804. /**
  3805. * Defines potential orientation for back face culling
  3806. */
  3807. export enum Orientation {
  3808. /**
  3809. * Clockwise
  3810. */
  3811. CW = 0,
  3812. /** Counter clockwise */
  3813. CCW = 1
  3814. }
  3815. /**
  3816. * Defines angle representation
  3817. */
  3818. export class Angle {
  3819. private _radians;
  3820. /**
  3821. * Creates an Angle object of "radians" radians (float).
  3822. * @param radians the angle in radians
  3823. */
  3824. constructor(radians: number);
  3825. /**
  3826. * Get value in degrees
  3827. * @returns the Angle value in degrees (float)
  3828. */
  3829. degrees(): number;
  3830. /**
  3831. * Get value in radians
  3832. * @returns the Angle value in radians (float)
  3833. */
  3834. radians(): number;
  3835. /**
  3836. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3837. * @param a defines first vector
  3838. * @param b defines second vector
  3839. * @returns a new Angle
  3840. */
  3841. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3842. /**
  3843. * Gets a new Angle object from the given float in radians
  3844. * @param radians defines the angle value in radians
  3845. * @returns a new Angle
  3846. */
  3847. static FromRadians(radians: number): Angle;
  3848. /**
  3849. * Gets a new Angle object from the given float in degrees
  3850. * @param degrees defines the angle value in degrees
  3851. * @returns a new Angle
  3852. */
  3853. static FromDegrees(degrees: number): Angle;
  3854. }
  3855. /**
  3856. * This represents an arc in a 2d space.
  3857. */
  3858. export class Arc2 {
  3859. /** Defines the start point of the arc */
  3860. startPoint: Vector2;
  3861. /** Defines the mid point of the arc */
  3862. midPoint: Vector2;
  3863. /** Defines the end point of the arc */
  3864. endPoint: Vector2;
  3865. /**
  3866. * Defines the center point of the arc.
  3867. */
  3868. centerPoint: Vector2;
  3869. /**
  3870. * Defines the radius of the arc.
  3871. */
  3872. radius: number;
  3873. /**
  3874. * Defines the angle of the arc (from mid point to end point).
  3875. */
  3876. angle: Angle;
  3877. /**
  3878. * Defines the start angle of the arc (from start point to middle point).
  3879. */
  3880. startAngle: Angle;
  3881. /**
  3882. * Defines the orientation of the arc (clock wise/counter clock wise).
  3883. */
  3884. orientation: Orientation;
  3885. /**
  3886. * Creates an Arc object from the three given points : start, middle and end.
  3887. * @param startPoint Defines the start point of the arc
  3888. * @param midPoint Defines the midlle point of the arc
  3889. * @param endPoint Defines the end point of the arc
  3890. */
  3891. constructor(
  3892. /** Defines the start point of the arc */
  3893. startPoint: Vector2,
  3894. /** Defines the mid point of the arc */
  3895. midPoint: Vector2,
  3896. /** Defines the end point of the arc */
  3897. endPoint: Vector2);
  3898. }
  3899. /**
  3900. * Represents a 2D path made up of multiple 2D points
  3901. */
  3902. export class Path2 {
  3903. private _points;
  3904. private _length;
  3905. /**
  3906. * If the path start and end point are the same
  3907. */
  3908. closed: boolean;
  3909. /**
  3910. * Creates a Path2 object from the starting 2D coordinates x and y.
  3911. * @param x the starting points x value
  3912. * @param y the starting points y value
  3913. */
  3914. constructor(x: number, y: number);
  3915. /**
  3916. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3917. * @param x the added points x value
  3918. * @param y the added points y value
  3919. * @returns the updated Path2.
  3920. */
  3921. addLineTo(x: number, y: number): Path2;
  3922. /**
  3923. * 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.
  3924. * @param midX middle point x value
  3925. * @param midY middle point y value
  3926. * @param endX end point x value
  3927. * @param endY end point y value
  3928. * @param numberOfSegments (default: 36)
  3929. * @returns the updated Path2.
  3930. */
  3931. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3932. /**
  3933. * Closes the Path2.
  3934. * @returns the Path2.
  3935. */
  3936. close(): Path2;
  3937. /**
  3938. * Gets the sum of the distance between each sequential point in the path
  3939. * @returns the Path2 total length (float).
  3940. */
  3941. length(): number;
  3942. /**
  3943. * Gets the points which construct the path
  3944. * @returns the Path2 internal array of points.
  3945. */
  3946. getPoints(): Vector2[];
  3947. /**
  3948. * Retreives the point at the distance aways from the starting point
  3949. * @param normalizedLengthPosition the length along the path to retreive the point from
  3950. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3951. */
  3952. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3953. /**
  3954. * Creates a new path starting from an x and y position
  3955. * @param x starting x value
  3956. * @param y starting y value
  3957. * @returns a new Path2 starting at the coordinates (x, y).
  3958. */
  3959. static StartingAt(x: number, y: number): Path2;
  3960. }
  3961. /**
  3962. * Represents a 3D path made up of multiple 3D points
  3963. */
  3964. export class Path3D {
  3965. /**
  3966. * an array of Vector3, the curve axis of the Path3D
  3967. */
  3968. path: Vector3[];
  3969. private _curve;
  3970. private _distances;
  3971. private _tangents;
  3972. private _normals;
  3973. private _binormals;
  3974. private _raw;
  3975. /**
  3976. * new Path3D(path, normal, raw)
  3977. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3978. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3979. * @param path an array of Vector3, the curve axis of the Path3D
  3980. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3981. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3982. */
  3983. constructor(
  3984. /**
  3985. * an array of Vector3, the curve axis of the Path3D
  3986. */
  3987. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3988. /**
  3989. * Returns the Path3D array of successive Vector3 designing its curve.
  3990. * @returns the Path3D array of successive Vector3 designing its curve.
  3991. */
  3992. getCurve(): Vector3[];
  3993. /**
  3994. * Returns an array populated with tangent vectors on each Path3D curve point.
  3995. * @returns an array populated with tangent vectors on each Path3D curve point.
  3996. */
  3997. getTangents(): Vector3[];
  3998. /**
  3999. * Returns an array populated with normal vectors on each Path3D curve point.
  4000. * @returns an array populated with normal vectors on each Path3D curve point.
  4001. */
  4002. getNormals(): Vector3[];
  4003. /**
  4004. * Returns an array populated with binormal vectors on each Path3D curve point.
  4005. * @returns an array populated with binormal vectors on each Path3D curve point.
  4006. */
  4007. getBinormals(): Vector3[];
  4008. /**
  4009. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4010. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. */
  4012. getDistances(): number[];
  4013. /**
  4014. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4015. * @param path path which all values are copied into the curves points
  4016. * @param firstNormal which should be projected onto the curve
  4017. * @returns the same object updated.
  4018. */
  4019. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4020. private _compute;
  4021. private _getFirstNonNullVector;
  4022. private _getLastNonNullVector;
  4023. private _normalVector;
  4024. }
  4025. /**
  4026. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4027. * A Curve3 is designed from a series of successive Vector3.
  4028. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4029. */
  4030. export class Curve3 {
  4031. private _points;
  4032. private _length;
  4033. /**
  4034. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4035. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4036. * @param v1 (Vector3) the control point
  4037. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4038. * @param nbPoints (integer) the wanted number of points in the curve
  4039. * @returns the created Curve3
  4040. */
  4041. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4042. /**
  4043. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4044. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4045. * @param v1 (Vector3) the first control point
  4046. * @param v2 (Vector3) the second control point
  4047. * @param v3 (Vector3) the end point of the Cubic Bezier
  4048. * @param nbPoints (integer) the wanted number of points in the curve
  4049. * @returns the created Curve3
  4050. */
  4051. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4052. /**
  4053. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4054. * @param p1 (Vector3) the origin point of the Hermite Spline
  4055. * @param t1 (Vector3) the tangent vector at the origin point
  4056. * @param p2 (Vector3) the end point of the Hermite Spline
  4057. * @param t2 (Vector3) the tangent vector at the end point
  4058. * @param nbPoints (integer) the wanted number of points in the curve
  4059. * @returns the created Curve3
  4060. */
  4061. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4062. /**
  4063. * Returns a Curve3 object along a CatmullRom Spline curve :
  4064. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4065. * @param nbPoints (integer) the wanted number of points between each curve control points
  4066. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4067. * @returns the created Curve3
  4068. */
  4069. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4070. /**
  4071. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4072. * A Curve3 is designed from a series of successive Vector3.
  4073. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4074. * @param points points which make up the curve
  4075. */
  4076. constructor(points: Vector3[]);
  4077. /**
  4078. * @returns the Curve3 stored array of successive Vector3
  4079. */
  4080. getPoints(): Vector3[];
  4081. /**
  4082. * @returns the computed length (float) of the curve.
  4083. */
  4084. length(): number;
  4085. /**
  4086. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4087. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4088. * curveA and curveB keep unchanged.
  4089. * @param curve the curve to continue from this curve
  4090. * @returns the newly constructed curve
  4091. */
  4092. continue(curve: DeepImmutable<Curve3>): Curve3;
  4093. private _computeLength;
  4094. }
  4095. /**
  4096. * Contains position and normal vectors for a vertex
  4097. */
  4098. export class PositionNormalVertex {
  4099. /** the position of the vertex (defaut: 0,0,0) */
  4100. position: Vector3;
  4101. /** the normal of the vertex (defaut: 0,1,0) */
  4102. normal: Vector3;
  4103. /**
  4104. * Creates a PositionNormalVertex
  4105. * @param position the position of the vertex (defaut: 0,0,0)
  4106. * @param normal the normal of the vertex (defaut: 0,1,0)
  4107. */
  4108. constructor(
  4109. /** the position of the vertex (defaut: 0,0,0) */
  4110. position?: Vector3,
  4111. /** the normal of the vertex (defaut: 0,1,0) */
  4112. normal?: Vector3);
  4113. /**
  4114. * Clones the PositionNormalVertex
  4115. * @returns the cloned PositionNormalVertex
  4116. */
  4117. clone(): PositionNormalVertex;
  4118. }
  4119. /**
  4120. * Contains position, normal and uv vectors for a vertex
  4121. */
  4122. export class PositionNormalTextureVertex {
  4123. /** the position of the vertex (defaut: 0,0,0) */
  4124. position: Vector3;
  4125. /** the normal of the vertex (defaut: 0,1,0) */
  4126. normal: Vector3;
  4127. /** the uv of the vertex (default: 0,0) */
  4128. uv: Vector2;
  4129. /**
  4130. * Creates a PositionNormalTextureVertex
  4131. * @param position the position of the vertex (defaut: 0,0,0)
  4132. * @param normal the normal of the vertex (defaut: 0,1,0)
  4133. * @param uv the uv of the vertex (default: 0,0)
  4134. */
  4135. constructor(
  4136. /** the position of the vertex (defaut: 0,0,0) */
  4137. position?: Vector3,
  4138. /** the normal of the vertex (defaut: 0,1,0) */
  4139. normal?: Vector3,
  4140. /** the uv of the vertex (default: 0,0) */
  4141. uv?: Vector2);
  4142. /**
  4143. * Clones the PositionNormalTextureVertex
  4144. * @returns the cloned PositionNormalTextureVertex
  4145. */
  4146. clone(): PositionNormalTextureVertex;
  4147. }
  4148. /**
  4149. * @hidden
  4150. */
  4151. export class Tmp {
  4152. static Color3: Color3[];
  4153. static Color4: Color4[];
  4154. static Vector2: Vector2[];
  4155. static Vector3: Vector3[];
  4156. static Vector4: Vector4[];
  4157. static Quaternion: Quaternion[];
  4158. static Matrix: Matrix[];
  4159. }
  4160. }
  4161. declare module BABYLON {
  4162. /**
  4163. * Class used to enable access to offline support
  4164. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4165. */
  4166. export interface IOfflineProvider {
  4167. /**
  4168. * Gets a boolean indicating if scene must be saved in the database
  4169. */
  4170. enableSceneOffline: boolean;
  4171. /**
  4172. * Gets a boolean indicating if textures must be saved in the database
  4173. */
  4174. enableTexturesOffline: boolean;
  4175. /**
  4176. * Open the offline support and make it available
  4177. * @param successCallback defines the callback to call on success
  4178. * @param errorCallback defines the callback to call on error
  4179. */
  4180. open(successCallback: () => void, errorCallback: () => void): void;
  4181. /**
  4182. * Loads an image from the offline support
  4183. * @param url defines the url to load from
  4184. * @param image defines the target DOM image
  4185. */
  4186. loadImage(url: string, image: HTMLImageElement): void;
  4187. /**
  4188. * Loads a file from offline support
  4189. * @param url defines the URL to load from
  4190. * @param sceneLoaded defines a callback to call on success
  4191. * @param progressCallBack defines a callback to call when progress changed
  4192. * @param errorCallback defines a callback to call on error
  4193. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4194. */
  4195. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4196. }
  4197. }
  4198. declare module BABYLON {
  4199. /**
  4200. * A class serves as a medium between the observable and its observers
  4201. */
  4202. export class EventState {
  4203. /**
  4204. * Create a new EventState
  4205. * @param mask defines the mask associated with this state
  4206. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4207. * @param target defines the original target of the state
  4208. * @param currentTarget defines the current target of the state
  4209. */
  4210. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4211. /**
  4212. * Initialize the current event state
  4213. * @param mask defines the mask associated with this state
  4214. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4215. * @param target defines the original target of the state
  4216. * @param currentTarget defines the current target of the state
  4217. * @returns the current event state
  4218. */
  4219. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4220. /**
  4221. * An Observer can set this property to true to prevent subsequent observers of being notified
  4222. */
  4223. skipNextObservers: boolean;
  4224. /**
  4225. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4226. */
  4227. mask: number;
  4228. /**
  4229. * The object that originally notified the event
  4230. */
  4231. target?: any;
  4232. /**
  4233. * The current object in the bubbling phase
  4234. */
  4235. currentTarget?: any;
  4236. /**
  4237. * This will be populated with the return value of the last function that was executed.
  4238. * If it is the first function in the callback chain it will be the event data.
  4239. */
  4240. lastReturnValue?: any;
  4241. }
  4242. /**
  4243. * Represent an Observer registered to a given Observable object.
  4244. */
  4245. export class Observer<T> {
  4246. /**
  4247. * Defines the callback to call when the observer is notified
  4248. */
  4249. callback: (eventData: T, eventState: EventState) => void;
  4250. /**
  4251. * Defines the mask of the observer (used to filter notifications)
  4252. */
  4253. mask: number;
  4254. /**
  4255. * Defines the current scope used to restore the JS context
  4256. */
  4257. scope: any;
  4258. /** @hidden */
  4259. _willBeUnregistered: boolean;
  4260. /**
  4261. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4262. */
  4263. unregisterOnNextCall: boolean;
  4264. /**
  4265. * Creates a new observer
  4266. * @param callback defines the callback to call when the observer is notified
  4267. * @param mask defines the mask of the observer (used to filter notifications)
  4268. * @param scope defines the current scope used to restore the JS context
  4269. */
  4270. constructor(
  4271. /**
  4272. * Defines the callback to call when the observer is notified
  4273. */
  4274. callback: (eventData: T, eventState: EventState) => void,
  4275. /**
  4276. * Defines the mask of the observer (used to filter notifications)
  4277. */
  4278. mask: number,
  4279. /**
  4280. * Defines the current scope used to restore the JS context
  4281. */
  4282. scope?: any);
  4283. }
  4284. /**
  4285. * Represent a list of observers registered to multiple Observables object.
  4286. */
  4287. export class MultiObserver<T> {
  4288. private _observers;
  4289. private _observables;
  4290. /**
  4291. * Release associated resources
  4292. */
  4293. dispose(): void;
  4294. /**
  4295. * Raise a callback when one of the observable will notify
  4296. * @param observables defines a list of observables to watch
  4297. * @param callback defines the callback to call on notification
  4298. * @param mask defines the mask used to filter notifications
  4299. * @param scope defines the current scope used to restore the JS context
  4300. * @returns the new MultiObserver
  4301. */
  4302. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4303. }
  4304. /**
  4305. * The Observable class is a simple implementation of the Observable pattern.
  4306. *
  4307. * 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.
  4308. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4309. * 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).
  4310. * 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.
  4311. */
  4312. export class Observable<T> {
  4313. private _observers;
  4314. private _eventState;
  4315. private _onObserverAdded;
  4316. /**
  4317. * Creates a new observable
  4318. * @param onObserverAdded defines a callback to call when a new observer is added
  4319. */
  4320. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4321. /**
  4322. * Create a new Observer with the specified callback
  4323. * @param callback the callback that will be executed for that Observer
  4324. * @param mask the mask used to filter observers
  4325. * @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.
  4326. * @param scope optional scope for the callback to be called from
  4327. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4328. * @returns the new observer created for the callback
  4329. */
  4330. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4331. /**
  4332. * Create a new Observer with the specified callback and unregisters after the next notification
  4333. * @param callback the callback that will be executed for that Observer
  4334. * @returns the new observer created for the callback
  4335. */
  4336. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4337. /**
  4338. * Remove an Observer from the Observable object
  4339. * @param observer the instance of the Observer to remove
  4340. * @returns false if it doesn't belong to this Observable
  4341. */
  4342. remove(observer: Nullable<Observer<T>>): boolean;
  4343. /**
  4344. * Remove a callback from the Observable object
  4345. * @param callback the callback to remove
  4346. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4347. * @returns false if it doesn't belong to this Observable
  4348. */
  4349. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4350. private _deferUnregister;
  4351. private _remove;
  4352. /**
  4353. * Notify all Observers by calling their respective callback with the given data
  4354. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4355. * @param eventData defines the data to send to all observers
  4356. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4357. * @param target defines the original target of the state
  4358. * @param currentTarget defines the current target of the state
  4359. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4360. */
  4361. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4362. /**
  4363. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4364. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4365. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4366. * and it is crucial that all callbacks will be executed.
  4367. * The order of the callbacks is kept, callbacks are not executed parallel.
  4368. *
  4369. * @param eventData The data to be sent to each callback
  4370. * @param mask is used to filter observers defaults to -1
  4371. * @param target defines the callback target (see EventState)
  4372. * @param currentTarget defines he current object in the bubbling phase
  4373. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4374. */
  4375. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4376. /**
  4377. * Notify a specific observer
  4378. * @param observer defines the observer to notify
  4379. * @param eventData defines the data to be sent to each callback
  4380. * @param mask is used to filter observers defaults to -1
  4381. */
  4382. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4383. /**
  4384. * Gets a boolean indicating if the observable has at least one observer
  4385. * @returns true is the Observable has at least one Observer registered
  4386. */
  4387. hasObservers(): boolean;
  4388. /**
  4389. * Clear the list of observers
  4390. */
  4391. clear(): void;
  4392. /**
  4393. * Clone the current observable
  4394. * @returns a new observable
  4395. */
  4396. clone(): Observable<T>;
  4397. /**
  4398. * Does this observable handles observer registered with a given mask
  4399. * @param mask defines the mask to be tested
  4400. * @return whether or not one observer registered with the given mask is handeled
  4401. **/
  4402. hasSpecificMask(mask?: number): boolean;
  4403. }
  4404. }
  4405. declare module BABYLON {
  4406. /**
  4407. * Class used to help managing file picking and drag'n'drop
  4408. * File Storage
  4409. */
  4410. export class FilesInputStore {
  4411. /**
  4412. * List of files ready to be loaded
  4413. */
  4414. static FilesToLoad: {
  4415. [key: string]: File;
  4416. };
  4417. }
  4418. }
  4419. declare module BABYLON {
  4420. /** Defines the cross module used constants to avoid circular dependncies */
  4421. export class Constants {
  4422. /** Defines that alpha blending is disabled */
  4423. static readonly ALPHA_DISABLE: number;
  4424. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4425. static readonly ALPHA_ADD: number;
  4426. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4427. static readonly ALPHA_COMBINE: number;
  4428. /** Defines that alpha blending to DEST - SRC * DEST */
  4429. static readonly ALPHA_SUBTRACT: number;
  4430. /** Defines that alpha blending to SRC * DEST */
  4431. static readonly ALPHA_MULTIPLY: number;
  4432. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4433. static readonly ALPHA_MAXIMIZED: number;
  4434. /** Defines that alpha blending to SRC + DEST */
  4435. static readonly ALPHA_ONEONE: number;
  4436. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4437. static readonly ALPHA_PREMULTIPLIED: number;
  4438. /**
  4439. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4440. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4441. */
  4442. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4443. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4444. static readonly ALPHA_INTERPOLATE: number;
  4445. /**
  4446. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4447. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4448. */
  4449. static readonly ALPHA_SCREENMODE: number;
  4450. /** Defines that the ressource is not delayed*/
  4451. static readonly DELAYLOADSTATE_NONE: number;
  4452. /** Defines that the ressource was successfully delay loaded */
  4453. static readonly DELAYLOADSTATE_LOADED: number;
  4454. /** Defines that the ressource is currently delay loading */
  4455. static readonly DELAYLOADSTATE_LOADING: number;
  4456. /** Defines that the ressource is delayed and has not started loading */
  4457. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4458. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4459. static readonly NEVER: number;
  4460. /** 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 */
  4461. static readonly ALWAYS: number;
  4462. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4463. static readonly LESS: number;
  4464. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4465. static readonly EQUAL: number;
  4466. /** 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 */
  4467. static readonly LEQUAL: number;
  4468. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4469. static readonly GREATER: number;
  4470. /** 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 */
  4471. static readonly GEQUAL: number;
  4472. /** 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 */
  4473. static readonly NOTEQUAL: number;
  4474. /** Passed to stencilOperation to specify that stencil value must be kept */
  4475. static readonly KEEP: number;
  4476. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4477. static readonly REPLACE: number;
  4478. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4479. static readonly INCR: number;
  4480. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4481. static readonly DECR: number;
  4482. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4483. static readonly INVERT: number;
  4484. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4485. static readonly INCR_WRAP: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4487. static readonly DECR_WRAP: number;
  4488. /** Texture is not repeating outside of 0..1 UVs */
  4489. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4490. /** Texture is repeating outside of 0..1 UVs */
  4491. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4492. /** Texture is repeating and mirrored */
  4493. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4494. /** ALPHA */
  4495. static readonly TEXTUREFORMAT_ALPHA: number;
  4496. /** LUMINANCE */
  4497. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4498. /** LUMINANCE_ALPHA */
  4499. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4500. /** RGB */
  4501. static readonly TEXTUREFORMAT_RGB: number;
  4502. /** RGBA */
  4503. static readonly TEXTUREFORMAT_RGBA: number;
  4504. /** RED */
  4505. static readonly TEXTUREFORMAT_RED: number;
  4506. /** RED (2nd reference) */
  4507. static readonly TEXTUREFORMAT_R: number;
  4508. /** RG */
  4509. static readonly TEXTUREFORMAT_RG: number;
  4510. /** RED_INTEGER */
  4511. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4512. /** RED_INTEGER (2nd reference) */
  4513. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4514. /** RG_INTEGER */
  4515. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4516. /** RGB_INTEGER */
  4517. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4518. /** RGBA_INTEGER */
  4519. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4520. /** UNSIGNED_BYTE */
  4521. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4522. /** UNSIGNED_BYTE (2nd reference) */
  4523. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4524. /** FLOAT */
  4525. static readonly TEXTURETYPE_FLOAT: number;
  4526. /** HALF_FLOAT */
  4527. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4528. /** BYTE */
  4529. static readonly TEXTURETYPE_BYTE: number;
  4530. /** SHORT */
  4531. static readonly TEXTURETYPE_SHORT: number;
  4532. /** UNSIGNED_SHORT */
  4533. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4534. /** INT */
  4535. static readonly TEXTURETYPE_INT: number;
  4536. /** UNSIGNED_INT */
  4537. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4538. /** UNSIGNED_SHORT_4_4_4_4 */
  4539. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4540. /** UNSIGNED_SHORT_5_5_5_1 */
  4541. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4542. /** UNSIGNED_SHORT_5_6_5 */
  4543. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4544. /** UNSIGNED_INT_2_10_10_10_REV */
  4545. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4546. /** UNSIGNED_INT_24_8 */
  4547. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4548. /** UNSIGNED_INT_10F_11F_11F_REV */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4550. /** UNSIGNED_INT_5_9_9_9_REV */
  4551. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4552. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4553. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4554. /** nearest is mag = nearest and min = nearest and mip = linear */
  4555. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4556. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4557. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4558. /** Trilinear is mag = linear and min = linear and mip = linear */
  4559. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4560. /** nearest is mag = nearest and min = nearest and mip = linear */
  4561. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4562. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4563. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4564. /** Trilinear is mag = linear and min = linear and mip = linear */
  4565. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4566. /** mag = nearest and min = nearest and mip = nearest */
  4567. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4568. /** mag = nearest and min = linear and mip = nearest */
  4569. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4570. /** mag = nearest and min = linear and mip = linear */
  4571. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4572. /** mag = nearest and min = linear and mip = none */
  4573. static readonly TEXTURE_NEAREST_LINEAR: number;
  4574. /** mag = nearest and min = nearest and mip = none */
  4575. static readonly TEXTURE_NEAREST_NEAREST: number;
  4576. /** mag = linear and min = nearest and mip = nearest */
  4577. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4578. /** mag = linear and min = nearest and mip = linear */
  4579. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4580. /** mag = linear and min = linear and mip = none */
  4581. static readonly TEXTURE_LINEAR_LINEAR: number;
  4582. /** mag = linear and min = nearest and mip = none */
  4583. static readonly TEXTURE_LINEAR_NEAREST: number;
  4584. /** Explicit coordinates mode */
  4585. static readonly TEXTURE_EXPLICIT_MODE: number;
  4586. /** Spherical coordinates mode */
  4587. static readonly TEXTURE_SPHERICAL_MODE: number;
  4588. /** Planar coordinates mode */
  4589. static readonly TEXTURE_PLANAR_MODE: number;
  4590. /** Cubic coordinates mode */
  4591. static readonly TEXTURE_CUBIC_MODE: number;
  4592. /** Projection coordinates mode */
  4593. static readonly TEXTURE_PROJECTION_MODE: number;
  4594. /** Skybox coordinates mode */
  4595. static readonly TEXTURE_SKYBOX_MODE: number;
  4596. /** Inverse Cubic coordinates mode */
  4597. static readonly TEXTURE_INVCUBIC_MODE: number;
  4598. /** Equirectangular coordinates mode */
  4599. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4600. /** Equirectangular Fixed coordinates mode */
  4601. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4602. /** Equirectangular Fixed Mirrored coordinates mode */
  4603. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4604. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4605. static readonly SCALEMODE_FLOOR: number;
  4606. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4607. static readonly SCALEMODE_NEAREST: number;
  4608. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4609. static readonly SCALEMODE_CEILING: number;
  4610. /**
  4611. * The dirty texture flag value
  4612. */
  4613. static readonly MATERIAL_TextureDirtyFlag: number;
  4614. /**
  4615. * The dirty light flag value
  4616. */
  4617. static readonly MATERIAL_LightDirtyFlag: number;
  4618. /**
  4619. * The dirty fresnel flag value
  4620. */
  4621. static readonly MATERIAL_FresnelDirtyFlag: number;
  4622. /**
  4623. * The dirty attribute flag value
  4624. */
  4625. static readonly MATERIAL_AttributesDirtyFlag: number;
  4626. /**
  4627. * The dirty misc flag value
  4628. */
  4629. static readonly MATERIAL_MiscDirtyFlag: number;
  4630. /**
  4631. * The all dirty flag value
  4632. */
  4633. static readonly MATERIAL_AllDirtyFlag: number;
  4634. /**
  4635. * Returns the triangle fill mode
  4636. */
  4637. static readonly MATERIAL_TriangleFillMode: number;
  4638. /**
  4639. * Returns the wireframe mode
  4640. */
  4641. static readonly MATERIAL_WireFrameFillMode: number;
  4642. /**
  4643. * Returns the point fill mode
  4644. */
  4645. static readonly MATERIAL_PointFillMode: number;
  4646. /**
  4647. * Returns the point list draw mode
  4648. */
  4649. static readonly MATERIAL_PointListDrawMode: number;
  4650. /**
  4651. * Returns the line list draw mode
  4652. */
  4653. static readonly MATERIAL_LineListDrawMode: number;
  4654. /**
  4655. * Returns the line loop draw mode
  4656. */
  4657. static readonly MATERIAL_LineLoopDrawMode: number;
  4658. /**
  4659. * Returns the line strip draw mode
  4660. */
  4661. static readonly MATERIAL_LineStripDrawMode: number;
  4662. /**
  4663. * Returns the triangle strip draw mode
  4664. */
  4665. static readonly MATERIAL_TriangleStripDrawMode: number;
  4666. /**
  4667. * Returns the triangle fan draw mode
  4668. */
  4669. static readonly MATERIAL_TriangleFanDrawMode: number;
  4670. /**
  4671. * Stores the clock-wise side orientation
  4672. */
  4673. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4674. /**
  4675. * Stores the counter clock-wise side orientation
  4676. */
  4677. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4678. /**
  4679. * Nothing
  4680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4681. */
  4682. static readonly ACTION_NothingTrigger: number;
  4683. /**
  4684. * On pick
  4685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4686. */
  4687. static readonly ACTION_OnPickTrigger: number;
  4688. /**
  4689. * On left pick
  4690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4691. */
  4692. static readonly ACTION_OnLeftPickTrigger: number;
  4693. /**
  4694. * On right pick
  4695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4696. */
  4697. static readonly ACTION_OnRightPickTrigger: number;
  4698. /**
  4699. * On center pick
  4700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4701. */
  4702. static readonly ACTION_OnCenterPickTrigger: number;
  4703. /**
  4704. * On pick down
  4705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4706. */
  4707. static readonly ACTION_OnPickDownTrigger: number;
  4708. /**
  4709. * On double pick
  4710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4711. */
  4712. static readonly ACTION_OnDoublePickTrigger: number;
  4713. /**
  4714. * On pick up
  4715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4716. */
  4717. static readonly ACTION_OnPickUpTrigger: number;
  4718. /**
  4719. * On pick out.
  4720. * This trigger will only be raised if you also declared a OnPickDown
  4721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4722. */
  4723. static readonly ACTION_OnPickOutTrigger: number;
  4724. /**
  4725. * On long press
  4726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4727. */
  4728. static readonly ACTION_OnLongPressTrigger: number;
  4729. /**
  4730. * On pointer over
  4731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4732. */
  4733. static readonly ACTION_OnPointerOverTrigger: number;
  4734. /**
  4735. * On pointer out
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_OnPointerOutTrigger: number;
  4739. /**
  4740. * On every frame
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnEveryFrameTrigger: number;
  4744. /**
  4745. * On intersection enter
  4746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4747. */
  4748. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4749. /**
  4750. * On intersection exit
  4751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4752. */
  4753. static readonly ACTION_OnIntersectionExitTrigger: number;
  4754. /**
  4755. * On key down
  4756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4757. */
  4758. static readonly ACTION_OnKeyDownTrigger: number;
  4759. /**
  4760. * On key up
  4761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4762. */
  4763. static readonly ACTION_OnKeyUpTrigger: number;
  4764. /**
  4765. * Billboard mode will only apply to Y axis
  4766. */
  4767. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4768. /**
  4769. * Billboard mode will apply to all axes
  4770. */
  4771. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4772. /**
  4773. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4774. */
  4775. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4776. /**
  4777. * Gets or sets base Assets URL
  4778. */
  4779. static readonly PARTICLES_BaseAssetsUrl: string;
  4780. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4781. * Test order :
  4782. * Is the bounding sphere outside the frustum ?
  4783. * If not, are the bounding box vertices outside the frustum ?
  4784. * It not, then the cullable object is in the frustum.
  4785. */
  4786. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4787. /** Culling strategy : Bounding Sphere Only.
  4788. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4789. * It's also less accurate than the standard because some not visible objects can still be selected.
  4790. * Test : is the bounding sphere outside the frustum ?
  4791. * If not, then the cullable object is in the frustum.
  4792. */
  4793. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4794. /** Culling strategy : Optimistic Inclusion.
  4795. * This in an inclusion test first, then the standard exclusion test.
  4796. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4797. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4798. * Anyway, it's as accurate as the standard strategy.
  4799. * Test :
  4800. * Is the cullable object bounding sphere center in the frustum ?
  4801. * If not, apply the default culling strategy.
  4802. */
  4803. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4804. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4805. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4806. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4807. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4808. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4809. * Test :
  4810. * Is the cullable object bounding sphere center in the frustum ?
  4811. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4812. */
  4813. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4814. /**
  4815. * No logging while loading
  4816. */
  4817. static readonly SCENELOADER_NO_LOGGING: number;
  4818. /**
  4819. * Minimal logging while loading
  4820. */
  4821. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4822. /**
  4823. * Summary logging while loading
  4824. */
  4825. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4826. /**
  4827. * Detailled logging while loading
  4828. */
  4829. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4830. }
  4831. }
  4832. declare module BABYLON {
  4833. /**
  4834. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4835. * Babylon.js
  4836. */
  4837. export class DomManagement {
  4838. /**
  4839. * Checks if the window object exists
  4840. * @returns true if the window object exists
  4841. */
  4842. static IsWindowObjectExist(): boolean;
  4843. /**
  4844. * Extracts text content from a DOM element hierarchy
  4845. * @param element defines the root element
  4846. * @returns a string
  4847. */
  4848. static GetDOMTextContent(element: HTMLElement): string;
  4849. }
  4850. }
  4851. declare module BABYLON {
  4852. /**
  4853. * Logger used througouht the application to allow configuration of
  4854. * the log level required for the messages.
  4855. */
  4856. export class Logger {
  4857. /**
  4858. * No log
  4859. */
  4860. static readonly NoneLogLevel: number;
  4861. /**
  4862. * Only message logs
  4863. */
  4864. static readonly MessageLogLevel: number;
  4865. /**
  4866. * Only warning logs
  4867. */
  4868. static readonly WarningLogLevel: number;
  4869. /**
  4870. * Only error logs
  4871. */
  4872. static readonly ErrorLogLevel: number;
  4873. /**
  4874. * All logs
  4875. */
  4876. static readonly AllLogLevel: number;
  4877. private static _LogCache;
  4878. /**
  4879. * Gets a value indicating the number of loading errors
  4880. * @ignorenaming
  4881. */
  4882. static errorsCount: number;
  4883. /**
  4884. * Callback called when a new log is added
  4885. */
  4886. static OnNewCacheEntry: (entry: string) => void;
  4887. private static _AddLogEntry;
  4888. private static _FormatMessage;
  4889. private static _LogDisabled;
  4890. private static _LogEnabled;
  4891. private static _WarnDisabled;
  4892. private static _WarnEnabled;
  4893. private static _ErrorDisabled;
  4894. private static _ErrorEnabled;
  4895. /**
  4896. * Log a message to the console
  4897. */
  4898. static Log: (message: string) => void;
  4899. /**
  4900. * Write a warning message to the console
  4901. */
  4902. static Warn: (message: string) => void;
  4903. /**
  4904. * Write an error message to the console
  4905. */
  4906. static Error: (message: string) => void;
  4907. /**
  4908. * Gets current log cache (list of logs)
  4909. */
  4910. static readonly LogCache: string;
  4911. /**
  4912. * Clears the log cache
  4913. */
  4914. static ClearLogCache(): void;
  4915. /**
  4916. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4917. */
  4918. static LogLevels: number;
  4919. }
  4920. }
  4921. declare module BABYLON {
  4922. /** @hidden */
  4923. export class _TypeStore {
  4924. /** @hidden */
  4925. static RegisteredTypes: {
  4926. [key: string]: Object;
  4927. };
  4928. /** @hidden */
  4929. static GetClass(fqdn: string): any;
  4930. }
  4931. }
  4932. declare module BABYLON {
  4933. /**
  4934. * Class containing a set of static utilities functions for deep copy.
  4935. */
  4936. export class DeepCopier {
  4937. /**
  4938. * Tries to copy an object by duplicating every property
  4939. * @param source defines the source object
  4940. * @param destination defines the target object
  4941. * @param doNotCopyList defines a list of properties to avoid
  4942. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4943. */
  4944. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4945. }
  4946. }
  4947. declare module BABYLON {
  4948. /**
  4949. * Class containing a set of static utilities functions for precision date
  4950. */
  4951. export class PrecisionDate {
  4952. /**
  4953. * Gets either window.performance.now() if supported or Date.now() else
  4954. */
  4955. static readonly Now: number;
  4956. }
  4957. }
  4958. declare module BABYLON {
  4959. /**
  4960. * Class used to evalaute queries containing `and` and `or` operators
  4961. */
  4962. export class AndOrNotEvaluator {
  4963. /**
  4964. * Evaluate a query
  4965. * @param query defines the query to evaluate
  4966. * @param evaluateCallback defines the callback used to filter result
  4967. * @returns true if the query matches
  4968. */
  4969. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4970. private static _HandleParenthesisContent;
  4971. private static _SimplifyNegation;
  4972. }
  4973. }
  4974. declare module BABYLON {
  4975. /**
  4976. * Class used to store custom tags
  4977. */
  4978. export class Tags {
  4979. /**
  4980. * Adds support for tags on the given object
  4981. * @param obj defines the object to use
  4982. */
  4983. static EnableFor(obj: any): void;
  4984. /**
  4985. * Removes tags support
  4986. * @param obj defines the object to use
  4987. */
  4988. static DisableFor(obj: any): void;
  4989. /**
  4990. * Gets a boolean indicating if the given object has tags
  4991. * @param obj defines the object to use
  4992. * @returns a boolean
  4993. */
  4994. static HasTags(obj: any): boolean;
  4995. /**
  4996. * Gets the tags available on a given object
  4997. * @param obj defines the object to use
  4998. * @param asString defines if the tags must be returned as a string instead of an array of strings
  4999. * @returns the tags
  5000. */
  5001. static GetTags(obj: any, asString?: boolean): any;
  5002. /**
  5003. * Adds tags to an object
  5004. * @param obj defines the object to use
  5005. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5006. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5007. */
  5008. static AddTagsTo(obj: any, tagsString: string): void;
  5009. /**
  5010. * @hidden
  5011. */
  5012. static _AddTagTo(obj: any, tag: string): void;
  5013. /**
  5014. * Removes specific tags from a specific object
  5015. * @param obj defines the object to use
  5016. * @param tagsString defines the tags to remove
  5017. */
  5018. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5019. /**
  5020. * @hidden
  5021. */
  5022. static _RemoveTagFrom(obj: any, tag: string): void;
  5023. /**
  5024. * Defines if tags hosted on an object match a given query
  5025. * @param obj defines the object to use
  5026. * @param tagsQuery defines the tag query
  5027. * @returns a boolean
  5028. */
  5029. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5030. }
  5031. }
  5032. declare module BABYLON {
  5033. /**
  5034. * Manages the defines for the Material
  5035. */
  5036. export class MaterialDefines {
  5037. private _keys;
  5038. private _isDirty;
  5039. /** @hidden */
  5040. _renderId: number;
  5041. /** @hidden */
  5042. _areLightsDirty: boolean;
  5043. /** @hidden */
  5044. _areAttributesDirty: boolean;
  5045. /** @hidden */
  5046. _areTexturesDirty: boolean;
  5047. /** @hidden */
  5048. _areFresnelDirty: boolean;
  5049. /** @hidden */
  5050. _areMiscDirty: boolean;
  5051. /** @hidden */
  5052. _areImageProcessingDirty: boolean;
  5053. /** @hidden */
  5054. _normals: boolean;
  5055. /** @hidden */
  5056. _uvs: boolean;
  5057. /** @hidden */
  5058. _needNormals: boolean;
  5059. /** @hidden */
  5060. _needUVs: boolean;
  5061. /**
  5062. * Specifies if the material needs to be re-calculated
  5063. */
  5064. readonly isDirty: boolean;
  5065. /**
  5066. * Marks the material to indicate that it has been re-calculated
  5067. */
  5068. markAsProcessed(): void;
  5069. /**
  5070. * Marks the material to indicate that it needs to be re-calculated
  5071. */
  5072. markAsUnprocessed(): void;
  5073. /**
  5074. * Marks the material to indicate all of its defines need to be re-calculated
  5075. */
  5076. markAllAsDirty(): void;
  5077. /**
  5078. * Marks the material to indicate that image processing needs to be re-calculated
  5079. */
  5080. markAsImageProcessingDirty(): void;
  5081. /**
  5082. * Marks the material to indicate the lights need to be re-calculated
  5083. */
  5084. markAsLightDirty(): void;
  5085. /**
  5086. * Marks the attribute state as changed
  5087. */
  5088. markAsAttributesDirty(): void;
  5089. /**
  5090. * Marks the texture state as changed
  5091. */
  5092. markAsTexturesDirty(): void;
  5093. /**
  5094. * Marks the fresnel state as changed
  5095. */
  5096. markAsFresnelDirty(): void;
  5097. /**
  5098. * Marks the misc state as changed
  5099. */
  5100. markAsMiscDirty(): void;
  5101. /**
  5102. * Rebuilds the material defines
  5103. */
  5104. rebuild(): void;
  5105. /**
  5106. * Specifies if two material defines are equal
  5107. * @param other - A material define instance to compare to
  5108. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5109. */
  5110. isEqual(other: MaterialDefines): boolean;
  5111. /**
  5112. * Clones this instance's defines to another instance
  5113. * @param other - material defines to clone values to
  5114. */
  5115. cloneTo(other: MaterialDefines): void;
  5116. /**
  5117. * Resets the material define values
  5118. */
  5119. reset(): void;
  5120. /**
  5121. * Converts the material define values to a string
  5122. * @returns - String of material define information
  5123. */
  5124. toString(): string;
  5125. }
  5126. }
  5127. declare module BABYLON {
  5128. /**
  5129. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5130. */
  5131. export class PerformanceMonitor {
  5132. private _enabled;
  5133. private _rollingFrameTime;
  5134. private _lastFrameTimeMs;
  5135. /**
  5136. * constructor
  5137. * @param frameSampleSize The number of samples required to saturate the sliding window
  5138. */
  5139. constructor(frameSampleSize?: number);
  5140. /**
  5141. * Samples current frame
  5142. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5143. */
  5144. sampleFrame(timeMs?: number): void;
  5145. /**
  5146. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5147. */
  5148. readonly averageFrameTime: number;
  5149. /**
  5150. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5151. */
  5152. readonly averageFrameTimeVariance: number;
  5153. /**
  5154. * Returns the frame time of the most recent frame
  5155. */
  5156. readonly instantaneousFrameTime: number;
  5157. /**
  5158. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5159. */
  5160. readonly averageFPS: number;
  5161. /**
  5162. * Returns the average framerate in frames per second using the most recent frame time
  5163. */
  5164. readonly instantaneousFPS: number;
  5165. /**
  5166. * Returns true if enough samples have been taken to completely fill the sliding window
  5167. */
  5168. readonly isSaturated: boolean;
  5169. /**
  5170. * Enables contributions to the sliding window sample set
  5171. */
  5172. enable(): void;
  5173. /**
  5174. * Disables contributions to the sliding window sample set
  5175. * Samples will not be interpolated over the disabled period
  5176. */
  5177. disable(): void;
  5178. /**
  5179. * Returns true if sampling is enabled
  5180. */
  5181. readonly isEnabled: boolean;
  5182. /**
  5183. * Resets performance monitor
  5184. */
  5185. reset(): void;
  5186. }
  5187. /**
  5188. * RollingAverage
  5189. *
  5190. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5191. */
  5192. export class RollingAverage {
  5193. /**
  5194. * Current average
  5195. */
  5196. average: number;
  5197. /**
  5198. * Current variance
  5199. */
  5200. variance: number;
  5201. protected _samples: Array<number>;
  5202. protected _sampleCount: number;
  5203. protected _pos: number;
  5204. protected _m2: number;
  5205. /**
  5206. * constructor
  5207. * @param length The number of samples required to saturate the sliding window
  5208. */
  5209. constructor(length: number);
  5210. /**
  5211. * Adds a sample to the sample set
  5212. * @param v The sample value
  5213. */
  5214. add(v: number): void;
  5215. /**
  5216. * Returns previously added values or null if outside of history or outside the sliding window domain
  5217. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5218. * @return Value previously recorded with add() or null if outside of range
  5219. */
  5220. history(i: number): number;
  5221. /**
  5222. * Returns true if enough samples have been taken to completely fill the sliding window
  5223. * @return true if sample-set saturated
  5224. */
  5225. isSaturated(): boolean;
  5226. /**
  5227. * Resets the rolling average (equivalent to 0 samples taken so far)
  5228. */
  5229. reset(): void;
  5230. /**
  5231. * Wraps a value around the sample range boundaries
  5232. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5233. * @return Wrapped position in sample range
  5234. */
  5235. protected _wrapPosition(i: number): number;
  5236. }
  5237. }
  5238. declare module BABYLON {
  5239. /**
  5240. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5241. * The underlying implementation relies on an associative array to ensure the best performances.
  5242. * The value can be anything including 'null' but except 'undefined'
  5243. */
  5244. export class StringDictionary<T> {
  5245. /**
  5246. * This will clear this dictionary and copy the content from the 'source' one.
  5247. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5248. * @param source the dictionary to take the content from and copy to this dictionary
  5249. */
  5250. copyFrom(source: StringDictionary<T>): void;
  5251. /**
  5252. * Get a value based from its key
  5253. * @param key the given key to get the matching value from
  5254. * @return the value if found, otherwise undefined is returned
  5255. */
  5256. get(key: string): T | undefined;
  5257. /**
  5258. * Get a value from its key or add it if it doesn't exist.
  5259. * This method will ensure you that a given key/data will be present in the dictionary.
  5260. * @param key the given key to get the matching value from
  5261. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5262. * The factory will only be invoked if there's no data for the given key.
  5263. * @return the value corresponding to the key.
  5264. */
  5265. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5266. /**
  5267. * Get a value from its key if present in the dictionary otherwise add it
  5268. * @param key the key to get the value from
  5269. * @param val if there's no such key/value pair in the dictionary add it with this value
  5270. * @return the value corresponding to the key
  5271. */
  5272. getOrAdd(key: string, val: T): T;
  5273. /**
  5274. * Check if there's a given key in the dictionary
  5275. * @param key the key to check for
  5276. * @return true if the key is present, false otherwise
  5277. */
  5278. contains(key: string): boolean;
  5279. /**
  5280. * Add a new key and its corresponding value
  5281. * @param key the key to add
  5282. * @param value the value corresponding to the key
  5283. * @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
  5284. */
  5285. add(key: string, value: T): boolean;
  5286. /**
  5287. * Update a specific value associated to a key
  5288. * @param key defines the key to use
  5289. * @param value defines the value to store
  5290. * @returns true if the value was updated (or false if the key was not found)
  5291. */
  5292. set(key: string, value: T): boolean;
  5293. /**
  5294. * Get the element of the given key and remove it from the dictionary
  5295. * @param key defines the key to search
  5296. * @returns the value associated with the key or null if not found
  5297. */
  5298. getAndRemove(key: string): Nullable<T>;
  5299. /**
  5300. * Remove a key/value from the dictionary.
  5301. * @param key the key to remove
  5302. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5303. */
  5304. remove(key: string): boolean;
  5305. /**
  5306. * Clear the whole content of the dictionary
  5307. */
  5308. clear(): void;
  5309. /**
  5310. * Gets the current count
  5311. */
  5312. readonly count: number;
  5313. /**
  5314. * Execute a callback on each key/val of the dictionary.
  5315. * Note that you can remove any element in this dictionary in the callback implementation
  5316. * @param callback the callback to execute on a given key/value pair
  5317. */
  5318. forEach(callback: (key: string, val: T) => void): void;
  5319. /**
  5320. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5321. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5322. * Note that you can remove any element in this dictionary in the callback implementation
  5323. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5324. * @returns the first item
  5325. */
  5326. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5327. private _count;
  5328. private _data;
  5329. }
  5330. }
  5331. declare module BABYLON {
  5332. /**
  5333. * Helper class that provides a small promise polyfill
  5334. */
  5335. export class PromisePolyfill {
  5336. /**
  5337. * Static function used to check if the polyfill is required
  5338. * If this is the case then the function will inject the polyfill to window.Promise
  5339. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5340. */
  5341. static Apply(force?: boolean): void;
  5342. }
  5343. }
  5344. declare module BABYLON {
  5345. /**
  5346. * Class used to store data that will be store in GPU memory
  5347. */
  5348. export class Buffer {
  5349. private _engine;
  5350. private _buffer;
  5351. /** @hidden */
  5352. _data: Nullable<DataArray>;
  5353. private _updatable;
  5354. private _instanced;
  5355. /**
  5356. * Gets the byte stride.
  5357. */
  5358. readonly byteStride: number;
  5359. /**
  5360. * Constructor
  5361. * @param engine the engine
  5362. * @param data the data to use for this buffer
  5363. * @param updatable whether the data is updatable
  5364. * @param stride the stride (optional)
  5365. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5366. * @param instanced whether the buffer is instanced (optional)
  5367. * @param useBytes set to true if the stride in in bytes (optional)
  5368. */
  5369. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5370. /**
  5371. * Create a new VertexBuffer based on the current buffer
  5372. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5373. * @param offset defines offset in the buffer (0 by default)
  5374. * @param size defines the size in floats of attributes (position is 3 for instance)
  5375. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5376. * @param instanced defines if the vertex buffer contains indexed data
  5377. * @param useBytes defines if the offset and stride are in bytes
  5378. * @returns the new vertex buffer
  5379. */
  5380. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5381. /**
  5382. * Gets a boolean indicating if the Buffer is updatable?
  5383. * @returns true if the buffer is updatable
  5384. */
  5385. isUpdatable(): boolean;
  5386. /**
  5387. * Gets current buffer's data
  5388. * @returns a DataArray or null
  5389. */
  5390. getData(): Nullable<DataArray>;
  5391. /**
  5392. * Gets underlying native buffer
  5393. * @returns underlying native buffer
  5394. */
  5395. getBuffer(): Nullable<WebGLBuffer>;
  5396. /**
  5397. * Gets the stride in float32 units (i.e. byte stride / 4).
  5398. * May not be an integer if the byte stride is not divisible by 4.
  5399. * DEPRECATED. Use byteStride instead.
  5400. * @returns the stride in float32 units
  5401. */
  5402. getStrideSize(): number;
  5403. /**
  5404. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5405. * @param data defines the data to store
  5406. */
  5407. create(data?: Nullable<DataArray>): void;
  5408. /** @hidden */
  5409. _rebuild(): void;
  5410. /**
  5411. * Update current buffer data
  5412. * @param data defines the data to store
  5413. */
  5414. update(data: DataArray): void;
  5415. /**
  5416. * Updates the data directly.
  5417. * @param data the new data
  5418. * @param offset the new offset
  5419. * @param vertexCount the vertex count (optional)
  5420. * @param useBytes set to true if the offset is in bytes
  5421. */
  5422. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5423. /**
  5424. * Release all resources
  5425. */
  5426. dispose(): void;
  5427. }
  5428. /**
  5429. * Specialized buffer used to store vertex data
  5430. */
  5431. export class VertexBuffer {
  5432. /** @hidden */
  5433. _buffer: Buffer;
  5434. private _kind;
  5435. private _size;
  5436. private _ownsBuffer;
  5437. private _instanced;
  5438. private _instanceDivisor;
  5439. /**
  5440. * The byte type.
  5441. */
  5442. static readonly BYTE: number;
  5443. /**
  5444. * The unsigned byte type.
  5445. */
  5446. static readonly UNSIGNED_BYTE: number;
  5447. /**
  5448. * The short type.
  5449. */
  5450. static readonly SHORT: number;
  5451. /**
  5452. * The unsigned short type.
  5453. */
  5454. static readonly UNSIGNED_SHORT: number;
  5455. /**
  5456. * The integer type.
  5457. */
  5458. static readonly INT: number;
  5459. /**
  5460. * The unsigned integer type.
  5461. */
  5462. static readonly UNSIGNED_INT: number;
  5463. /**
  5464. * The float type.
  5465. */
  5466. static readonly FLOAT: number;
  5467. /**
  5468. * Gets or sets the instance divisor when in instanced mode
  5469. */
  5470. instanceDivisor: number;
  5471. /**
  5472. * Gets the byte stride.
  5473. */
  5474. readonly byteStride: number;
  5475. /**
  5476. * Gets the byte offset.
  5477. */
  5478. readonly byteOffset: number;
  5479. /**
  5480. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5481. */
  5482. readonly normalized: boolean;
  5483. /**
  5484. * Gets the data type of each component in the array.
  5485. */
  5486. readonly type: number;
  5487. /**
  5488. * Constructor
  5489. * @param engine the engine
  5490. * @param data the data to use for this vertex buffer
  5491. * @param kind the vertex buffer kind
  5492. * @param updatable whether the data is updatable
  5493. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5494. * @param stride the stride (optional)
  5495. * @param instanced whether the buffer is instanced (optional)
  5496. * @param offset the offset of the data (optional)
  5497. * @param size the number of components (optional)
  5498. * @param type the type of the component (optional)
  5499. * @param normalized whether the data contains normalized data (optional)
  5500. * @param useBytes set to true if stride and offset are in bytes (optional)
  5501. */
  5502. 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);
  5503. /** @hidden */
  5504. _rebuild(): void;
  5505. /**
  5506. * Returns the kind of the VertexBuffer (string)
  5507. * @returns a string
  5508. */
  5509. getKind(): string;
  5510. /**
  5511. * Gets a boolean indicating if the VertexBuffer is updatable?
  5512. * @returns true if the buffer is updatable
  5513. */
  5514. isUpdatable(): boolean;
  5515. /**
  5516. * Gets current buffer's data
  5517. * @returns a DataArray or null
  5518. */
  5519. getData(): Nullable<DataArray>;
  5520. /**
  5521. * Gets underlying native buffer
  5522. * @returns underlying native buffer
  5523. */
  5524. getBuffer(): Nullable<WebGLBuffer>;
  5525. /**
  5526. * Gets the stride in float32 units (i.e. byte stride / 4).
  5527. * May not be an integer if the byte stride is not divisible by 4.
  5528. * DEPRECATED. Use byteStride instead.
  5529. * @returns the stride in float32 units
  5530. */
  5531. getStrideSize(): number;
  5532. /**
  5533. * Returns the offset as a multiple of the type byte length.
  5534. * DEPRECATED. Use byteOffset instead.
  5535. * @returns the offset in bytes
  5536. */
  5537. getOffset(): number;
  5538. /**
  5539. * Returns the number of components per vertex attribute (integer)
  5540. * @returns the size in float
  5541. */
  5542. getSize(): number;
  5543. /**
  5544. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5545. * @returns true if this buffer is instanced
  5546. */
  5547. getIsInstanced(): boolean;
  5548. /**
  5549. * Returns the instancing divisor, zero for non-instanced (integer).
  5550. * @returns a number
  5551. */
  5552. getInstanceDivisor(): number;
  5553. /**
  5554. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5555. * @param data defines the data to store
  5556. */
  5557. create(data?: DataArray): void;
  5558. /**
  5559. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5560. * This function will create a new buffer if the current one is not updatable
  5561. * @param data defines the data to store
  5562. */
  5563. update(data: DataArray): void;
  5564. /**
  5565. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5566. * Returns the directly updated WebGLBuffer.
  5567. * @param data the new data
  5568. * @param offset the new offset
  5569. * @param useBytes set to true if the offset is in bytes
  5570. */
  5571. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5572. /**
  5573. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5574. */
  5575. dispose(): void;
  5576. /**
  5577. * Enumerates each value of this vertex buffer as numbers.
  5578. * @param count the number of values to enumerate
  5579. * @param callback the callback function called for each value
  5580. */
  5581. forEach(count: number, callback: (value: number, index: number) => void): void;
  5582. /**
  5583. * Positions
  5584. */
  5585. static readonly PositionKind: string;
  5586. /**
  5587. * Normals
  5588. */
  5589. static readonly NormalKind: string;
  5590. /**
  5591. * Tangents
  5592. */
  5593. static readonly TangentKind: string;
  5594. /**
  5595. * Texture coordinates
  5596. */
  5597. static readonly UVKind: string;
  5598. /**
  5599. * Texture coordinates 2
  5600. */
  5601. static readonly UV2Kind: string;
  5602. /**
  5603. * Texture coordinates 3
  5604. */
  5605. static readonly UV3Kind: string;
  5606. /**
  5607. * Texture coordinates 4
  5608. */
  5609. static readonly UV4Kind: string;
  5610. /**
  5611. * Texture coordinates 5
  5612. */
  5613. static readonly UV5Kind: string;
  5614. /**
  5615. * Texture coordinates 6
  5616. */
  5617. static readonly UV6Kind: string;
  5618. /**
  5619. * Colors
  5620. */
  5621. static readonly ColorKind: string;
  5622. /**
  5623. * Matrix indices (for bones)
  5624. */
  5625. static readonly MatricesIndicesKind: string;
  5626. /**
  5627. * Matrix weights (for bones)
  5628. */
  5629. static readonly MatricesWeightsKind: string;
  5630. /**
  5631. * Additional matrix indices (for bones)
  5632. */
  5633. static readonly MatricesIndicesExtraKind: string;
  5634. /**
  5635. * Additional matrix weights (for bones)
  5636. */
  5637. static readonly MatricesWeightsExtraKind: string;
  5638. /**
  5639. * Deduces the stride given a kind.
  5640. * @param kind The kind string to deduce
  5641. * @returns The deduced stride
  5642. */
  5643. static DeduceStride(kind: string): number;
  5644. /**
  5645. * Gets the byte length of the given type.
  5646. * @param type the type
  5647. * @returns the number of bytes
  5648. */
  5649. static GetTypeByteLength(type: number): number;
  5650. /**
  5651. * Enumerates each value of the given parameters as numbers.
  5652. * @param data the data to enumerate
  5653. * @param byteOffset the byte offset of the data
  5654. * @param byteStride the byte stride of the data
  5655. * @param componentCount the number of components per element
  5656. * @param componentType the type of the component
  5657. * @param count the total number of components
  5658. * @param normalized whether the data is normalized
  5659. * @param callback the callback function called for each value
  5660. */
  5661. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5662. private static _GetFloatValue;
  5663. }
  5664. }
  5665. declare module BABYLON {
  5666. /**
  5667. * Class representing spherical polynomial coefficients to the 3rd degree
  5668. */
  5669. export class SphericalPolynomial {
  5670. /**
  5671. * The x coefficients of the spherical polynomial
  5672. */
  5673. x: Vector3;
  5674. /**
  5675. * The y coefficients of the spherical polynomial
  5676. */
  5677. y: Vector3;
  5678. /**
  5679. * The z coefficients of the spherical polynomial
  5680. */
  5681. z: Vector3;
  5682. /**
  5683. * The xx coefficients of the spherical polynomial
  5684. */
  5685. xx: Vector3;
  5686. /**
  5687. * The yy coefficients of the spherical polynomial
  5688. */
  5689. yy: Vector3;
  5690. /**
  5691. * The zz coefficients of the spherical polynomial
  5692. */
  5693. zz: Vector3;
  5694. /**
  5695. * The xy coefficients of the spherical polynomial
  5696. */
  5697. xy: Vector3;
  5698. /**
  5699. * The yz coefficients of the spherical polynomial
  5700. */
  5701. yz: Vector3;
  5702. /**
  5703. * The zx coefficients of the spherical polynomial
  5704. */
  5705. zx: Vector3;
  5706. /**
  5707. * Adds an ambient color to the spherical polynomial
  5708. * @param color the color to add
  5709. */
  5710. addAmbient(color: Color3): void;
  5711. /**
  5712. * Scales the spherical polynomial by the given amount
  5713. * @param scale the amount to scale
  5714. */
  5715. scale(scale: number): void;
  5716. /**
  5717. * Gets the spherical polynomial from harmonics
  5718. * @param harmonics the spherical harmonics
  5719. * @returns the spherical polynomial
  5720. */
  5721. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5722. /**
  5723. * Constructs a spherical polynomial from an array.
  5724. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5725. * @returns the spherical polynomial
  5726. */
  5727. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5728. }
  5729. /**
  5730. * Class representing spherical harmonics coefficients to the 3rd degree
  5731. */
  5732. export class SphericalHarmonics {
  5733. /**
  5734. * The l0,0 coefficients of the spherical harmonics
  5735. */
  5736. l00: Vector3;
  5737. /**
  5738. * The l1,-1 coefficients of the spherical harmonics
  5739. */
  5740. l1_1: Vector3;
  5741. /**
  5742. * The l1,0 coefficients of the spherical harmonics
  5743. */
  5744. l10: Vector3;
  5745. /**
  5746. * The l1,1 coefficients of the spherical harmonics
  5747. */
  5748. l11: Vector3;
  5749. /**
  5750. * The l2,-2 coefficients of the spherical harmonics
  5751. */
  5752. l2_2: Vector3;
  5753. /**
  5754. * The l2,-1 coefficients of the spherical harmonics
  5755. */
  5756. l2_1: Vector3;
  5757. /**
  5758. * The l2,0 coefficients of the spherical harmonics
  5759. */
  5760. l20: Vector3;
  5761. /**
  5762. * The l2,1 coefficients of the spherical harmonics
  5763. */
  5764. l21: Vector3;
  5765. /**
  5766. * The l2,2 coefficients of the spherical harmonics
  5767. */
  5768. lL22: Vector3;
  5769. /**
  5770. * Adds a light to the spherical harmonics
  5771. * @param direction the direction of the light
  5772. * @param color the color of the light
  5773. * @param deltaSolidAngle the delta solid angle of the light
  5774. */
  5775. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5776. /**
  5777. * Scales the spherical harmonics by the given amount
  5778. * @param scale the amount to scale
  5779. */
  5780. scale(scale: number): void;
  5781. /**
  5782. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5783. *
  5784. * ```
  5785. * E_lm = A_l * L_lm
  5786. * ```
  5787. *
  5788. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5789. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5790. * the scaling factors are given in equation 9.
  5791. */
  5792. convertIncidentRadianceToIrradiance(): void;
  5793. /**
  5794. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5795. *
  5796. * ```
  5797. * L = (1/pi) * E * rho
  5798. * ```
  5799. *
  5800. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5801. */
  5802. convertIrradianceToLambertianRadiance(): void;
  5803. /**
  5804. * Gets the spherical harmonics from polynomial
  5805. * @param polynomial the spherical polynomial
  5806. * @returns the spherical harmonics
  5807. */
  5808. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5809. /**
  5810. * Constructs a spherical harmonics from an array.
  5811. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5812. * @returns the spherical harmonics
  5813. */
  5814. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5815. }
  5816. }
  5817. declare module BABYLON {
  5818. /**
  5819. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5820. */
  5821. export interface CubeMapInfo {
  5822. /**
  5823. * The pixel array for the front face.
  5824. * This is stored in format, left to right, up to down format.
  5825. */
  5826. front: Nullable<ArrayBufferView>;
  5827. /**
  5828. * The pixel array for the back face.
  5829. * This is stored in format, left to right, up to down format.
  5830. */
  5831. back: Nullable<ArrayBufferView>;
  5832. /**
  5833. * The pixel array for the left face.
  5834. * This is stored in format, left to right, up to down format.
  5835. */
  5836. left: Nullable<ArrayBufferView>;
  5837. /**
  5838. * The pixel array for the right face.
  5839. * This is stored in format, left to right, up to down format.
  5840. */
  5841. right: Nullable<ArrayBufferView>;
  5842. /**
  5843. * The pixel array for the up face.
  5844. * This is stored in format, left to right, up to down format.
  5845. */
  5846. up: Nullable<ArrayBufferView>;
  5847. /**
  5848. * The pixel array for the down face.
  5849. * This is stored in format, left to right, up to down format.
  5850. */
  5851. down: Nullable<ArrayBufferView>;
  5852. /**
  5853. * The size of the cubemap stored.
  5854. *
  5855. * Each faces will be size * size pixels.
  5856. */
  5857. size: number;
  5858. /**
  5859. * The format of the texture.
  5860. *
  5861. * RGBA, RGB.
  5862. */
  5863. format: number;
  5864. /**
  5865. * The type of the texture data.
  5866. *
  5867. * UNSIGNED_INT, FLOAT.
  5868. */
  5869. type: number;
  5870. /**
  5871. * Specifies whether the texture is in gamma space.
  5872. */
  5873. gammaSpace: boolean;
  5874. }
  5875. /**
  5876. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5877. */
  5878. export class PanoramaToCubeMapTools {
  5879. private static FACE_FRONT;
  5880. private static FACE_BACK;
  5881. private static FACE_RIGHT;
  5882. private static FACE_LEFT;
  5883. private static FACE_DOWN;
  5884. private static FACE_UP;
  5885. /**
  5886. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5887. *
  5888. * @param float32Array The source data.
  5889. * @param inputWidth The width of the input panorama.
  5890. * @param inputHeight The height of the input panorama.
  5891. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5892. * @return The cubemap data
  5893. */
  5894. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5895. private static CreateCubemapTexture;
  5896. private static CalcProjectionSpherical;
  5897. }
  5898. }
  5899. declare module BABYLON {
  5900. /**
  5901. * Helper class dealing with the extraction of spherical polynomial dataArray
  5902. * from a cube map.
  5903. */
  5904. export class CubeMapToSphericalPolynomialTools {
  5905. private static FileFaces;
  5906. /**
  5907. * Converts a texture to the according Spherical Polynomial data.
  5908. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5909. *
  5910. * @param texture The texture to extract the information from.
  5911. * @return The Spherical Polynomial data.
  5912. */
  5913. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5914. /**
  5915. * Converts a cubemap to the according Spherical Polynomial data.
  5916. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5917. *
  5918. * @param cubeInfo The Cube map to extract the information from.
  5919. * @return The Spherical Polynomial data.
  5920. */
  5921. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5922. }
  5923. }
  5924. declare module BABYLON {
  5925. /**
  5926. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5927. * during the life time of the application.
  5928. */
  5929. export class EngineStore {
  5930. /** Gets the list of created engines */
  5931. static Instances: Engine[];
  5932. /**
  5933. * Gets the latest created engine
  5934. */
  5935. static readonly LastCreatedEngine: Nullable<Engine>;
  5936. /**
  5937. * Gets the latest created scene
  5938. */
  5939. static readonly LastCreatedScene: Nullable<Scene>;
  5940. }
  5941. }
  5942. declare module BABYLON {
  5943. /**
  5944. * Define options used to create a render target texture
  5945. */
  5946. export class RenderTargetCreationOptions {
  5947. /**
  5948. * Specifies is mipmaps must be generated
  5949. */
  5950. generateMipMaps?: boolean;
  5951. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5952. generateDepthBuffer?: boolean;
  5953. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5954. generateStencilBuffer?: boolean;
  5955. /** Defines texture type (int by default) */
  5956. type?: number;
  5957. /** Defines sampling mode (trilinear by default) */
  5958. samplingMode?: number;
  5959. /** Defines format (RGBA by default) */
  5960. format?: number;
  5961. }
  5962. }
  5963. declare module BABYLON {
  5964. /**
  5965. * @hidden
  5966. **/
  5967. export class _AlphaState {
  5968. private _isAlphaBlendDirty;
  5969. private _isBlendFunctionParametersDirty;
  5970. private _isBlendEquationParametersDirty;
  5971. private _isBlendConstantsDirty;
  5972. private _alphaBlend;
  5973. private _blendFunctionParameters;
  5974. private _blendEquationParameters;
  5975. private _blendConstants;
  5976. /**
  5977. * Initializes the state.
  5978. */
  5979. constructor();
  5980. readonly isDirty: boolean;
  5981. alphaBlend: boolean;
  5982. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5983. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5984. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5985. reset(): void;
  5986. apply(gl: WebGLRenderingContext): void;
  5987. }
  5988. }
  5989. declare module BABYLON {
  5990. /**
  5991. * @hidden
  5992. **/
  5993. export class _DepthCullingState {
  5994. private _isDepthTestDirty;
  5995. private _isDepthMaskDirty;
  5996. private _isDepthFuncDirty;
  5997. private _isCullFaceDirty;
  5998. private _isCullDirty;
  5999. private _isZOffsetDirty;
  6000. private _isFrontFaceDirty;
  6001. private _depthTest;
  6002. private _depthMask;
  6003. private _depthFunc;
  6004. private _cull;
  6005. private _cullFace;
  6006. private _zOffset;
  6007. private _frontFace;
  6008. /**
  6009. * Initializes the state.
  6010. */
  6011. constructor();
  6012. readonly isDirty: boolean;
  6013. zOffset: number;
  6014. cullFace: Nullable<number>;
  6015. cull: Nullable<boolean>;
  6016. depthFunc: Nullable<number>;
  6017. depthMask: boolean;
  6018. depthTest: boolean;
  6019. frontFace: Nullable<number>;
  6020. reset(): void;
  6021. apply(gl: WebGLRenderingContext): void;
  6022. }
  6023. }
  6024. declare module BABYLON {
  6025. /**
  6026. * @hidden
  6027. **/
  6028. export class _StencilState {
  6029. /** 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 */
  6030. static readonly ALWAYS: number;
  6031. /** Passed to stencilOperation to specify that stencil value must be kept */
  6032. static readonly KEEP: number;
  6033. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6034. static readonly REPLACE: number;
  6035. private _isStencilTestDirty;
  6036. private _isStencilMaskDirty;
  6037. private _isStencilFuncDirty;
  6038. private _isStencilOpDirty;
  6039. private _stencilTest;
  6040. private _stencilMask;
  6041. private _stencilFunc;
  6042. private _stencilFuncRef;
  6043. private _stencilFuncMask;
  6044. private _stencilOpStencilFail;
  6045. private _stencilOpDepthFail;
  6046. private _stencilOpStencilDepthPass;
  6047. readonly isDirty: boolean;
  6048. stencilFunc: number;
  6049. stencilFuncRef: number;
  6050. stencilFuncMask: number;
  6051. stencilOpStencilFail: number;
  6052. stencilOpDepthFail: number;
  6053. stencilOpStencilDepthPass: number;
  6054. stencilMask: number;
  6055. stencilTest: boolean;
  6056. constructor();
  6057. reset(): void;
  6058. apply(gl: WebGLRenderingContext): void;
  6059. }
  6060. }
  6061. declare module BABYLON {
  6062. /**
  6063. * @hidden
  6064. **/
  6065. export class _TimeToken {
  6066. _startTimeQuery: Nullable<WebGLQuery>;
  6067. _endTimeQuery: Nullable<WebGLQuery>;
  6068. _timeElapsedQuery: Nullable<WebGLQuery>;
  6069. _timeElapsedQueryEnded: boolean;
  6070. }
  6071. }
  6072. declare module BABYLON {
  6073. /**
  6074. * Internal interface used to track InternalTexture already bound to the GL context
  6075. */
  6076. export interface IInternalTextureTracker {
  6077. /**
  6078. * Gets or set the previous tracker in the list
  6079. */
  6080. previous: Nullable<IInternalTextureTracker>;
  6081. /**
  6082. * Gets or set the next tracker in the list
  6083. */
  6084. next: Nullable<IInternalTextureTracker>;
  6085. }
  6086. /**
  6087. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6088. */
  6089. export class DummyInternalTextureTracker {
  6090. /**
  6091. * Gets or set the previous tracker in the list
  6092. */
  6093. previous: Nullable<IInternalTextureTracker>;
  6094. /**
  6095. * Gets or set the next tracker in the list
  6096. */
  6097. next: Nullable<IInternalTextureTracker>;
  6098. }
  6099. }
  6100. declare module BABYLON {
  6101. /**
  6102. * Class used to store data associated with WebGL texture data for the engine
  6103. * This class should not be used directly
  6104. */
  6105. export class InternalTexture implements IInternalTextureTracker {
  6106. /** hidden */
  6107. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6108. /**
  6109. * The source of the texture data is unknown
  6110. */
  6111. static DATASOURCE_UNKNOWN: number;
  6112. /**
  6113. * Texture data comes from an URL
  6114. */
  6115. static DATASOURCE_URL: number;
  6116. /**
  6117. * Texture data is only used for temporary storage
  6118. */
  6119. static DATASOURCE_TEMP: number;
  6120. /**
  6121. * Texture data comes from raw data (ArrayBuffer)
  6122. */
  6123. static DATASOURCE_RAW: number;
  6124. /**
  6125. * Texture content is dynamic (video or dynamic texture)
  6126. */
  6127. static DATASOURCE_DYNAMIC: number;
  6128. /**
  6129. * Texture content is generated by rendering to it
  6130. */
  6131. static DATASOURCE_RENDERTARGET: number;
  6132. /**
  6133. * Texture content is part of a multi render target process
  6134. */
  6135. static DATASOURCE_MULTIRENDERTARGET: number;
  6136. /**
  6137. * Texture data comes from a cube data file
  6138. */
  6139. static DATASOURCE_CUBE: number;
  6140. /**
  6141. * Texture data comes from a raw cube data
  6142. */
  6143. static DATASOURCE_CUBERAW: number;
  6144. /**
  6145. * Texture data come from a prefiltered cube data file
  6146. */
  6147. static DATASOURCE_CUBEPREFILTERED: number;
  6148. /**
  6149. * Texture content is raw 3D data
  6150. */
  6151. static DATASOURCE_RAW3D: number;
  6152. /**
  6153. * Texture content is a depth texture
  6154. */
  6155. static DATASOURCE_DEPTHTEXTURE: number;
  6156. /**
  6157. * Texture data comes from a raw cube data encoded with RGBD
  6158. */
  6159. static DATASOURCE_CUBERAW_RGBD: number;
  6160. /**
  6161. * Defines if the texture is ready
  6162. */
  6163. isReady: boolean;
  6164. /**
  6165. * Defines if the texture is a cube texture
  6166. */
  6167. isCube: boolean;
  6168. /**
  6169. * Defines if the texture contains 3D data
  6170. */
  6171. is3D: boolean;
  6172. /**
  6173. * Gets the URL used to load this texture
  6174. */
  6175. url: string;
  6176. /**
  6177. * Gets the sampling mode of the texture
  6178. */
  6179. samplingMode: number;
  6180. /**
  6181. * Gets a boolean indicating if the texture needs mipmaps generation
  6182. */
  6183. generateMipMaps: boolean;
  6184. /**
  6185. * Gets the number of samples used by the texture (WebGL2+ only)
  6186. */
  6187. samples: number;
  6188. /**
  6189. * Gets the type of the texture (int, float...)
  6190. */
  6191. type: number;
  6192. /**
  6193. * Gets the format of the texture (RGB, RGBA...)
  6194. */
  6195. format: number;
  6196. /**
  6197. * Observable called when the texture is loaded
  6198. */
  6199. onLoadedObservable: Observable<InternalTexture>;
  6200. /**
  6201. * Gets the width of the texture
  6202. */
  6203. width: number;
  6204. /**
  6205. * Gets the height of the texture
  6206. */
  6207. height: number;
  6208. /**
  6209. * Gets the depth of the texture
  6210. */
  6211. depth: number;
  6212. /**
  6213. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6214. */
  6215. baseWidth: number;
  6216. /**
  6217. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6218. */
  6219. baseHeight: number;
  6220. /**
  6221. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6222. */
  6223. baseDepth: number;
  6224. /**
  6225. * Gets a boolean indicating if the texture is inverted on Y axis
  6226. */
  6227. invertY: boolean;
  6228. /**
  6229. * Gets or set the previous tracker in the list
  6230. */
  6231. previous: Nullable<IInternalTextureTracker>;
  6232. /**
  6233. * Gets or set the next tracker in the list
  6234. */
  6235. next: Nullable<IInternalTextureTracker>;
  6236. /** @hidden */
  6237. _invertVScale: boolean;
  6238. /** @hidden */
  6239. _initialSlot: number;
  6240. /** @hidden */
  6241. _designatedSlot: number;
  6242. /** @hidden */
  6243. _dataSource: number;
  6244. /** @hidden */
  6245. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6246. /** @hidden */
  6247. _bufferView: Nullable<ArrayBufferView>;
  6248. /** @hidden */
  6249. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6250. /** @hidden */
  6251. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6252. /** @hidden */
  6253. _size: number;
  6254. /** @hidden */
  6255. _extension: string;
  6256. /** @hidden */
  6257. _files: Nullable<string[]>;
  6258. /** @hidden */
  6259. _workingCanvas: HTMLCanvasElement;
  6260. /** @hidden */
  6261. _workingContext: CanvasRenderingContext2D;
  6262. /** @hidden */
  6263. _framebuffer: Nullable<WebGLFramebuffer>;
  6264. /** @hidden */
  6265. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6266. /** @hidden */
  6267. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6268. /** @hidden */
  6269. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6270. /** @hidden */
  6271. _attachments: Nullable<number[]>;
  6272. /** @hidden */
  6273. _cachedCoordinatesMode: Nullable<number>;
  6274. /** @hidden */
  6275. _cachedWrapU: Nullable<number>;
  6276. /** @hidden */
  6277. _cachedWrapV: Nullable<number>;
  6278. /** @hidden */
  6279. _cachedWrapR: Nullable<number>;
  6280. /** @hidden */
  6281. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6282. /** @hidden */
  6283. _isDisabled: boolean;
  6284. /** @hidden */
  6285. _compression: Nullable<string>;
  6286. /** @hidden */
  6287. _generateStencilBuffer: boolean;
  6288. /** @hidden */
  6289. _generateDepthBuffer: boolean;
  6290. /** @hidden */
  6291. _comparisonFunction: number;
  6292. /** @hidden */
  6293. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6294. /** @hidden */
  6295. _lodGenerationScale: number;
  6296. /** @hidden */
  6297. _lodGenerationOffset: number;
  6298. /** @hidden */
  6299. _lodTextureHigh: BaseTexture;
  6300. /** @hidden */
  6301. _lodTextureMid: BaseTexture;
  6302. /** @hidden */
  6303. _lodTextureLow: BaseTexture;
  6304. /** @hidden */
  6305. _isRGBD: boolean;
  6306. /** @hidden */
  6307. _webGLTexture: Nullable<WebGLTexture>;
  6308. /** @hidden */
  6309. _references: number;
  6310. private _engine;
  6311. /**
  6312. * Gets the Engine the texture belongs to.
  6313. * @returns The babylon engine
  6314. */
  6315. getEngine(): Engine;
  6316. /**
  6317. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6318. */
  6319. readonly dataSource: number;
  6320. /**
  6321. * Creates a new InternalTexture
  6322. * @param engine defines the engine to use
  6323. * @param dataSource defines the type of data that will be used
  6324. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6325. */
  6326. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6327. /**
  6328. * Increments the number of references (ie. the number of Texture that point to it)
  6329. */
  6330. incrementReferences(): void;
  6331. /**
  6332. * Change the size of the texture (not the size of the content)
  6333. * @param width defines the new width
  6334. * @param height defines the new height
  6335. * @param depth defines the new depth (1 by default)
  6336. */
  6337. updateSize(width: int, height: int, depth?: int): void;
  6338. /** @hidden */
  6339. _rebuild(): void;
  6340. /** @hidden */
  6341. _swapAndDie(target: InternalTexture): void;
  6342. /**
  6343. * Dispose the current allocated resources
  6344. */
  6345. dispose(): void;
  6346. }
  6347. }
  6348. declare module BABYLON {
  6349. /**
  6350. * This represents the main contract an easing function should follow.
  6351. * Easing functions are used throughout the animation system.
  6352. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6353. */
  6354. export interface IEasingFunction {
  6355. /**
  6356. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6357. * of the easing function.
  6358. * The link below provides some of the most common examples of easing functions.
  6359. * @see https://easings.net/
  6360. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6361. * @returns the corresponding value on the curve defined by the easing function
  6362. */
  6363. ease(gradient: number): number;
  6364. }
  6365. /**
  6366. * Base class used for every default easing function.
  6367. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6368. */
  6369. export class EasingFunction implements IEasingFunction {
  6370. /**
  6371. * Interpolation follows the mathematical formula associated with the easing function.
  6372. */
  6373. static readonly EASINGMODE_EASEIN: number;
  6374. /**
  6375. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6376. */
  6377. static readonly EASINGMODE_EASEOUT: number;
  6378. /**
  6379. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6380. */
  6381. static readonly EASINGMODE_EASEINOUT: number;
  6382. private _easingMode;
  6383. /**
  6384. * Sets the easing mode of the current function.
  6385. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6386. */
  6387. setEasingMode(easingMode: number): void;
  6388. /**
  6389. * Gets the current easing mode.
  6390. * @returns the easing mode
  6391. */
  6392. getEasingMode(): number;
  6393. /**
  6394. * @hidden
  6395. */
  6396. easeInCore(gradient: number): number;
  6397. /**
  6398. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6399. * of the easing function.
  6400. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6401. * @returns the corresponding value on the curve defined by the easing function
  6402. */
  6403. ease(gradient: number): number;
  6404. }
  6405. /**
  6406. * Easing function with a circle shape (see link below).
  6407. * @see https://easings.net/#easeInCirc
  6408. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6409. */
  6410. export class CircleEase extends EasingFunction implements IEasingFunction {
  6411. /** @hidden */
  6412. easeInCore(gradient: number): number;
  6413. }
  6414. /**
  6415. * Easing function with a ease back shape (see link below).
  6416. * @see https://easings.net/#easeInBack
  6417. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6418. */
  6419. export class BackEase extends EasingFunction implements IEasingFunction {
  6420. /** Defines the amplitude of the function */
  6421. amplitude: number;
  6422. /**
  6423. * Instantiates a back ease easing
  6424. * @see https://easings.net/#easeInBack
  6425. * @param amplitude Defines the amplitude of the function
  6426. */
  6427. constructor(
  6428. /** Defines the amplitude of the function */
  6429. amplitude?: number);
  6430. /** @hidden */
  6431. easeInCore(gradient: number): number;
  6432. }
  6433. /**
  6434. * Easing function with a bouncing shape (see link below).
  6435. * @see https://easings.net/#easeInBounce
  6436. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6437. */
  6438. export class BounceEase extends EasingFunction implements IEasingFunction {
  6439. /** Defines the number of bounces */
  6440. bounces: number;
  6441. /** Defines the amplitude of the bounce */
  6442. bounciness: number;
  6443. /**
  6444. * Instantiates a bounce easing
  6445. * @see https://easings.net/#easeInBounce
  6446. * @param bounces Defines the number of bounces
  6447. * @param bounciness Defines the amplitude of the bounce
  6448. */
  6449. constructor(
  6450. /** Defines the number of bounces */
  6451. bounces?: number,
  6452. /** Defines the amplitude of the bounce */
  6453. bounciness?: number);
  6454. /** @hidden */
  6455. easeInCore(gradient: number): number;
  6456. }
  6457. /**
  6458. * Easing function with a power of 3 shape (see link below).
  6459. * @see https://easings.net/#easeInCubic
  6460. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6461. */
  6462. export class CubicEase extends EasingFunction implements IEasingFunction {
  6463. /** @hidden */
  6464. easeInCore(gradient: number): number;
  6465. }
  6466. /**
  6467. * Easing function with an elastic shape (see link below).
  6468. * @see https://easings.net/#easeInElastic
  6469. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6470. */
  6471. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6472. /** Defines the number of oscillations*/
  6473. oscillations: number;
  6474. /** Defines the amplitude of the oscillations*/
  6475. springiness: number;
  6476. /**
  6477. * Instantiates an elastic easing function
  6478. * @see https://easings.net/#easeInElastic
  6479. * @param oscillations Defines the number of oscillations
  6480. * @param springiness Defines the amplitude of the oscillations
  6481. */
  6482. constructor(
  6483. /** Defines the number of oscillations*/
  6484. oscillations?: number,
  6485. /** Defines the amplitude of the oscillations*/
  6486. springiness?: number);
  6487. /** @hidden */
  6488. easeInCore(gradient: number): number;
  6489. }
  6490. /**
  6491. * Easing function with an exponential shape (see link below).
  6492. * @see https://easings.net/#easeInExpo
  6493. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6494. */
  6495. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6496. /** Defines the exponent of the function */
  6497. exponent: number;
  6498. /**
  6499. * Instantiates an exponential easing function
  6500. * @see https://easings.net/#easeInExpo
  6501. * @param exponent Defines the exponent of the function
  6502. */
  6503. constructor(
  6504. /** Defines the exponent of the function */
  6505. exponent?: number);
  6506. /** @hidden */
  6507. easeInCore(gradient: number): number;
  6508. }
  6509. /**
  6510. * Easing function with a power shape (see link below).
  6511. * @see https://easings.net/#easeInQuad
  6512. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6513. */
  6514. export class PowerEase extends EasingFunction implements IEasingFunction {
  6515. /** Defines the power of the function */
  6516. power: number;
  6517. /**
  6518. * Instantiates an power base easing function
  6519. * @see https://easings.net/#easeInQuad
  6520. * @param power Defines the power of the function
  6521. */
  6522. constructor(
  6523. /** Defines the power of the function */
  6524. power?: number);
  6525. /** @hidden */
  6526. easeInCore(gradient: number): number;
  6527. }
  6528. /**
  6529. * Easing function with a power of 2 shape (see link below).
  6530. * @see https://easings.net/#easeInQuad
  6531. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6532. */
  6533. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6534. /** @hidden */
  6535. easeInCore(gradient: number): number;
  6536. }
  6537. /**
  6538. * Easing function with a power of 4 shape (see link below).
  6539. * @see https://easings.net/#easeInQuart
  6540. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6541. */
  6542. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6543. /** @hidden */
  6544. easeInCore(gradient: number): number;
  6545. }
  6546. /**
  6547. * Easing function with a power of 5 shape (see link below).
  6548. * @see https://easings.net/#easeInQuint
  6549. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6550. */
  6551. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6552. /** @hidden */
  6553. easeInCore(gradient: number): number;
  6554. }
  6555. /**
  6556. * Easing function with a sin shape (see link below).
  6557. * @see https://easings.net/#easeInSine
  6558. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6559. */
  6560. export class SineEase extends EasingFunction implements IEasingFunction {
  6561. /** @hidden */
  6562. easeInCore(gradient: number): number;
  6563. }
  6564. /**
  6565. * Easing function with a bezier shape (see link below).
  6566. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6567. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6568. */
  6569. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6570. /** Defines the x component of the start tangent in the bezier curve */
  6571. x1: number;
  6572. /** Defines the y component of the start tangent in the bezier curve */
  6573. y1: number;
  6574. /** Defines the x component of the end tangent in the bezier curve */
  6575. x2: number;
  6576. /** Defines the y component of the end tangent in the bezier curve */
  6577. y2: number;
  6578. /**
  6579. * Instantiates a bezier function
  6580. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6581. * @param x1 Defines the x component of the start tangent in the bezier curve
  6582. * @param y1 Defines the y component of the start tangent in the bezier curve
  6583. * @param x2 Defines the x component of the end tangent in the bezier curve
  6584. * @param y2 Defines the y component of the end tangent in the bezier curve
  6585. */
  6586. constructor(
  6587. /** Defines the x component of the start tangent in the bezier curve */
  6588. x1?: number,
  6589. /** Defines the y component of the start tangent in the bezier curve */
  6590. y1?: number,
  6591. /** Defines the x component of the end tangent in the bezier curve */
  6592. x2?: number,
  6593. /** Defines the y component of the end tangent in the bezier curve */
  6594. y2?: number);
  6595. /** @hidden */
  6596. easeInCore(gradient: number): number;
  6597. }
  6598. }
  6599. declare module BABYLON {
  6600. /**
  6601. * Defines an interface which represents an animation key frame
  6602. */
  6603. export interface IAnimationKey {
  6604. /**
  6605. * Frame of the key frame
  6606. */
  6607. frame: number;
  6608. /**
  6609. * Value at the specifies key frame
  6610. */
  6611. value: any;
  6612. /**
  6613. * The input tangent for the cubic hermite spline
  6614. */
  6615. inTangent?: any;
  6616. /**
  6617. * The output tangent for the cubic hermite spline
  6618. */
  6619. outTangent?: any;
  6620. /**
  6621. * The animation interpolation type
  6622. */
  6623. interpolation?: AnimationKeyInterpolation;
  6624. }
  6625. /**
  6626. * Enum for the animation key frame interpolation type
  6627. */
  6628. export enum AnimationKeyInterpolation {
  6629. /**
  6630. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6631. */
  6632. STEP = 1
  6633. }
  6634. }
  6635. declare module BABYLON {
  6636. /**
  6637. * Represents the range of an animation
  6638. */
  6639. export class AnimationRange {
  6640. /**The name of the animation range**/
  6641. name: string;
  6642. /**The starting frame of the animation */
  6643. from: number;
  6644. /**The ending frame of the animation*/
  6645. to: number;
  6646. /**
  6647. * Initializes the range of an animation
  6648. * @param name The name of the animation range
  6649. * @param from The starting frame of the animation
  6650. * @param to The ending frame of the animation
  6651. */
  6652. constructor(
  6653. /**The name of the animation range**/
  6654. name: string,
  6655. /**The starting frame of the animation */
  6656. from: number,
  6657. /**The ending frame of the animation*/
  6658. to: number);
  6659. /**
  6660. * Makes a copy of the animation range
  6661. * @returns A copy of the animation range
  6662. */
  6663. clone(): AnimationRange;
  6664. }
  6665. }
  6666. declare module BABYLON {
  6667. /**
  6668. * Composed of a frame, and an action function
  6669. */
  6670. export class AnimationEvent {
  6671. /** The frame for which the event is triggered **/
  6672. frame: number;
  6673. /** The event to perform when triggered **/
  6674. action: (currentFrame: number) => void;
  6675. /** Specifies if the event should be triggered only once**/
  6676. onlyOnce?: boolean | undefined;
  6677. /**
  6678. * Specifies if the animation event is done
  6679. */
  6680. isDone: boolean;
  6681. /**
  6682. * Initializes the animation event
  6683. * @param frame The frame for which the event is triggered
  6684. * @param action The event to perform when triggered
  6685. * @param onlyOnce Specifies if the event should be triggered only once
  6686. */
  6687. constructor(
  6688. /** The frame for which the event is triggered **/
  6689. frame: number,
  6690. /** The event to perform when triggered **/
  6691. action: (currentFrame: number) => void,
  6692. /** Specifies if the event should be triggered only once**/
  6693. onlyOnce?: boolean | undefined);
  6694. /** @hidden */
  6695. _clone(): AnimationEvent;
  6696. }
  6697. }
  6698. declare module BABYLON {
  6699. /**
  6700. * Interface used to define a behavior
  6701. */
  6702. export interface Behavior<T> {
  6703. /** gets or sets behavior's name */
  6704. name: string;
  6705. /**
  6706. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6707. */
  6708. init(): void;
  6709. /**
  6710. * Called when the behavior is attached to a target
  6711. * @param target defines the target where the behavior is attached to
  6712. */
  6713. attach(target: T): void;
  6714. /**
  6715. * Called when the behavior is detached from its target
  6716. */
  6717. detach(): void;
  6718. }
  6719. /**
  6720. * Interface implemented by classes supporting behaviors
  6721. */
  6722. export interface IBehaviorAware<T> {
  6723. /**
  6724. * Attach a behavior
  6725. * @param behavior defines the behavior to attach
  6726. * @returns the current host
  6727. */
  6728. addBehavior(behavior: Behavior<T>): T;
  6729. /**
  6730. * Remove a behavior from the current object
  6731. * @param behavior defines the behavior to detach
  6732. * @returns the current host
  6733. */
  6734. removeBehavior(behavior: Behavior<T>): T;
  6735. /**
  6736. * Gets a behavior using its name to search
  6737. * @param name defines the name to search
  6738. * @returns the behavior or null if not found
  6739. */
  6740. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6741. }
  6742. }
  6743. declare module BABYLON {
  6744. /**
  6745. * Defines a runtime animation
  6746. */
  6747. export class RuntimeAnimation {
  6748. private _events;
  6749. /**
  6750. * The current frame of the runtime animation
  6751. */
  6752. private _currentFrame;
  6753. /**
  6754. * The animation used by the runtime animation
  6755. */
  6756. private _animation;
  6757. /**
  6758. * The target of the runtime animation
  6759. */
  6760. private _target;
  6761. /**
  6762. * The initiating animatable
  6763. */
  6764. private _host;
  6765. /**
  6766. * The original value of the runtime animation
  6767. */
  6768. private _originalValue;
  6769. /**
  6770. * The original blend value of the runtime animation
  6771. */
  6772. private _originalBlendValue;
  6773. /**
  6774. * The offsets cache of the runtime animation
  6775. */
  6776. private _offsetsCache;
  6777. /**
  6778. * The high limits cache of the runtime animation
  6779. */
  6780. private _highLimitsCache;
  6781. /**
  6782. * Specifies if the runtime animation has been stopped
  6783. */
  6784. private _stopped;
  6785. /**
  6786. * The blending factor of the runtime animation
  6787. */
  6788. private _blendingFactor;
  6789. /**
  6790. * The BabylonJS scene
  6791. */
  6792. private _scene;
  6793. /**
  6794. * The current value of the runtime animation
  6795. */
  6796. private _currentValue;
  6797. /** @hidden */
  6798. _workValue: any;
  6799. /**
  6800. * The active target of the runtime animation
  6801. */
  6802. private _activeTarget;
  6803. /**
  6804. * The target path of the runtime animation
  6805. */
  6806. private _targetPath;
  6807. /**
  6808. * The weight of the runtime animation
  6809. */
  6810. private _weight;
  6811. /**
  6812. * The ratio offset of the runtime animation
  6813. */
  6814. private _ratioOffset;
  6815. /**
  6816. * The previous delay of the runtime animation
  6817. */
  6818. private _previousDelay;
  6819. /**
  6820. * The previous ratio of the runtime animation
  6821. */
  6822. private _previousRatio;
  6823. /**
  6824. * Gets the current frame of the runtime animation
  6825. */
  6826. readonly currentFrame: number;
  6827. /**
  6828. * Gets the weight of the runtime animation
  6829. */
  6830. readonly weight: number;
  6831. /**
  6832. * Gets the current value of the runtime animation
  6833. */
  6834. readonly currentValue: any;
  6835. /**
  6836. * Gets the target path of the runtime animation
  6837. */
  6838. readonly targetPath: string;
  6839. /**
  6840. * Gets the actual target of the runtime animation
  6841. */
  6842. readonly target: any;
  6843. /**
  6844. * Create a new RuntimeAnimation object
  6845. * @param target defines the target of the animation
  6846. * @param animation defines the source animation object
  6847. * @param scene defines the hosting scene
  6848. * @param host defines the initiating Animatable
  6849. */
  6850. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  6851. /**
  6852. * Gets the animation from the runtime animation
  6853. */
  6854. readonly animation: Animation;
  6855. /**
  6856. * Resets the runtime animation to the beginning
  6857. * @param restoreOriginal defines whether to restore the target property to the original value
  6858. */
  6859. reset(restoreOriginal?: boolean): void;
  6860. /**
  6861. * Specifies if the runtime animation is stopped
  6862. * @returns Boolean specifying if the runtime animation is stopped
  6863. */
  6864. isStopped(): boolean;
  6865. /**
  6866. * Disposes of the runtime animation
  6867. */
  6868. dispose(): void;
  6869. /**
  6870. * Interpolates the animation from the current frame
  6871. * @param currentFrame The frame to interpolate the animation to
  6872. * @param repeatCount The number of times that the animation should loop
  6873. * @param loopMode The type of looping mode to use
  6874. * @param offsetValue Animation offset value
  6875. * @param highLimitValue The high limit value
  6876. * @returns The interpolated value
  6877. */
  6878. private _interpolate;
  6879. /**
  6880. * Apply the interpolated value to the target
  6881. * @param currentValue defines the value computed by the animation
  6882. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  6883. */
  6884. setValue(currentValue: any, weight?: number): void;
  6885. private _setValue;
  6886. /**
  6887. * Gets the loop pmode of the runtime animation
  6888. * @returns Loop Mode
  6889. */
  6890. private _getCorrectLoopMode;
  6891. /**
  6892. * Move the current animation to a given frame
  6893. * @param frame defines the frame to move to
  6894. */
  6895. goToFrame(frame: number): void;
  6896. /**
  6897. * @hidden Internal use only
  6898. */
  6899. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  6900. /**
  6901. * Execute the current animation
  6902. * @param delay defines the delay to add to the current frame
  6903. * @param from defines the lower bound of the animation range
  6904. * @param to defines the upper bound of the animation range
  6905. * @param loop defines if the current animation must loop
  6906. * @param speedRatio defines the current speed ratio
  6907. * @param weight defines the weight of the animation (default is -1 so no weight)
  6908. * @param onLoop optional callback called when animation loops
  6909. * @returns a boolean indicating if the animation is running
  6910. */
  6911. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  6912. }
  6913. }
  6914. declare module BABYLON {
  6915. /**
  6916. * @hidden
  6917. */
  6918. export class IntersectionInfo {
  6919. bu: Nullable<number>;
  6920. bv: Nullable<number>;
  6921. distance: number;
  6922. faceId: number;
  6923. subMeshId: number;
  6924. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6925. }
  6926. }
  6927. declare module BABYLON {
  6928. /**
  6929. * Interface used to define ActionEvent
  6930. */
  6931. export interface IActionEvent {
  6932. /** The mesh or sprite that triggered the action */
  6933. source: any;
  6934. /** The X mouse cursor position at the time of the event */
  6935. pointerX: number;
  6936. /** The Y mouse cursor position at the time of the event */
  6937. pointerY: number;
  6938. /** The mesh that is currently pointed at (can be null) */
  6939. meshUnderPointer: Nullable<AbstractMesh>;
  6940. /** the original (browser) event that triggered the ActionEvent */
  6941. sourceEvent?: any;
  6942. /** additional data for the event */
  6943. additionalData?: any;
  6944. }
  6945. /**
  6946. * ActionEvent is the event being sent when an action is triggered.
  6947. */
  6948. export class ActionEvent implements IActionEvent {
  6949. /** The mesh or sprite that triggered the action */
  6950. source: any;
  6951. /** The X mouse cursor position at the time of the event */
  6952. pointerX: number;
  6953. /** The Y mouse cursor position at the time of the event */
  6954. pointerY: number;
  6955. /** The mesh that is currently pointed at (can be null) */
  6956. meshUnderPointer: Nullable<AbstractMesh>;
  6957. /** the original (browser) event that triggered the ActionEvent */
  6958. sourceEvent?: any;
  6959. /** additional data for the event */
  6960. additionalData?: any;
  6961. /**
  6962. * Creates a new ActionEvent
  6963. * @param source The mesh or sprite that triggered the action
  6964. * @param pointerX The X mouse cursor position at the time of the event
  6965. * @param pointerY The Y mouse cursor position at the time of the event
  6966. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  6967. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  6968. * @param additionalData additional data for the event
  6969. */
  6970. constructor(
  6971. /** The mesh or sprite that triggered the action */
  6972. source: any,
  6973. /** The X mouse cursor position at the time of the event */
  6974. pointerX: number,
  6975. /** The Y mouse cursor position at the time of the event */
  6976. pointerY: number,
  6977. /** The mesh that is currently pointed at (can be null) */
  6978. meshUnderPointer: Nullable<AbstractMesh>,
  6979. /** the original (browser) event that triggered the ActionEvent */
  6980. sourceEvent?: any,
  6981. /** additional data for the event */
  6982. additionalData?: any);
  6983. /**
  6984. * Helper function to auto-create an ActionEvent from a source mesh.
  6985. * @param source The source mesh that triggered the event
  6986. * @param evt The original (browser) event
  6987. * @param additionalData additional data for the event
  6988. * @returns the new ActionEvent
  6989. */
  6990. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  6991. /**
  6992. * Helper function to auto-create an ActionEvent from a source sprite
  6993. * @param source The source sprite that triggered the event
  6994. * @param scene Scene associated with the sprite
  6995. * @param evt The original (browser) event
  6996. * @param additionalData additional data for the event
  6997. * @returns the new ActionEvent
  6998. */
  6999. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  7000. /**
  7001. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  7002. * @param scene the scene where the event occurred
  7003. * @param evt The original (browser) event
  7004. * @returns the new ActionEvent
  7005. */
  7006. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  7007. /**
  7008. * Helper function to auto-create an ActionEvent from a primitive
  7009. * @param prim defines the target primitive
  7010. * @param pointerPos defines the pointer position
  7011. * @param evt The original (browser) event
  7012. * @param additionalData additional data for the event
  7013. * @returns the new ActionEvent
  7014. */
  7015. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  7016. }
  7017. }
  7018. declare module BABYLON {
  7019. /**
  7020. * Class used to store bounding sphere information
  7021. */
  7022. export class BoundingSphere {
  7023. /**
  7024. * Gets the center of the bounding sphere in local space
  7025. */
  7026. readonly center: Vector3;
  7027. /**
  7028. * Radius of the bounding sphere in local space
  7029. */
  7030. radius: number;
  7031. /**
  7032. * Gets the center of the bounding sphere in world space
  7033. */
  7034. readonly centerWorld: Vector3;
  7035. /**
  7036. * Radius of the bounding sphere in world space
  7037. */
  7038. radiusWorld: number;
  7039. /**
  7040. * Gets the minimum vector in local space
  7041. */
  7042. readonly minimum: Vector3;
  7043. /**
  7044. * Gets the maximum vector in local space
  7045. */
  7046. readonly maximum: Vector3;
  7047. private _worldMatrix;
  7048. private static readonly TmpVector3;
  7049. /**
  7050. * Creates a new bounding sphere
  7051. * @param min defines the minimum vector (in local space)
  7052. * @param max defines the maximum vector (in local space)
  7053. * @param worldMatrix defines the new world matrix
  7054. */
  7055. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7056. /**
  7057. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7058. * @param min defines the new minimum vector (in local space)
  7059. * @param max defines the new maximum vector (in local space)
  7060. * @param worldMatrix defines the new world matrix
  7061. */
  7062. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7063. /**
  7064. * Scale the current bounding sphere by applying a scale factor
  7065. * @param factor defines the scale factor to apply
  7066. * @returns the current bounding box
  7067. */
  7068. scale(factor: number): BoundingSphere;
  7069. /**
  7070. * Gets the world matrix of the bounding box
  7071. * @returns a matrix
  7072. */
  7073. getWorldMatrix(): DeepImmutable<Matrix>;
  7074. /** @hidden */
  7075. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7076. /**
  7077. * Tests if the bounding sphere is intersecting the frustum planes
  7078. * @param frustumPlanes defines the frustum planes to test
  7079. * @returns true if there is an intersection
  7080. */
  7081. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7082. /**
  7083. * Tests if the bounding sphere center is in between the frustum planes.
  7084. * Used for optimistic fast inclusion.
  7085. * @param frustumPlanes defines the frustum planes to test
  7086. * @returns true if the sphere center is in between the frustum planes
  7087. */
  7088. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7089. /**
  7090. * Tests if a point is inside the bounding sphere
  7091. * @param point defines the point to test
  7092. * @returns true if the point is inside the bounding sphere
  7093. */
  7094. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7095. /**
  7096. * Checks if two sphere intersct
  7097. * @param sphere0 sphere 0
  7098. * @param sphere1 sphere 1
  7099. * @returns true if the speres intersect
  7100. */
  7101. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7102. }
  7103. }
  7104. declare module BABYLON {
  7105. /**
  7106. * Class used to store bounding box information
  7107. */
  7108. export class BoundingBox implements ICullable {
  7109. /**
  7110. * Gets the 8 vectors representing the bounding box in local space
  7111. */
  7112. readonly vectors: Vector3[];
  7113. /**
  7114. * Gets the center of the bounding box in local space
  7115. */
  7116. readonly center: Vector3;
  7117. /**
  7118. * Gets the center of the bounding box in world space
  7119. */
  7120. readonly centerWorld: Vector3;
  7121. /**
  7122. * Gets the extend size in local space
  7123. */
  7124. readonly extendSize: Vector3;
  7125. /**
  7126. * Gets the extend size in world space
  7127. */
  7128. readonly extendSizeWorld: Vector3;
  7129. /**
  7130. * Gets the OBB (object bounding box) directions
  7131. */
  7132. readonly directions: Vector3[];
  7133. /**
  7134. * Gets the 8 vectors representing the bounding box in world space
  7135. */
  7136. readonly vectorsWorld: Vector3[];
  7137. /**
  7138. * Gets the minimum vector in world space
  7139. */
  7140. readonly minimumWorld: Vector3;
  7141. /**
  7142. * Gets the maximum vector in world space
  7143. */
  7144. readonly maximumWorld: Vector3;
  7145. /**
  7146. * Gets the minimum vector in local space
  7147. */
  7148. readonly minimum: Vector3;
  7149. /**
  7150. * Gets the maximum vector in local space
  7151. */
  7152. readonly maximum: Vector3;
  7153. private _worldMatrix;
  7154. private static readonly TmpVector3;
  7155. /**
  7156. * @hidden
  7157. */
  7158. _tag: number;
  7159. /**
  7160. * Creates a new bounding box
  7161. * @param min defines the minimum vector (in local space)
  7162. * @param max defines the maximum vector (in local space)
  7163. * @param worldMatrix defines the new world matrix
  7164. */
  7165. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7166. /**
  7167. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7168. * @param min defines the new minimum vector (in local space)
  7169. * @param max defines the new maximum vector (in local space)
  7170. * @param worldMatrix defines the new world matrix
  7171. */
  7172. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7173. /**
  7174. * Scale the current bounding box by applying a scale factor
  7175. * @param factor defines the scale factor to apply
  7176. * @returns the current bounding box
  7177. */
  7178. scale(factor: number): BoundingBox;
  7179. /**
  7180. * Gets the world matrix of the bounding box
  7181. * @returns a matrix
  7182. */
  7183. getWorldMatrix(): DeepImmutable<Matrix>;
  7184. /** @hidden */
  7185. _update(world: DeepImmutable<Matrix>): void;
  7186. /**
  7187. * Tests if the bounding box is intersecting the frustum planes
  7188. * @param frustumPlanes defines the frustum planes to test
  7189. * @returns true if there is an intersection
  7190. */
  7191. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7192. /**
  7193. * Tests if the bounding box is entirely inside the frustum planes
  7194. * @param frustumPlanes defines the frustum planes to test
  7195. * @returns true if there is an inclusion
  7196. */
  7197. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7198. /**
  7199. * Tests if a point is inside the bounding box
  7200. * @param point defines the point to test
  7201. * @returns true if the point is inside the bounding box
  7202. */
  7203. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7204. /**
  7205. * Tests if the bounding box intersects with a bounding sphere
  7206. * @param sphere defines the sphere to test
  7207. * @returns true if there is an intersection
  7208. */
  7209. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7210. /**
  7211. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7212. * @param min defines the min vector to use
  7213. * @param max defines the max vector to use
  7214. * @returns true if there is an intersection
  7215. */
  7216. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7217. /**
  7218. * Tests if two bounding boxes are intersections
  7219. * @param box0 defines the first box to test
  7220. * @param box1 defines the second box to test
  7221. * @returns true if there is an intersection
  7222. */
  7223. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7224. /**
  7225. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7226. * @param minPoint defines the minimum vector of the bounding box
  7227. * @param maxPoint defines the maximum vector of the bounding box
  7228. * @param sphereCenter defines the sphere center
  7229. * @param sphereRadius defines the sphere radius
  7230. * @returns true if there is an intersection
  7231. */
  7232. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7233. /**
  7234. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7235. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7236. * @param frustumPlanes defines the frustum planes to test
  7237. * @return true if there is an inclusion
  7238. */
  7239. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7240. /**
  7241. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7242. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7243. * @param frustumPlanes defines the frustum planes to test
  7244. * @return true if there is an intersection
  7245. */
  7246. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7247. }
  7248. }
  7249. declare module BABYLON {
  7250. /** @hidden */
  7251. export class Collider {
  7252. /** Define if a collision was found */
  7253. collisionFound: boolean;
  7254. /**
  7255. * Define last intersection point in local space
  7256. */
  7257. intersectionPoint: Vector3;
  7258. /**
  7259. * Define last collided mesh
  7260. */
  7261. collidedMesh: Nullable<AbstractMesh>;
  7262. private _collisionPoint;
  7263. private _planeIntersectionPoint;
  7264. private _tempVector;
  7265. private _tempVector2;
  7266. private _tempVector3;
  7267. private _tempVector4;
  7268. private _edge;
  7269. private _baseToVertex;
  7270. private _destinationPoint;
  7271. private _slidePlaneNormal;
  7272. private _displacementVector;
  7273. /** @hidden */
  7274. _radius: Vector3;
  7275. /** @hidden */
  7276. _retry: number;
  7277. private _velocity;
  7278. private _basePoint;
  7279. private _epsilon;
  7280. /** @hidden */
  7281. _velocityWorldLength: number;
  7282. /** @hidden */
  7283. _basePointWorld: Vector3;
  7284. private _velocityWorld;
  7285. private _normalizedVelocity;
  7286. /** @hidden */
  7287. _initialVelocity: Vector3;
  7288. /** @hidden */
  7289. _initialPosition: Vector3;
  7290. private _nearestDistance;
  7291. private _collisionMask;
  7292. collisionMask: number;
  7293. /**
  7294. * Gets the plane normal used to compute the sliding response (in local space)
  7295. */
  7296. readonly slidePlaneNormal: Vector3;
  7297. /** @hidden */
  7298. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7299. /** @hidden */
  7300. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7301. /** @hidden */
  7302. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7303. /** @hidden */
  7304. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7305. /** @hidden */
  7306. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7307. /** @hidden */
  7308. _getResponse(pos: Vector3, vel: Vector3): void;
  7309. }
  7310. }
  7311. declare module BABYLON {
  7312. /**
  7313. * Interface for cullable objects
  7314. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7315. */
  7316. export interface ICullable {
  7317. /**
  7318. * Checks if the object or part of the object is in the frustum
  7319. * @param frustumPlanes Camera near/planes
  7320. * @returns true if the object is in frustum otherwise false
  7321. */
  7322. isInFrustum(frustumPlanes: Plane[]): boolean;
  7323. /**
  7324. * Checks if a cullable object (mesh...) is in the camera frustum
  7325. * Unlike isInFrustum this cheks the full bounding box
  7326. * @param frustumPlanes Camera near/planes
  7327. * @returns true if the object is in frustum otherwise false
  7328. */
  7329. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7330. }
  7331. /**
  7332. * Info for a bounding data of a mesh
  7333. */
  7334. export class BoundingInfo implements ICullable {
  7335. /**
  7336. * Bounding box for the mesh
  7337. */
  7338. readonly boundingBox: BoundingBox;
  7339. /**
  7340. * Bounding sphere for the mesh
  7341. */
  7342. readonly boundingSphere: BoundingSphere;
  7343. private _isLocked;
  7344. private static readonly TmpVector3;
  7345. /**
  7346. * Constructs bounding info
  7347. * @param minimum min vector of the bounding box/sphere
  7348. * @param maximum max vector of the bounding box/sphere
  7349. * @param worldMatrix defines the new world matrix
  7350. */
  7351. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7352. /**
  7353. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7354. * @param min defines the new minimum vector (in local space)
  7355. * @param max defines the new maximum vector (in local space)
  7356. * @param worldMatrix defines the new world matrix
  7357. */
  7358. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7359. /**
  7360. * min vector of the bounding box/sphere
  7361. */
  7362. readonly minimum: Vector3;
  7363. /**
  7364. * max vector of the bounding box/sphere
  7365. */
  7366. readonly maximum: Vector3;
  7367. /**
  7368. * If the info is locked and won't be updated to avoid perf overhead
  7369. */
  7370. isLocked: boolean;
  7371. /**
  7372. * Updates the bounding sphere and box
  7373. * @param world world matrix to be used to update
  7374. */
  7375. update(world: DeepImmutable<Matrix>): void;
  7376. /**
  7377. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7378. * @param center New center of the bounding info
  7379. * @param extend New extend of the bounding info
  7380. * @returns the current bounding info
  7381. */
  7382. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7383. /**
  7384. * Scale the current bounding info by applying a scale factor
  7385. * @param factor defines the scale factor to apply
  7386. * @returns the current bounding info
  7387. */
  7388. scale(factor: number): BoundingInfo;
  7389. /**
  7390. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7391. * @param frustumPlanes defines the frustum to test
  7392. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7393. * @returns true if the bounding info is in the frustum planes
  7394. */
  7395. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7396. /**
  7397. * Gets the world distance between the min and max points of the bounding box
  7398. */
  7399. readonly diagonalLength: number;
  7400. /**
  7401. * Checks if a cullable object (mesh...) is in the camera frustum
  7402. * Unlike isInFrustum this cheks the full bounding box
  7403. * @param frustumPlanes Camera near/planes
  7404. * @returns true if the object is in frustum otherwise false
  7405. */
  7406. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7407. /** @hidden */
  7408. _checkCollision(collider: Collider): boolean;
  7409. /**
  7410. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7411. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7412. * @param point the point to check intersection with
  7413. * @returns if the point intersects
  7414. */
  7415. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7416. /**
  7417. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7418. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7419. * @param boundingInfo the bounding info to check intersection with
  7420. * @param precise if the intersection should be done using OBB
  7421. * @returns if the bounding info intersects
  7422. */
  7423. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7424. }
  7425. }
  7426. declare module BABYLON {
  7427. /**
  7428. * Defines an array and its length.
  7429. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7430. */
  7431. export interface ISmartArrayLike<T> {
  7432. /**
  7433. * The data of the array.
  7434. */
  7435. data: Array<T>;
  7436. /**
  7437. * The active length of the array.
  7438. */
  7439. length: number;
  7440. }
  7441. /**
  7442. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7443. */
  7444. export class SmartArray<T> implements ISmartArrayLike<T> {
  7445. /**
  7446. * The full set of data from the array.
  7447. */
  7448. data: Array<T>;
  7449. /**
  7450. * The active length of the array.
  7451. */
  7452. length: number;
  7453. protected _id: number;
  7454. /**
  7455. * Instantiates a Smart Array.
  7456. * @param capacity defines the default capacity of the array.
  7457. */
  7458. constructor(capacity: number);
  7459. /**
  7460. * Pushes a value at the end of the active data.
  7461. * @param value defines the object to push in the array.
  7462. */
  7463. push(value: T): void;
  7464. /**
  7465. * Iterates over the active data and apply the lambda to them.
  7466. * @param func defines the action to apply on each value.
  7467. */
  7468. forEach(func: (content: T) => void): void;
  7469. /**
  7470. * Sorts the full sets of data.
  7471. * @param compareFn defines the comparison function to apply.
  7472. */
  7473. sort(compareFn: (a: T, b: T) => number): void;
  7474. /**
  7475. * Resets the active data to an empty array.
  7476. */
  7477. reset(): void;
  7478. /**
  7479. * Releases all the data from the array as well as the array.
  7480. */
  7481. dispose(): void;
  7482. /**
  7483. * Concats the active data with a given array.
  7484. * @param array defines the data to concatenate with.
  7485. */
  7486. concat(array: any): void;
  7487. /**
  7488. * Returns the position of a value in the active data.
  7489. * @param value defines the value to find the index for
  7490. * @returns the index if found in the active data otherwise -1
  7491. */
  7492. indexOf(value: T): number;
  7493. /**
  7494. * Returns whether an element is part of the active data.
  7495. * @param value defines the value to look for
  7496. * @returns true if found in the active data otherwise false
  7497. */
  7498. contains(value: T): boolean;
  7499. private static _GlobalId;
  7500. }
  7501. /**
  7502. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7503. * The data in this array can only be present once
  7504. */
  7505. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7506. private _duplicateId;
  7507. /**
  7508. * Pushes a value at the end of the active data.
  7509. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7510. * @param value defines the object to push in the array.
  7511. */
  7512. push(value: T): void;
  7513. /**
  7514. * Pushes a value at the end of the active data.
  7515. * If the data is already present, it won t be added again
  7516. * @param value defines the object to push in the array.
  7517. * @returns true if added false if it was already present
  7518. */
  7519. pushNoDuplicate(value: T): boolean;
  7520. /**
  7521. * Resets the active data to an empty array.
  7522. */
  7523. reset(): void;
  7524. /**
  7525. * Concats the active data with a given array.
  7526. * This ensures no dupplicate will be present in the result.
  7527. * @param array defines the data to concatenate with.
  7528. */
  7529. concatWithNoDuplicate(array: any): void;
  7530. }
  7531. }
  7532. declare module BABYLON {
  7533. /**
  7534. * Class for creating a cube texture
  7535. */
  7536. export class CubeTexture extends BaseTexture {
  7537. private _delayedOnLoad;
  7538. /**
  7539. * The url of the texture
  7540. */
  7541. url: string;
  7542. /**
  7543. * Gets or sets the center of the bounding box associated with the cube texture.
  7544. * It must define where the camera used to render the texture was set
  7545. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7546. */
  7547. boundingBoxPosition: Vector3;
  7548. private _boundingBoxSize;
  7549. /**
  7550. * Gets or sets the size of the bounding box associated with the cube texture
  7551. * When defined, the cubemap will switch to local mode
  7552. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7553. * @example https://www.babylonjs-playground.com/#RNASML
  7554. */
  7555. /**
  7556. * Returns the bounding box size
  7557. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7558. */
  7559. boundingBoxSize: Vector3;
  7560. protected _rotationY: number;
  7561. /**
  7562. * Sets texture matrix rotation angle around Y axis in radians.
  7563. */
  7564. /**
  7565. * Gets texture matrix rotation angle around Y axis radians.
  7566. */
  7567. rotationY: number;
  7568. /**
  7569. * Are mip maps generated for this texture or not.
  7570. */
  7571. readonly noMipmap: boolean;
  7572. private _noMipmap;
  7573. private _files;
  7574. private _extensions;
  7575. private _textureMatrix;
  7576. private _format;
  7577. private _createPolynomials;
  7578. /** @hidden */
  7579. _prefiltered: boolean;
  7580. /**
  7581. * Creates a cube texture from an array of image urls
  7582. * @param files defines an array of image urls
  7583. * @param scene defines the hosting scene
  7584. * @param noMipmap specifies if mip maps are not used
  7585. * @returns a cube texture
  7586. */
  7587. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7588. /**
  7589. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7590. * @param url defines the url of the prefiltered texture
  7591. * @param scene defines the scene the texture is attached to
  7592. * @param forcedExtension defines the extension of the file if different from the url
  7593. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7594. * @return the prefiltered texture
  7595. */
  7596. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7597. /**
  7598. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7599. * as prefiltered data.
  7600. * @param rootUrl defines the url of the texture or the root name of the six images
  7601. * @param scene defines the scene the texture is attached to
  7602. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7603. * @param noMipmap defines if mipmaps should be created or not
  7604. * @param files defines the six files to load for the different faces
  7605. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7606. * @param onError defines a callback triggered in case of error during load
  7607. * @param format defines the internal format to use for the texture once loaded
  7608. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7609. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7610. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7611. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7612. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7613. * @return the cube texture
  7614. */
  7615. 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);
  7616. /**
  7617. * Get the current class name of the texture useful for serialization or dynamic coding.
  7618. * @returns "CubeTexture"
  7619. */
  7620. getClassName(): string;
  7621. /**
  7622. * Update the url (and optional buffer) of this texture if url was null during construction.
  7623. * @param url the url of the texture
  7624. * @param forcedExtension defines the extension to use
  7625. * @param onLoad callback called when the texture is loaded (defaults to null)
  7626. */
  7627. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7628. /**
  7629. * Delays loading of the cube texture
  7630. * @param forcedExtension defines the extension to use
  7631. */
  7632. delayLoad(forcedExtension?: string): void;
  7633. /**
  7634. * Returns the reflection texture matrix
  7635. * @returns the reflection texture matrix
  7636. */
  7637. getReflectionTextureMatrix(): Matrix;
  7638. /**
  7639. * Sets the reflection texture matrix
  7640. * @param value Reflection texture matrix
  7641. */
  7642. setReflectionTextureMatrix(value: Matrix): void;
  7643. /**
  7644. * Parses text to create a cube texture
  7645. * @param parsedTexture define the serialized text to read from
  7646. * @param scene defines the hosting scene
  7647. * @param rootUrl defines the root url of the cube texture
  7648. * @returns a cube texture
  7649. */
  7650. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7651. /**
  7652. * Makes a clone, or deep copy, of the cube texture
  7653. * @returns a new cube texture
  7654. */
  7655. clone(): CubeTexture;
  7656. }
  7657. }
  7658. declare module BABYLON {
  7659. /** @hidden */
  7660. export var postprocessVertexShader: {
  7661. name: string;
  7662. shader: string;
  7663. };
  7664. }
  7665. declare module BABYLON {
  7666. /**
  7667. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7668. * This is the base of the follow, arc rotate cameras and Free camera
  7669. * @see http://doc.babylonjs.com/features/cameras
  7670. */
  7671. export class TargetCamera extends Camera {
  7672. private static _RigCamTransformMatrix;
  7673. private static _TargetTransformMatrix;
  7674. private static _TargetFocalPoint;
  7675. /**
  7676. * Define the current direction the camera is moving to
  7677. */
  7678. cameraDirection: Vector3;
  7679. /**
  7680. * Define the current rotation the camera is rotating to
  7681. */
  7682. cameraRotation: Vector2;
  7683. /**
  7684. * When set, the up vector of the camera will be updated by the rotation of the camera
  7685. */
  7686. updateUpVectorFromRotation: boolean;
  7687. private _tmpQuaternion;
  7688. /**
  7689. * Define the current rotation of the camera
  7690. */
  7691. rotation: Vector3;
  7692. /**
  7693. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7694. */
  7695. rotationQuaternion: Quaternion;
  7696. /**
  7697. * Define the current speed of the camera
  7698. */
  7699. speed: number;
  7700. /**
  7701. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7702. * around all axis.
  7703. */
  7704. noRotationConstraint: boolean;
  7705. /**
  7706. * Define the current target of the camera as an object or a position.
  7707. */
  7708. lockedTarget: any;
  7709. /** @hidden */
  7710. _currentTarget: Vector3;
  7711. /** @hidden */
  7712. _initialFocalDistance: number;
  7713. /** @hidden */
  7714. _viewMatrix: Matrix;
  7715. /** @hidden */
  7716. _camMatrix: Matrix;
  7717. /** @hidden */
  7718. _cameraTransformMatrix: Matrix;
  7719. /** @hidden */
  7720. _cameraRotationMatrix: Matrix;
  7721. /** @hidden */
  7722. _referencePoint: Vector3;
  7723. /** @hidden */
  7724. _transformedReferencePoint: Vector3;
  7725. protected _globalCurrentTarget: Vector3;
  7726. protected _globalCurrentUpVector: Vector3;
  7727. /** @hidden */
  7728. _reset: () => void;
  7729. private _defaultUp;
  7730. /**
  7731. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  7732. * This is the base of the follow, arc rotate cameras and Free camera
  7733. * @see http://doc.babylonjs.com/features/cameras
  7734. * @param name Defines the name of the camera in the scene
  7735. * @param position Defines the start position of the camera in the scene
  7736. * @param scene Defines the scene the camera belongs to
  7737. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7738. */
  7739. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7740. /**
  7741. * Gets the position in front of the camera at a given distance.
  7742. * @param distance The distance from the camera we want the position to be
  7743. * @returns the position
  7744. */
  7745. getFrontPosition(distance: number): Vector3;
  7746. /** @hidden */
  7747. _getLockedTargetPosition(): Nullable<Vector3>;
  7748. private _storedPosition;
  7749. private _storedRotation;
  7750. private _storedRotationQuaternion;
  7751. /**
  7752. * Store current camera state of the camera (fov, position, rotation, etc..)
  7753. * @returns the camera
  7754. */
  7755. storeState(): Camera;
  7756. /**
  7757. * Restored camera state. You must call storeState() first
  7758. * @returns whether it was successful or not
  7759. * @hidden
  7760. */
  7761. _restoreStateValues(): boolean;
  7762. /** @hidden */
  7763. _initCache(): void;
  7764. /** @hidden */
  7765. _updateCache(ignoreParentClass?: boolean): void;
  7766. /** @hidden */
  7767. _isSynchronizedViewMatrix(): boolean;
  7768. /** @hidden */
  7769. _computeLocalCameraSpeed(): number;
  7770. /** @hidden */
  7771. setTarget(target: Vector3): void;
  7772. /**
  7773. * Return the current target position of the camera. This value is expressed in local space.
  7774. * @returns the target position
  7775. */
  7776. getTarget(): Vector3;
  7777. /** @hidden */
  7778. _decideIfNeedsToMove(): boolean;
  7779. /** @hidden */
  7780. _updatePosition(): void;
  7781. /** @hidden */
  7782. _checkInputs(): void;
  7783. protected _updateCameraRotationMatrix(): void;
  7784. /**
  7785. * 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)
  7786. * @returns the current camera
  7787. */
  7788. private _rotateUpVectorWithCameraRotationMatrix;
  7789. private _cachedRotationZ;
  7790. private _cachedQuaternionRotationZ;
  7791. /** @hidden */
  7792. _getViewMatrix(): Matrix;
  7793. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  7794. /**
  7795. * @hidden
  7796. */
  7797. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7798. /**
  7799. * @hidden
  7800. */
  7801. _updateRigCameras(): void;
  7802. private _getRigCamPositionAndTarget;
  7803. /**
  7804. * Gets the current object class name.
  7805. * @return the class name
  7806. */
  7807. getClassName(): string;
  7808. }
  7809. }
  7810. declare module BABYLON {
  7811. /**
  7812. * @ignore
  7813. * This is a list of all the different input types that are available in the application.
  7814. * Fo instance: ArcRotateCameraGamepadInput...
  7815. */
  7816. export var CameraInputTypes: {};
  7817. /**
  7818. * This is the contract to implement in order to create a new input class.
  7819. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7820. */
  7821. export interface ICameraInput<TCamera extends Camera> {
  7822. /**
  7823. * Defines the camera the input is attached to.
  7824. */
  7825. camera: Nullable<TCamera>;
  7826. /**
  7827. * Gets the class name of the current intput.
  7828. * @returns the class name
  7829. */
  7830. getClassName(): string;
  7831. /**
  7832. * Get the friendly name associated with the input class.
  7833. * @returns the input friendly name
  7834. */
  7835. getSimpleName(): string;
  7836. /**
  7837. * Attach the input controls to a specific dom element to get the input from.
  7838. * @param element Defines the element the controls should be listened from
  7839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7840. */
  7841. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7842. /**
  7843. * Detach the current controls from the specified dom element.
  7844. * @param element Defines the element to stop listening the inputs from
  7845. */
  7846. detachControl(element: Nullable<HTMLElement>): void;
  7847. /**
  7848. * Update the current camera state depending on the inputs that have been used this frame.
  7849. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7850. */
  7851. checkInputs?: () => void;
  7852. }
  7853. /**
  7854. * Represents a map of input types to input instance or input index to input instance.
  7855. */
  7856. export interface CameraInputsMap<TCamera extends Camera> {
  7857. /**
  7858. * Accessor to the input by input type.
  7859. */
  7860. [name: string]: ICameraInput<TCamera>;
  7861. /**
  7862. * Accessor to the input by input index.
  7863. */
  7864. [idx: number]: ICameraInput<TCamera>;
  7865. }
  7866. /**
  7867. * This represents the input manager used within a camera.
  7868. * It helps dealing with all the different kind of input attached to a camera.
  7869. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7870. */
  7871. export class CameraInputsManager<TCamera extends Camera> {
  7872. /**
  7873. * Defines the list of inputs attahed to the camera.
  7874. */
  7875. attached: CameraInputsMap<TCamera>;
  7876. /**
  7877. * Defines the dom element the camera is collecting inputs from.
  7878. * This is null if the controls have not been attached.
  7879. */
  7880. attachedElement: Nullable<HTMLElement>;
  7881. /**
  7882. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7883. */
  7884. noPreventDefault: boolean;
  7885. /**
  7886. * Defined the camera the input manager belongs to.
  7887. */
  7888. camera: TCamera;
  7889. /**
  7890. * Update the current camera state depending on the inputs that have been used this frame.
  7891. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7892. */
  7893. checkInputs: () => void;
  7894. /**
  7895. * Instantiate a new Camera Input Manager.
  7896. * @param camera Defines the camera the input manager blongs to
  7897. */
  7898. constructor(camera: TCamera);
  7899. /**
  7900. * Add an input method to a camera
  7901. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7902. * @param input camera input method
  7903. */
  7904. add(input: ICameraInput<TCamera>): void;
  7905. /**
  7906. * Remove a specific input method from a camera
  7907. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  7908. * @param inputToRemove camera input method
  7909. */
  7910. remove(inputToRemove: ICameraInput<TCamera>): void;
  7911. /**
  7912. * Remove a specific input type from a camera
  7913. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  7914. * @param inputType the type of the input to remove
  7915. */
  7916. removeByType(inputType: string): void;
  7917. private _addCheckInputs;
  7918. /**
  7919. * Attach the input controls to the currently attached dom element to listen the events from.
  7920. * @param input Defines the input to attach
  7921. */
  7922. attachInput(input: ICameraInput<TCamera>): void;
  7923. /**
  7924. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  7925. * @param element Defines the dom element to collect the events from
  7926. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7927. */
  7928. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  7929. /**
  7930. * Detach the current manager inputs controls from a specific dom element.
  7931. * @param element Defines the dom element to collect the events from
  7932. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  7933. */
  7934. detachElement(element: HTMLElement, disconnect?: boolean): void;
  7935. /**
  7936. * Rebuild the dynamic inputCheck function from the current list of
  7937. * defined inputs in the manager.
  7938. */
  7939. rebuildInputCheck(): void;
  7940. /**
  7941. * Remove all attached input methods from a camera
  7942. */
  7943. clear(): void;
  7944. /**
  7945. * Serialize the current input manager attached to a camera.
  7946. * This ensures than once parsed,
  7947. * the input associated to the camera will be identical to the current ones
  7948. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  7949. */
  7950. serialize(serializedCamera: any): void;
  7951. /**
  7952. * Parses an input manager serialized JSON to restore the previous list of inputs
  7953. * and states associated to a camera.
  7954. * @param parsedCamera Defines the JSON to parse
  7955. */
  7956. parse(parsedCamera: any): void;
  7957. }
  7958. }
  7959. declare module BABYLON {
  7960. /**
  7961. * Gather the list of keyboard event types as constants.
  7962. */
  7963. export class KeyboardEventTypes {
  7964. /**
  7965. * The keydown event is fired when a key becomes active (pressed).
  7966. */
  7967. static readonly KEYDOWN: number;
  7968. /**
  7969. * The keyup event is fired when a key has been released.
  7970. */
  7971. static readonly KEYUP: number;
  7972. }
  7973. /**
  7974. * This class is used to store keyboard related info for the onKeyboardObservable event.
  7975. */
  7976. export class KeyboardInfo {
  7977. /**
  7978. * Defines the type of event (KeyboardEventTypes)
  7979. */
  7980. type: number;
  7981. /**
  7982. * Defines the related dom event
  7983. */
  7984. event: KeyboardEvent;
  7985. /**
  7986. * Instantiates a new keyboard info.
  7987. * This class is used to store keyboard related info for the onKeyboardObservable event.
  7988. * @param type Defines the type of event (KeyboardEventTypes)
  7989. * @param event Defines the related dom event
  7990. */
  7991. constructor(
  7992. /**
  7993. * Defines the type of event (KeyboardEventTypes)
  7994. */
  7995. type: number,
  7996. /**
  7997. * Defines the related dom event
  7998. */
  7999. event: KeyboardEvent);
  8000. }
  8001. /**
  8002. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8003. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8004. */
  8005. export class KeyboardInfoPre extends KeyboardInfo {
  8006. /**
  8007. * Defines the type of event (KeyboardEventTypes)
  8008. */
  8009. type: number;
  8010. /**
  8011. * Defines the related dom event
  8012. */
  8013. event: KeyboardEvent;
  8014. /**
  8015. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8016. */
  8017. skipOnPointerObservable: boolean;
  8018. /**
  8019. * Instantiates a new keyboard pre info.
  8020. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8021. * @param type Defines the type of event (KeyboardEventTypes)
  8022. * @param event Defines the related dom event
  8023. */
  8024. constructor(
  8025. /**
  8026. * Defines the type of event (KeyboardEventTypes)
  8027. */
  8028. type: number,
  8029. /**
  8030. * Defines the related dom event
  8031. */
  8032. event: KeyboardEvent);
  8033. }
  8034. }
  8035. declare module BABYLON {
  8036. /**
  8037. * Manage the keyboard inputs to control the movement of a free camera.
  8038. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8039. */
  8040. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8041. /**
  8042. * Defines the camera the input is attached to.
  8043. */
  8044. camera: FreeCamera;
  8045. /**
  8046. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8047. */
  8048. keysUp: number[];
  8049. /**
  8050. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8051. */
  8052. keysDown: number[];
  8053. /**
  8054. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8055. */
  8056. keysLeft: number[];
  8057. /**
  8058. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8059. */
  8060. keysRight: number[];
  8061. private _keys;
  8062. private _onCanvasBlurObserver;
  8063. private _onKeyboardObserver;
  8064. private _engine;
  8065. private _scene;
  8066. /**
  8067. * Attach the input controls to a specific dom element to get the input from.
  8068. * @param element Defines the element the controls should be listened from
  8069. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8070. */
  8071. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8072. /**
  8073. * Detach the current controls from the specified dom element.
  8074. * @param element Defines the element to stop listening the inputs from
  8075. */
  8076. detachControl(element: Nullable<HTMLElement>): void;
  8077. /**
  8078. * Update the current camera state depending on the inputs that have been used this frame.
  8079. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8080. */
  8081. checkInputs(): void;
  8082. /**
  8083. * Gets the class name of the current intput.
  8084. * @returns the class name
  8085. */
  8086. getClassName(): string;
  8087. /** @hidden */
  8088. _onLostFocus(): void;
  8089. /**
  8090. * Get the friendly name associated with the input class.
  8091. * @returns the input friendly name
  8092. */
  8093. getSimpleName(): string;
  8094. }
  8095. }
  8096. declare module BABYLON {
  8097. /**
  8098. * Gather the list of pointer event types as constants.
  8099. */
  8100. export class PointerEventTypes {
  8101. /**
  8102. * 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.
  8103. */
  8104. static readonly POINTERDOWN: number;
  8105. /**
  8106. * The pointerup event is fired when a pointer is no longer active.
  8107. */
  8108. static readonly POINTERUP: number;
  8109. /**
  8110. * The pointermove event is fired when a pointer changes coordinates.
  8111. */
  8112. static readonly POINTERMOVE: number;
  8113. /**
  8114. * The pointerwheel event is fired when a mouse wheel has been rotated.
  8115. */
  8116. static readonly POINTERWHEEL: number;
  8117. /**
  8118. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  8119. */
  8120. static readonly POINTERPICK: number;
  8121. /**
  8122. * The pointertap event is fired when a the object has been touched and released without drag.
  8123. */
  8124. static readonly POINTERTAP: number;
  8125. /**
  8126. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  8127. */
  8128. static readonly POINTERDOUBLETAP: number;
  8129. }
  8130. /**
  8131. * Base class of pointer info types.
  8132. */
  8133. export class PointerInfoBase {
  8134. /**
  8135. * Defines the type of event (PointerEventTypes)
  8136. */
  8137. type: number;
  8138. /**
  8139. * Defines the related dom event
  8140. */
  8141. event: PointerEvent | MouseWheelEvent;
  8142. /**
  8143. * Instantiates the base class of pointers info.
  8144. * @param type Defines the type of event (PointerEventTypes)
  8145. * @param event Defines the related dom event
  8146. */
  8147. constructor(
  8148. /**
  8149. * Defines the type of event (PointerEventTypes)
  8150. */
  8151. type: number,
  8152. /**
  8153. * Defines the related dom event
  8154. */
  8155. event: PointerEvent | MouseWheelEvent);
  8156. }
  8157. /**
  8158. * This class is used to store pointer related info for the onPrePointerObservable event.
  8159. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  8160. */
  8161. export class PointerInfoPre extends PointerInfoBase {
  8162. /**
  8163. * Ray from a pointer if availible (eg. 6dof controller)
  8164. */
  8165. ray: Nullable<Ray>;
  8166. /**
  8167. * Defines the local position of the pointer on the canvas.
  8168. */
  8169. localPosition: Vector2;
  8170. /**
  8171. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  8172. */
  8173. skipOnPointerObservable: boolean;
  8174. /**
  8175. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  8176. * @param type Defines the type of event (PointerEventTypes)
  8177. * @param event Defines the related dom event
  8178. * @param localX Defines the local x coordinates of the pointer when the event occured
  8179. * @param localY Defines the local y coordinates of the pointer when the event occured
  8180. */
  8181. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  8182. }
  8183. /**
  8184. * This type contains all the data related to a pointer event in Babylon.js.
  8185. * 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.
  8186. */
  8187. export class PointerInfo extends PointerInfoBase {
  8188. /**
  8189. * Defines the picking info associated to the info (if any)\
  8190. */
  8191. pickInfo: Nullable<PickingInfo>;
  8192. /**
  8193. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  8194. * @param type Defines the type of event (PointerEventTypes)
  8195. * @param event Defines the related dom event
  8196. * @param pickInfo Defines the picking info associated to the info (if any)\
  8197. */
  8198. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  8199. /**
  8200. * Defines the picking info associated to the info (if any)\
  8201. */
  8202. pickInfo: Nullable<PickingInfo>);
  8203. }
  8204. }
  8205. declare module BABYLON {
  8206. /**
  8207. * Manage the mouse inputs to control the movement of a free camera.
  8208. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8209. */
  8210. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  8211. /**
  8212. * Define if touch is enabled in the mouse input
  8213. */
  8214. touchEnabled: boolean;
  8215. /**
  8216. * Defines the camera the input is attached to.
  8217. */
  8218. camera: FreeCamera;
  8219. /**
  8220. * Defines the buttons associated with the input to handle camera move.
  8221. */
  8222. buttons: number[];
  8223. /**
  8224. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  8225. */
  8226. angularSensibility: number;
  8227. private _pointerInput;
  8228. private _onMouseMove;
  8229. private _observer;
  8230. private previousPosition;
  8231. /**
  8232. * Manage the mouse inputs to control the movement of a free camera.
  8233. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8234. * @param touchEnabled Defines if touch is enabled or not
  8235. */
  8236. constructor(
  8237. /**
  8238. * Define if touch is enabled in the mouse input
  8239. */
  8240. touchEnabled?: boolean);
  8241. /**
  8242. * Attach the input controls to a specific dom element to get the input from.
  8243. * @param element Defines the element the controls should be listened from
  8244. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8245. */
  8246. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8247. /**
  8248. * Detach the current controls from the specified dom element.
  8249. * @param element Defines the element to stop listening the inputs from
  8250. */
  8251. detachControl(element: Nullable<HTMLElement>): void;
  8252. /**
  8253. * Gets the class name of the current intput.
  8254. * @returns the class name
  8255. */
  8256. getClassName(): string;
  8257. /**
  8258. * Get the friendly name associated with the input class.
  8259. * @returns the input friendly name
  8260. */
  8261. getSimpleName(): string;
  8262. }
  8263. }
  8264. declare module BABYLON {
  8265. /**
  8266. * Manage the touch inputs to control the movement of a free camera.
  8267. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8268. */
  8269. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  8270. /**
  8271. * Defines the camera the input is attached to.
  8272. */
  8273. camera: FreeCamera;
  8274. /**
  8275. * Defines the touch sensibility for rotation.
  8276. * The higher the faster.
  8277. */
  8278. touchAngularSensibility: number;
  8279. /**
  8280. * Defines the touch sensibility for move.
  8281. * The higher the faster.
  8282. */
  8283. touchMoveSensibility: number;
  8284. private _offsetX;
  8285. private _offsetY;
  8286. private _pointerPressed;
  8287. private _pointerInput;
  8288. private _observer;
  8289. private _onLostFocus;
  8290. /**
  8291. * Attach the input controls to a specific dom element to get the input from.
  8292. * @param element Defines the element the controls should be listened from
  8293. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8294. */
  8295. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8296. /**
  8297. * Detach the current controls from the specified dom element.
  8298. * @param element Defines the element to stop listening the inputs from
  8299. */
  8300. detachControl(element: Nullable<HTMLElement>): void;
  8301. /**
  8302. * Update the current camera state depending on the inputs that have been used this frame.
  8303. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8304. */
  8305. checkInputs(): void;
  8306. /**
  8307. * Gets the class name of the current intput.
  8308. * @returns the class name
  8309. */
  8310. getClassName(): string;
  8311. /**
  8312. * Get the friendly name associated with the input class.
  8313. * @returns the input friendly name
  8314. */
  8315. getSimpleName(): string;
  8316. }
  8317. }
  8318. declare module BABYLON {
  8319. /**
  8320. * Default Inputs manager for the FreeCamera.
  8321. * It groups all the default supported inputs for ease of use.
  8322. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8323. */
  8324. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8325. /**
  8326. * Instantiates a new FreeCameraInputsManager.
  8327. * @param camera Defines the camera the inputs belong to
  8328. */
  8329. constructor(camera: FreeCamera);
  8330. /**
  8331. * Add keyboard input support to the input manager.
  8332. * @returns the current input manager
  8333. */
  8334. addKeyboard(): FreeCameraInputsManager;
  8335. /**
  8336. * Add mouse input support to the input manager.
  8337. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8338. * @returns the current input manager
  8339. */
  8340. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8341. /**
  8342. * Add touch input support to the input manager.
  8343. * @returns the current input manager
  8344. */
  8345. addTouch(): FreeCameraInputsManager;
  8346. }
  8347. }
  8348. declare module BABYLON {
  8349. /**
  8350. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8351. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8352. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8353. */
  8354. export class FreeCamera extends TargetCamera {
  8355. /**
  8356. * Define the collision ellipsoid of the camera.
  8357. * This is helpful to simulate a camera body like the player body around the camera
  8358. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8359. */
  8360. ellipsoid: Vector3;
  8361. /**
  8362. * Define an offset for the position of the ellipsoid around the camera.
  8363. * This can be helpful to determine the center of the body near the gravity center of the body
  8364. * instead of its head.
  8365. */
  8366. ellipsoidOffset: Vector3;
  8367. /**
  8368. * Enable or disable collisions of the camera with the rest of the scene objects.
  8369. */
  8370. checkCollisions: boolean;
  8371. /**
  8372. * Enable or disable gravity on the camera.
  8373. */
  8374. applyGravity: boolean;
  8375. /**
  8376. * Define the input manager associated to the camera.
  8377. */
  8378. inputs: FreeCameraInputsManager;
  8379. /**
  8380. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8381. * Higher values reduce sensitivity.
  8382. */
  8383. /**
  8384. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8385. * Higher values reduce sensitivity.
  8386. */
  8387. angularSensibility: number;
  8388. /**
  8389. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8390. */
  8391. keysUp: number[];
  8392. /**
  8393. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8394. */
  8395. keysDown: number[];
  8396. /**
  8397. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8398. */
  8399. keysLeft: number[];
  8400. /**
  8401. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8402. */
  8403. keysRight: number[];
  8404. /**
  8405. * Event raised when the camera collide with a mesh in the scene.
  8406. */
  8407. onCollide: (collidedMesh: AbstractMesh) => void;
  8408. private _collider;
  8409. private _needMoveForGravity;
  8410. private _oldPosition;
  8411. private _diffPosition;
  8412. private _newPosition;
  8413. /** @hidden */
  8414. _localDirection: Vector3;
  8415. /** @hidden */
  8416. _transformedDirection: Vector3;
  8417. /**
  8418. * Instantiates a Free Camera.
  8419. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8420. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8421. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8422. * @param name Define the name of the camera in the scene
  8423. * @param position Define the start position of the camera in the scene
  8424. * @param scene Define the scene the camera belongs to
  8425. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8426. */
  8427. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8428. /**
  8429. * Attached controls to the current camera.
  8430. * @param element Defines the element the controls should be listened from
  8431. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8432. */
  8433. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8434. /**
  8435. * Detach the current controls from the camera.
  8436. * The camera will stop reacting to inputs.
  8437. * @param element Defines the element to stop listening the inputs from
  8438. */
  8439. detachControl(element: HTMLElement): void;
  8440. private _collisionMask;
  8441. /**
  8442. * Define a collision mask to limit the list of object the camera can collide with
  8443. */
  8444. collisionMask: number;
  8445. /** @hidden */
  8446. _collideWithWorld(displacement: Vector3): void;
  8447. private _onCollisionPositionChange;
  8448. /** @hidden */
  8449. _checkInputs(): void;
  8450. /** @hidden */
  8451. _decideIfNeedsToMove(): boolean;
  8452. /** @hidden */
  8453. _updatePosition(): void;
  8454. /**
  8455. * Destroy the camera and release the current resources hold by it.
  8456. */
  8457. dispose(): void;
  8458. /**
  8459. * Gets the current object class name.
  8460. * @return the class name
  8461. */
  8462. getClassName(): string;
  8463. }
  8464. }
  8465. declare module BABYLON {
  8466. /**
  8467. * Represents a gamepad control stick position
  8468. */
  8469. export class StickValues {
  8470. /**
  8471. * The x component of the control stick
  8472. */
  8473. x: number;
  8474. /**
  8475. * The y component of the control stick
  8476. */
  8477. y: number;
  8478. /**
  8479. * Initializes the gamepad x and y control stick values
  8480. * @param x The x component of the gamepad control stick value
  8481. * @param y The y component of the gamepad control stick value
  8482. */
  8483. constructor(
  8484. /**
  8485. * The x component of the control stick
  8486. */
  8487. x: number,
  8488. /**
  8489. * The y component of the control stick
  8490. */
  8491. y: number);
  8492. }
  8493. /**
  8494. * An interface which manages callbacks for gamepad button changes
  8495. */
  8496. export interface GamepadButtonChanges {
  8497. /**
  8498. * Called when a gamepad has been changed
  8499. */
  8500. changed: boolean;
  8501. /**
  8502. * Called when a gamepad press event has been triggered
  8503. */
  8504. pressChanged: boolean;
  8505. /**
  8506. * Called when a touch event has been triggered
  8507. */
  8508. touchChanged: boolean;
  8509. /**
  8510. * Called when a value has changed
  8511. */
  8512. valueChanged: boolean;
  8513. }
  8514. /**
  8515. * Represents a gamepad
  8516. */
  8517. export class Gamepad {
  8518. /**
  8519. * The id of the gamepad
  8520. */
  8521. id: string;
  8522. /**
  8523. * The index of the gamepad
  8524. */
  8525. index: number;
  8526. /**
  8527. * The browser gamepad
  8528. */
  8529. browserGamepad: any;
  8530. /**
  8531. * Specifies what type of gamepad this represents
  8532. */
  8533. type: number;
  8534. private _leftStick;
  8535. private _rightStick;
  8536. /** @hidden */
  8537. _isConnected: boolean;
  8538. private _leftStickAxisX;
  8539. private _leftStickAxisY;
  8540. private _rightStickAxisX;
  8541. private _rightStickAxisY;
  8542. /**
  8543. * Triggered when the left control stick has been changed
  8544. */
  8545. private _onleftstickchanged;
  8546. /**
  8547. * Triggered when the right control stick has been changed
  8548. */
  8549. private _onrightstickchanged;
  8550. /**
  8551. * Represents a gamepad controller
  8552. */
  8553. static GAMEPAD: number;
  8554. /**
  8555. * Represents a generic controller
  8556. */
  8557. static GENERIC: number;
  8558. /**
  8559. * Represents an XBox controller
  8560. */
  8561. static XBOX: number;
  8562. /**
  8563. * Represents a pose-enabled controller
  8564. */
  8565. static POSE_ENABLED: number;
  8566. /**
  8567. * Specifies whether the left control stick should be Y-inverted
  8568. */
  8569. protected _invertLeftStickY: boolean;
  8570. /**
  8571. * Specifies if the gamepad has been connected
  8572. */
  8573. readonly isConnected: boolean;
  8574. /**
  8575. * Initializes the gamepad
  8576. * @param id The id of the gamepad
  8577. * @param index The index of the gamepad
  8578. * @param browserGamepad The browser gamepad
  8579. * @param leftStickX The x component of the left joystick
  8580. * @param leftStickY The y component of the left joystick
  8581. * @param rightStickX The x component of the right joystick
  8582. * @param rightStickY The y component of the right joystick
  8583. */
  8584. constructor(
  8585. /**
  8586. * The id of the gamepad
  8587. */
  8588. id: string,
  8589. /**
  8590. * The index of the gamepad
  8591. */
  8592. index: number,
  8593. /**
  8594. * The browser gamepad
  8595. */
  8596. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  8597. /**
  8598. * Callback triggered when the left joystick has changed
  8599. * @param callback
  8600. */
  8601. onleftstickchanged(callback: (values: StickValues) => void): void;
  8602. /**
  8603. * Callback triggered when the right joystick has changed
  8604. * @param callback
  8605. */
  8606. onrightstickchanged(callback: (values: StickValues) => void): void;
  8607. /**
  8608. * Gets the left joystick
  8609. */
  8610. /**
  8611. * Sets the left joystick values
  8612. */
  8613. leftStick: StickValues;
  8614. /**
  8615. * Gets the right joystick
  8616. */
  8617. /**
  8618. * Sets the right joystick value
  8619. */
  8620. rightStick: StickValues;
  8621. /**
  8622. * Updates the gamepad joystick positions
  8623. */
  8624. update(): void;
  8625. /**
  8626. * Disposes the gamepad
  8627. */
  8628. dispose(): void;
  8629. }
  8630. /**
  8631. * Represents a generic gamepad
  8632. */
  8633. export class GenericPad extends Gamepad {
  8634. private _buttons;
  8635. private _onbuttondown;
  8636. private _onbuttonup;
  8637. /**
  8638. * Observable triggered when a button has been pressed
  8639. */
  8640. onButtonDownObservable: Observable<number>;
  8641. /**
  8642. * Observable triggered when a button has been released
  8643. */
  8644. onButtonUpObservable: Observable<number>;
  8645. /**
  8646. * Callback triggered when a button has been pressed
  8647. * @param callback Called when a button has been pressed
  8648. */
  8649. onbuttondown(callback: (buttonPressed: number) => void): void;
  8650. /**
  8651. * Callback triggered when a button has been released
  8652. * @param callback Called when a button has been released
  8653. */
  8654. onbuttonup(callback: (buttonReleased: number) => void): void;
  8655. /**
  8656. * Initializes the generic gamepad
  8657. * @param id The id of the generic gamepad
  8658. * @param index The index of the generic gamepad
  8659. * @param browserGamepad The browser gamepad
  8660. */
  8661. constructor(id: string, index: number, browserGamepad: any);
  8662. private _setButtonValue;
  8663. /**
  8664. * Updates the generic gamepad
  8665. */
  8666. update(): void;
  8667. /**
  8668. * Disposes the generic gamepad
  8669. */
  8670. dispose(): void;
  8671. }
  8672. }
  8673. declare module BABYLON {
  8674. /**
  8675. * 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.
  8676. * @see https://doc.babylonjs.com/how_to/transformnode
  8677. */
  8678. export class TransformNode extends Node {
  8679. /**
  8680. * Object will not rotate to face the camera
  8681. */
  8682. static BILLBOARDMODE_NONE: number;
  8683. /**
  8684. * Object will rotate to face the camera but only on the x axis
  8685. */
  8686. static BILLBOARDMODE_X: number;
  8687. /**
  8688. * Object will rotate to face the camera but only on the y axis
  8689. */
  8690. static BILLBOARDMODE_Y: number;
  8691. /**
  8692. * Object will rotate to face the camera but only on the z axis
  8693. */
  8694. static BILLBOARDMODE_Z: number;
  8695. /**
  8696. * Object will rotate to face the camera
  8697. */
  8698. static BILLBOARDMODE_ALL: number;
  8699. private _forward;
  8700. private _forwardInverted;
  8701. private _up;
  8702. private _right;
  8703. private _rightInverted;
  8704. private _position;
  8705. private _rotation;
  8706. private _rotationQuaternion;
  8707. protected _scaling: Vector3;
  8708. protected _isDirty: boolean;
  8709. private _transformToBoneReferal;
  8710. /**
  8711. * Set the billboard mode. Default is 0.
  8712. *
  8713. * | Value | Type | Description |
  8714. * | --- | --- | --- |
  8715. * | 0 | BILLBOARDMODE_NONE | |
  8716. * | 1 | BILLBOARDMODE_X | |
  8717. * | 2 | BILLBOARDMODE_Y | |
  8718. * | 4 | BILLBOARDMODE_Z | |
  8719. * | 7 | BILLBOARDMODE_ALL | |
  8720. *
  8721. */
  8722. billboardMode: number;
  8723. /**
  8724. * 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
  8725. */
  8726. scalingDeterminant: number;
  8727. /**
  8728. * Sets the distance of the object to max, often used by skybox
  8729. */
  8730. infiniteDistance: boolean;
  8731. /**
  8732. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8733. * By default the system will update normals to compensate
  8734. */
  8735. ignoreNonUniformScaling: boolean;
  8736. /** @hidden */
  8737. _poseMatrix: Matrix;
  8738. /** @hidden */
  8739. _localMatrix: Matrix;
  8740. private _absolutePosition;
  8741. private _pivotMatrix;
  8742. private _pivotMatrixInverse;
  8743. protected _postMultiplyPivotMatrix: boolean;
  8744. protected _isWorldMatrixFrozen: boolean;
  8745. /** @hidden */
  8746. _indexInSceneTransformNodesArray: number;
  8747. /**
  8748. * An event triggered after the world matrix is updated
  8749. */
  8750. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8751. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8752. /**
  8753. * Gets a string identifying the name of the class
  8754. * @returns "TransformNode" string
  8755. */
  8756. getClassName(): string;
  8757. /**
  8758. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8759. */
  8760. position: Vector3;
  8761. /**
  8762. * 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)).
  8763. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8764. */
  8765. rotation: Vector3;
  8766. /**
  8767. * 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)).
  8768. */
  8769. scaling: Vector3;
  8770. /**
  8771. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  8772. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8773. */
  8774. rotationQuaternion: Nullable<Quaternion>;
  8775. /**
  8776. * The forward direction of that transform in world space.
  8777. */
  8778. readonly forward: Vector3;
  8779. /**
  8780. * The up direction of that transform in world space.
  8781. */
  8782. readonly up: Vector3;
  8783. /**
  8784. * The right direction of that transform in world space.
  8785. */
  8786. readonly right: Vector3;
  8787. /**
  8788. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8789. * @param matrix the matrix to copy the pose from
  8790. * @returns this TransformNode.
  8791. */
  8792. updatePoseMatrix(matrix: Matrix): TransformNode;
  8793. /**
  8794. * Returns the mesh Pose matrix.
  8795. * @returns the pose matrix
  8796. */
  8797. getPoseMatrix(): Matrix;
  8798. /** @hidden */
  8799. _isSynchronized(): boolean;
  8800. /** @hidden */
  8801. _initCache(): void;
  8802. /**
  8803. * Flag the transform node as dirty (Forcing it to update everything)
  8804. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8805. * @returns this transform node
  8806. */
  8807. markAsDirty(property: string): TransformNode;
  8808. /**
  8809. * Returns the current mesh absolute position.
  8810. * Returns a Vector3.
  8811. */
  8812. readonly absolutePosition: Vector3;
  8813. /**
  8814. * Sets a new matrix to apply before all other transformation
  8815. * @param matrix defines the transform matrix
  8816. * @returns the current TransformNode
  8817. */
  8818. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8819. /**
  8820. * Sets a new pivot matrix to the current node
  8821. * @param matrix defines the new pivot matrix to use
  8822. * @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
  8823. * @returns the current TransformNode
  8824. */
  8825. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8826. /**
  8827. * Returns the mesh pivot matrix.
  8828. * Default : Identity.
  8829. * @returns the matrix
  8830. */
  8831. getPivotMatrix(): Matrix;
  8832. /**
  8833. * Prevents the World matrix to be computed any longer.
  8834. * @returns the TransformNode.
  8835. */
  8836. freezeWorldMatrix(): TransformNode;
  8837. /**
  8838. * Allows back the World matrix computation.
  8839. * @returns the TransformNode.
  8840. */
  8841. unfreezeWorldMatrix(): this;
  8842. /**
  8843. * True if the World matrix has been frozen.
  8844. */
  8845. readonly isWorldMatrixFrozen: boolean;
  8846. /**
  8847. * Retuns the mesh absolute position in the World.
  8848. * @returns a Vector3.
  8849. */
  8850. getAbsolutePosition(): Vector3;
  8851. /**
  8852. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8853. * @param absolutePosition the absolute position to set
  8854. * @returns the TransformNode.
  8855. */
  8856. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8857. /**
  8858. * Sets the mesh position in its local space.
  8859. * @param vector3 the position to set in localspace
  8860. * @returns the TransformNode.
  8861. */
  8862. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8863. /**
  8864. * Returns the mesh position in the local space from the current World matrix values.
  8865. * @returns a new Vector3.
  8866. */
  8867. getPositionExpressedInLocalSpace(): Vector3;
  8868. /**
  8869. * Translates the mesh along the passed Vector3 in its local space.
  8870. * @param vector3 the distance to translate in localspace
  8871. * @returns the TransformNode.
  8872. */
  8873. locallyTranslate(vector3: Vector3): TransformNode;
  8874. private static _lookAtVectorCache;
  8875. /**
  8876. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8877. * @param targetPoint the position (must be in same space as current mesh) to look at
  8878. * @param yawCor optional yaw (y-axis) correction in radians
  8879. * @param pitchCor optional pitch (x-axis) correction in radians
  8880. * @param rollCor optional roll (z-axis) correction in radians
  8881. * @param space the choosen space of the target
  8882. * @returns the TransformNode.
  8883. */
  8884. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8885. /**
  8886. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8887. * This Vector3 is expressed in the World space.
  8888. * @param localAxis axis to rotate
  8889. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8890. */
  8891. getDirection(localAxis: Vector3): Vector3;
  8892. /**
  8893. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8894. * localAxis is expressed in the mesh local space.
  8895. * result is computed in the Wordl space from the mesh World matrix.
  8896. * @param localAxis axis to rotate
  8897. * @param result the resulting transformnode
  8898. * @returns this TransformNode.
  8899. */
  8900. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8901. /**
  8902. * Sets this transform node rotation to the given local axis.
  8903. * @param localAxis the axis in local space
  8904. * @param yawCor optional yaw (y-axis) correction in radians
  8905. * @param pitchCor optional pitch (x-axis) correction in radians
  8906. * @param rollCor optional roll (z-axis) correction in radians
  8907. * @returns this TransformNode
  8908. */
  8909. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8910. /**
  8911. * Sets a new pivot point to the current node
  8912. * @param point defines the new pivot point to use
  8913. * @param space defines if the point is in world or local space (local by default)
  8914. * @returns the current TransformNode
  8915. */
  8916. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8917. /**
  8918. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8919. * @returns the pivot point
  8920. */
  8921. getPivotPoint(): Vector3;
  8922. /**
  8923. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8924. * @param result the vector3 to store the result
  8925. * @returns this TransformNode.
  8926. */
  8927. getPivotPointToRef(result: Vector3): TransformNode;
  8928. /**
  8929. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8930. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8931. */
  8932. getAbsolutePivotPoint(): Vector3;
  8933. /**
  8934. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8935. * @param result vector3 to store the result
  8936. * @returns this TransformNode.
  8937. */
  8938. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8939. /**
  8940. * Defines the passed node as the parent of the current node.
  8941. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8942. * @param node the node ot set as the parent
  8943. * @returns this TransformNode.
  8944. */
  8945. setParent(node: Nullable<Node>): TransformNode;
  8946. private _nonUniformScaling;
  8947. /**
  8948. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8949. */
  8950. readonly nonUniformScaling: boolean;
  8951. /** @hidden */
  8952. _updateNonUniformScalingState(value: boolean): boolean;
  8953. /**
  8954. * Attach the current TransformNode to another TransformNode associated with a bone
  8955. * @param bone Bone affecting the TransformNode
  8956. * @param affectedTransformNode TransformNode associated with the bone
  8957. * @returns this object
  8958. */
  8959. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8960. /**
  8961. * Detach the transform node if its associated with a bone
  8962. * @returns this object
  8963. */
  8964. detachFromBone(): TransformNode;
  8965. private static _rotationAxisCache;
  8966. /**
  8967. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8968. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8969. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8970. * The passed axis is also normalized.
  8971. * @param axis the axis to rotate around
  8972. * @param amount the amount to rotate in radians
  8973. * @param space Space to rotate in (Default: local)
  8974. * @returns the TransformNode.
  8975. */
  8976. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8977. /**
  8978. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8979. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8980. * The passed axis is also normalized. .
  8981. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8982. * @param point the point to rotate around
  8983. * @param axis the axis to rotate around
  8984. * @param amount the amount to rotate in radians
  8985. * @returns the TransformNode
  8986. */
  8987. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8988. /**
  8989. * Translates the mesh along the axis vector for the passed distance in the given space.
  8990. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8991. * @param axis the axis to translate in
  8992. * @param distance the distance to translate
  8993. * @param space Space to rotate in (Default: local)
  8994. * @returns the TransformNode.
  8995. */
  8996. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8997. /**
  8998. * Adds a rotation step to the mesh current rotation.
  8999. * x, y, z are Euler angles expressed in radians.
  9000. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  9001. * This means this rotation is made in the mesh local space only.
  9002. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  9003. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  9004. * ```javascript
  9005. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  9006. * ```
  9007. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  9008. * 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.
  9009. * @param x Rotation to add
  9010. * @param y Rotation to add
  9011. * @param z Rotation to add
  9012. * @returns the TransformNode.
  9013. */
  9014. addRotation(x: number, y: number, z: number): TransformNode;
  9015. /**
  9016. * Computes the world matrix of the node
  9017. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9018. * @returns the world matrix
  9019. */
  9020. computeWorldMatrix(force?: boolean): Matrix;
  9021. protected _afterComputeWorldMatrix(): void;
  9022. /**
  9023. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  9024. * @param func callback function to add
  9025. *
  9026. * @returns the TransformNode.
  9027. */
  9028. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  9029. /**
  9030. * Removes a registered callback function.
  9031. * @param func callback function to remove
  9032. * @returns the TransformNode.
  9033. */
  9034. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  9035. /**
  9036. * Gets the position of the current mesh in camera space
  9037. * @param camera defines the camera to use
  9038. * @returns a position
  9039. */
  9040. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  9041. /**
  9042. * Returns the distance from the mesh to the active camera
  9043. * @param camera defines the camera to use
  9044. * @returns the distance
  9045. */
  9046. getDistanceToCamera(camera?: Nullable<Camera>): number;
  9047. /**
  9048. * Clone the current transform node
  9049. * @param name Name of the new clone
  9050. * @param newParent New parent for the clone
  9051. * @param doNotCloneChildren Do not clone children hierarchy
  9052. * @returns the new transform node
  9053. */
  9054. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  9055. /**
  9056. * Serializes the objects information.
  9057. * @param currentSerializationObject defines the object to serialize in
  9058. * @returns the serialized object
  9059. */
  9060. serialize(currentSerializationObject?: any): any;
  9061. /**
  9062. * Returns a new TransformNode object parsed from the source provided.
  9063. * @param parsedTransformNode is the source.
  9064. * @param scene the scne the object belongs to
  9065. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  9066. * @returns a new TransformNode object parsed from the source provided.
  9067. */
  9068. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  9069. /**
  9070. * Get all child-transformNodes of this node
  9071. * @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
  9072. * @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
  9073. * @returns an array of TransformNode
  9074. */
  9075. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  9076. /**
  9077. * Releases resources associated with this transform node.
  9078. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9079. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9080. */
  9081. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9082. }
  9083. }
  9084. declare module BABYLON {
  9085. /**
  9086. * Defines the types of pose enabled controllers that are supported
  9087. */
  9088. export enum PoseEnabledControllerType {
  9089. /**
  9090. * HTC Vive
  9091. */
  9092. VIVE = 0,
  9093. /**
  9094. * Oculus Rift
  9095. */
  9096. OCULUS = 1,
  9097. /**
  9098. * Windows mixed reality
  9099. */
  9100. WINDOWS = 2,
  9101. /**
  9102. * Samsung gear VR
  9103. */
  9104. GEAR_VR = 3,
  9105. /**
  9106. * Google Daydream
  9107. */
  9108. DAYDREAM = 4,
  9109. /**
  9110. * Generic
  9111. */
  9112. GENERIC = 5
  9113. }
  9114. /**
  9115. * Defines the MutableGamepadButton interface for the state of a gamepad button
  9116. */
  9117. export interface MutableGamepadButton {
  9118. /**
  9119. * Value of the button/trigger
  9120. */
  9121. value: number;
  9122. /**
  9123. * If the button/trigger is currently touched
  9124. */
  9125. touched: boolean;
  9126. /**
  9127. * If the button/trigger is currently pressed
  9128. */
  9129. pressed: boolean;
  9130. }
  9131. /**
  9132. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  9133. * @hidden
  9134. */
  9135. export interface ExtendedGamepadButton extends GamepadButton {
  9136. /**
  9137. * If the button/trigger is currently pressed
  9138. */
  9139. readonly pressed: boolean;
  9140. /**
  9141. * If the button/trigger is currently touched
  9142. */
  9143. readonly touched: boolean;
  9144. /**
  9145. * Value of the button/trigger
  9146. */
  9147. readonly value: number;
  9148. }
  9149. /** @hidden */
  9150. export interface _GamePadFactory {
  9151. /**
  9152. * Returns wether or not the current gamepad can be created for this type of controller.
  9153. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  9154. * @returns true if it can be created, otherwise false
  9155. */
  9156. canCreate(gamepadInfo: any): boolean;
  9157. /**
  9158. * Creates a new instance of the Gamepad.
  9159. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  9160. * @returns the new gamepad instance
  9161. */
  9162. create(gamepadInfo: any): Gamepad;
  9163. }
  9164. /**
  9165. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  9166. */
  9167. export class PoseEnabledControllerHelper {
  9168. /** @hidden */
  9169. static _ControllerFactories: _GamePadFactory[];
  9170. /** @hidden */
  9171. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  9172. /**
  9173. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  9174. * @param vrGamepad the gamepad to initialized
  9175. * @returns a vr controller of the type the gamepad identified as
  9176. */
  9177. static InitiateController(vrGamepad: any): Gamepad;
  9178. }
  9179. /**
  9180. * Defines the PoseEnabledController object that contains state of a vr capable controller
  9181. */
  9182. export class PoseEnabledController extends Gamepad implements PoseControlled {
  9183. private _deviceRoomPosition;
  9184. private _deviceRoomRotationQuaternion;
  9185. /**
  9186. * The device position in babylon space
  9187. */
  9188. devicePosition: Vector3;
  9189. /**
  9190. * The device rotation in babylon space
  9191. */
  9192. deviceRotationQuaternion: Quaternion;
  9193. /**
  9194. * The scale factor of the device in babylon space
  9195. */
  9196. deviceScaleFactor: number;
  9197. /**
  9198. * (Likely devicePosition should be used instead) The device position in its room space
  9199. */
  9200. position: Vector3;
  9201. /**
  9202. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  9203. */
  9204. rotationQuaternion: Quaternion;
  9205. /**
  9206. * The type of controller (Eg. Windows mixed reality)
  9207. */
  9208. controllerType: PoseEnabledControllerType;
  9209. protected _calculatedPosition: Vector3;
  9210. private _calculatedRotation;
  9211. /**
  9212. * The raw pose from the device
  9213. */
  9214. rawPose: DevicePose;
  9215. private _trackPosition;
  9216. private _maxRotationDistFromHeadset;
  9217. private _draggedRoomRotation;
  9218. /**
  9219. * @hidden
  9220. */
  9221. _disableTrackPosition(fixedPosition: Vector3): void;
  9222. /**
  9223. * Internal, the mesh attached to the controller
  9224. * @hidden
  9225. */
  9226. _mesh: Nullable<AbstractMesh>;
  9227. private _poseControlledCamera;
  9228. private _leftHandSystemQuaternion;
  9229. /**
  9230. * Internal, matrix used to convert room space to babylon space
  9231. * @hidden
  9232. */
  9233. _deviceToWorld: Matrix;
  9234. /**
  9235. * Node to be used when casting a ray from the controller
  9236. * @hidden
  9237. */
  9238. _pointingPoseNode: Nullable<TransformNode>;
  9239. /**
  9240. * Name of the child mesh that can be used to cast a ray from the controller
  9241. */
  9242. static readonly POINTING_POSE: string;
  9243. /**
  9244. * Creates a new PoseEnabledController from a gamepad
  9245. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  9246. */
  9247. constructor(browserGamepad: any);
  9248. private _workingMatrix;
  9249. /**
  9250. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  9251. */
  9252. update(): void;
  9253. /**
  9254. * Updates only the pose device and mesh without doing any button event checking
  9255. */
  9256. protected _updatePoseAndMesh(): void;
  9257. /**
  9258. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  9259. * @param poseData raw pose fromthe device
  9260. */
  9261. updateFromDevice(poseData: DevicePose): void;
  9262. /**
  9263. * @hidden
  9264. */
  9265. _meshAttachedObservable: Observable<AbstractMesh>;
  9266. /**
  9267. * Attaches a mesh to the controller
  9268. * @param mesh the mesh to be attached
  9269. */
  9270. attachToMesh(mesh: AbstractMesh): void;
  9271. /**
  9272. * Attaches the controllers mesh to a camera
  9273. * @param camera the camera the mesh should be attached to
  9274. */
  9275. attachToPoseControlledCamera(camera: TargetCamera): void;
  9276. /**
  9277. * Disposes of the controller
  9278. */
  9279. dispose(): void;
  9280. /**
  9281. * The mesh that is attached to the controller
  9282. */
  9283. readonly mesh: Nullable<AbstractMesh>;
  9284. /**
  9285. * Gets the ray of the controller in the direction the controller is pointing
  9286. * @param length the length the resulting ray should be
  9287. * @returns a ray in the direction the controller is pointing
  9288. */
  9289. getForwardRay(length?: number): Ray;
  9290. }
  9291. }
  9292. declare module BABYLON {
  9293. /**
  9294. * Defines the WebVRController object that represents controllers tracked in 3D space
  9295. */
  9296. export abstract class WebVRController extends PoseEnabledController {
  9297. /**
  9298. * Internal, the default controller model for the controller
  9299. */
  9300. protected _defaultModel: AbstractMesh;
  9301. /**
  9302. * Fired when the trigger state has changed
  9303. */
  9304. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  9305. /**
  9306. * Fired when the main button state has changed
  9307. */
  9308. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  9309. /**
  9310. * Fired when the secondary button state has changed
  9311. */
  9312. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  9313. /**
  9314. * Fired when the pad state has changed
  9315. */
  9316. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  9317. /**
  9318. * Fired when controllers stick values have changed
  9319. */
  9320. onPadValuesChangedObservable: Observable<StickValues>;
  9321. /**
  9322. * Array of button availible on the controller
  9323. */
  9324. protected _buttons: Array<MutableGamepadButton>;
  9325. private _onButtonStateChange;
  9326. /**
  9327. * Fired when a controller button's state has changed
  9328. * @param callback the callback containing the button that was modified
  9329. */
  9330. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  9331. /**
  9332. * X and Y axis corrisponding to the controllers joystick
  9333. */
  9334. pad: StickValues;
  9335. /**
  9336. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  9337. */
  9338. hand: string;
  9339. /**
  9340. * The default controller model for the controller
  9341. */
  9342. readonly defaultModel: AbstractMesh;
  9343. /**
  9344. * Creates a new WebVRController from a gamepad
  9345. * @param vrGamepad the gamepad that the WebVRController should be created from
  9346. */
  9347. constructor(vrGamepad: any);
  9348. /**
  9349. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  9350. */
  9351. update(): void;
  9352. /**
  9353. * Function to be called when a button is modified
  9354. */
  9355. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  9356. /**
  9357. * Loads a mesh and attaches it to the controller
  9358. * @param scene the scene the mesh should be added to
  9359. * @param meshLoaded callback for when the mesh has been loaded
  9360. */
  9361. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  9362. private _setButtonValue;
  9363. private _changes;
  9364. private _checkChanges;
  9365. /**
  9366. * Disposes of th webVRCOntroller
  9367. */
  9368. dispose(): void;
  9369. }
  9370. }
  9371. declare module BABYLON {
  9372. /**
  9373. * Interface describing all the common properties and methods a shadow light needs to implement.
  9374. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9375. * as well as binding the different shadow properties to the effects.
  9376. */
  9377. export interface IShadowLight extends Light {
  9378. /**
  9379. * The light id in the scene (used in scene.findLighById for instance)
  9380. */
  9381. id: string;
  9382. /**
  9383. * The position the shdow will be casted from.
  9384. */
  9385. position: Vector3;
  9386. /**
  9387. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9388. */
  9389. direction: Vector3;
  9390. /**
  9391. * The transformed position. Position of the light in world space taking parenting in account.
  9392. */
  9393. transformedPosition: Vector3;
  9394. /**
  9395. * The transformed direction. Direction of the light in world space taking parenting in account.
  9396. */
  9397. transformedDirection: Vector3;
  9398. /**
  9399. * The friendly name of the light in the scene.
  9400. */
  9401. name: string;
  9402. /**
  9403. * Defines the shadow projection clipping minimum z value.
  9404. */
  9405. shadowMinZ: number;
  9406. /**
  9407. * Defines the shadow projection clipping maximum z value.
  9408. */
  9409. shadowMaxZ: number;
  9410. /**
  9411. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9412. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9413. */
  9414. computeTransformedInformation(): boolean;
  9415. /**
  9416. * Gets the scene the light belongs to.
  9417. * @returns The scene
  9418. */
  9419. getScene(): Scene;
  9420. /**
  9421. * Callback defining a custom Projection Matrix Builder.
  9422. * This can be used to override the default projection matrix computation.
  9423. */
  9424. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9425. /**
  9426. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9427. * @param matrix The materix to updated with the projection information
  9428. * @param viewMatrix The transform matrix of the light
  9429. * @param renderList The list of mesh to render in the map
  9430. * @returns The current light
  9431. */
  9432. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9433. /**
  9434. * Gets the current depth scale used in ESM.
  9435. * @returns The scale
  9436. */
  9437. getDepthScale(): number;
  9438. /**
  9439. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9440. * @returns true if a cube texture needs to be use
  9441. */
  9442. needCube(): boolean;
  9443. /**
  9444. * Detects if the projection matrix requires to be recomputed this frame.
  9445. * @returns true if it requires to be recomputed otherwise, false.
  9446. */
  9447. needProjectionMatrixCompute(): boolean;
  9448. /**
  9449. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9450. */
  9451. forceProjectionMatrixCompute(): void;
  9452. /**
  9453. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9454. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9455. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9456. */
  9457. getShadowDirection(faceIndex?: number): Vector3;
  9458. /**
  9459. * Gets the minZ used for shadow according to both the scene and the light.
  9460. * @param activeCamera The camera we are returning the min for
  9461. * @returns the depth min z
  9462. */
  9463. getDepthMinZ(activeCamera: Camera): number;
  9464. /**
  9465. * Gets the maxZ used for shadow according to both the scene and the light.
  9466. * @param activeCamera The camera we are returning the max for
  9467. * @returns the depth max z
  9468. */
  9469. getDepthMaxZ(activeCamera: Camera): number;
  9470. }
  9471. /**
  9472. * Base implementation IShadowLight
  9473. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9474. */
  9475. export abstract class ShadowLight extends Light implements IShadowLight {
  9476. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9477. protected _position: Vector3;
  9478. protected _setPosition(value: Vector3): void;
  9479. /**
  9480. * Sets the position the shadow will be casted from. Also use as the light position for both
  9481. * point and spot lights.
  9482. */
  9483. /**
  9484. * Sets the position the shadow will be casted from. Also use as the light position for both
  9485. * point and spot lights.
  9486. */
  9487. position: Vector3;
  9488. protected _direction: Vector3;
  9489. protected _setDirection(value: Vector3): void;
  9490. /**
  9491. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9492. * Also use as the light direction on spot and directional lights.
  9493. */
  9494. /**
  9495. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9496. * Also use as the light direction on spot and directional lights.
  9497. */
  9498. direction: Vector3;
  9499. private _shadowMinZ;
  9500. /**
  9501. * Gets the shadow projection clipping minimum z value.
  9502. */
  9503. /**
  9504. * Sets the shadow projection clipping minimum z value.
  9505. */
  9506. shadowMinZ: number;
  9507. private _shadowMaxZ;
  9508. /**
  9509. * Sets the shadow projection clipping maximum z value.
  9510. */
  9511. /**
  9512. * Gets the shadow projection clipping maximum z value.
  9513. */
  9514. shadowMaxZ: number;
  9515. /**
  9516. * Callback defining a custom Projection Matrix Builder.
  9517. * This can be used to override the default projection matrix computation.
  9518. */
  9519. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9520. /**
  9521. * The transformed position. Position of the light in world space taking parenting in account.
  9522. */
  9523. transformedPosition: Vector3;
  9524. /**
  9525. * The transformed direction. Direction of the light in world space taking parenting in account.
  9526. */
  9527. transformedDirection: Vector3;
  9528. private _needProjectionMatrixCompute;
  9529. /**
  9530. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9531. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9532. */
  9533. computeTransformedInformation(): boolean;
  9534. /**
  9535. * Return the depth scale used for the shadow map.
  9536. * @returns the depth scale.
  9537. */
  9538. getDepthScale(): number;
  9539. /**
  9540. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9541. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9542. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9543. */
  9544. getShadowDirection(faceIndex?: number): Vector3;
  9545. /**
  9546. * Returns the ShadowLight absolute position in the World.
  9547. * @returns the position vector in world space
  9548. */
  9549. getAbsolutePosition(): Vector3;
  9550. /**
  9551. * Sets the ShadowLight direction toward the passed target.
  9552. * @param target The point tot target in local space
  9553. * @returns the updated ShadowLight direction
  9554. */
  9555. setDirectionToTarget(target: Vector3): Vector3;
  9556. /**
  9557. * Returns the light rotation in euler definition.
  9558. * @returns the x y z rotation in local space.
  9559. */
  9560. getRotation(): Vector3;
  9561. /**
  9562. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9563. * @returns true if a cube texture needs to be use
  9564. */
  9565. needCube(): boolean;
  9566. /**
  9567. * Detects if the projection matrix requires to be recomputed this frame.
  9568. * @returns true if it requires to be recomputed otherwise, false.
  9569. */
  9570. needProjectionMatrixCompute(): boolean;
  9571. /**
  9572. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9573. */
  9574. forceProjectionMatrixCompute(): void;
  9575. /** @hidden */
  9576. _initCache(): void;
  9577. /** @hidden */
  9578. _isSynchronized(): boolean;
  9579. /**
  9580. * Computes the world matrix of the node
  9581. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9582. * @returns the world matrix
  9583. */
  9584. computeWorldMatrix(force?: boolean): Matrix;
  9585. /**
  9586. * Gets the minZ used for shadow according to both the scene and the light.
  9587. * @param activeCamera The camera we are returning the min for
  9588. * @returns the depth min z
  9589. */
  9590. getDepthMinZ(activeCamera: Camera): number;
  9591. /**
  9592. * Gets the maxZ used for shadow according to both the scene and the light.
  9593. * @param activeCamera The camera we are returning the max for
  9594. * @returns the depth max z
  9595. */
  9596. getDepthMaxZ(activeCamera: Camera): number;
  9597. /**
  9598. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9599. * @param matrix The materix to updated with the projection information
  9600. * @param viewMatrix The transform matrix of the light
  9601. * @param renderList The list of mesh to render in the map
  9602. * @returns The current light
  9603. */
  9604. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9605. }
  9606. }
  9607. declare module BABYLON {
  9608. /**
  9609. * "Static Class" containing the most commonly used helper while dealing with material for
  9610. * rendering purpose.
  9611. *
  9612. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9613. *
  9614. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9615. */
  9616. export class MaterialHelper {
  9617. /**
  9618. * Bind the current view position to an effect.
  9619. * @param effect The effect to be bound
  9620. * @param scene The scene the eyes position is used from
  9621. */
  9622. static BindEyePosition(effect: Effect, scene: Scene): void;
  9623. /**
  9624. * Helps preparing the defines values about the UVs in used in the effect.
  9625. * UVs are shared as much as we can accross channels in the shaders.
  9626. * @param texture The texture we are preparing the UVs for
  9627. * @param defines The defines to update
  9628. * @param key The channel key "diffuse", "specular"... used in the shader
  9629. */
  9630. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9631. /**
  9632. * Binds a texture matrix value to its corrsponding uniform
  9633. * @param texture The texture to bind the matrix for
  9634. * @param uniformBuffer The uniform buffer receivin the data
  9635. * @param key The channel key "diffuse", "specular"... used in the shader
  9636. */
  9637. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9638. /**
  9639. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9640. * @param mesh defines the current mesh
  9641. * @param scene defines the current scene
  9642. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9643. * @param pointsCloud defines if point cloud rendering has to be turned on
  9644. * @param fogEnabled defines if fog has to be turned on
  9645. * @param alphaTest defines if alpha testing has to be turned on
  9646. * @param defines defines the current list of defines
  9647. */
  9648. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9649. /**
  9650. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9651. * @param scene defines the current scene
  9652. * @param engine defines the current engine
  9653. * @param defines specifies the list of active defines
  9654. * @param useInstances defines if instances have to be turned on
  9655. * @param useClipPlane defines if clip plane have to be turned on
  9656. */
  9657. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9658. /**
  9659. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9660. * @param mesh The mesh containing the geometry data we will draw
  9661. * @param defines The defines to update
  9662. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9663. * @param useBones Precise whether bones should be used or not (override mesh info)
  9664. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9665. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9666. * @returns false if defines are considered not dirty and have not been checked
  9667. */
  9668. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9669. /**
  9670. * Prepares the defines related to the light information passed in parameter
  9671. * @param scene The scene we are intending to draw
  9672. * @param mesh The mesh the effect is compiling for
  9673. * @param defines The defines to update
  9674. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9675. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9676. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9677. * @returns true if normals will be required for the rest of the effect
  9678. */
  9679. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9680. /**
  9681. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9682. * that won t be acctive due to defines being turned off.
  9683. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9684. * @param samplersList The samplers list
  9685. * @param defines The defines helping in the list generation
  9686. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9687. */
  9688. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9689. /**
  9690. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9691. * @param defines The defines to update while falling back
  9692. * @param fallbacks The authorized effect fallbacks
  9693. * @param maxSimultaneousLights The maximum number of lights allowed
  9694. * @param rank the current rank of the Effect
  9695. * @returns The newly affected rank
  9696. */
  9697. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9698. /**
  9699. * Prepares the list of attributes required for morph targets according to the effect defines.
  9700. * @param attribs The current list of supported attribs
  9701. * @param mesh The mesh to prepare the morph targets attributes for
  9702. * @param defines The current Defines of the effect
  9703. */
  9704. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9705. /**
  9706. * Prepares the list of attributes required for bones according to the effect defines.
  9707. * @param attribs The current list of supported attribs
  9708. * @param mesh The mesh to prepare the bones attributes for
  9709. * @param defines The current Defines of the effect
  9710. * @param fallbacks The current efffect fallback strategy
  9711. */
  9712. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9713. /**
  9714. * Prepares the list of attributes required for instances according to the effect defines.
  9715. * @param attribs The current list of supported attribs
  9716. * @param defines The current Defines of the effect
  9717. */
  9718. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9719. /**
  9720. * Binds the light shadow information to the effect for the given mesh.
  9721. * @param light The light containing the generator
  9722. * @param scene The scene the lights belongs to
  9723. * @param mesh The mesh we are binding the information to render
  9724. * @param lightIndex The light index in the effect used to render the mesh
  9725. * @param effect The effect we are binding the data to
  9726. */
  9727. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9728. /**
  9729. * Binds the light information to the effect.
  9730. * @param light The light containing the generator
  9731. * @param effect The effect we are binding the data to
  9732. * @param lightIndex The light index in the effect used to render
  9733. */
  9734. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9735. /**
  9736. * Binds the lights information from the scene to the effect for the given mesh.
  9737. * @param scene The scene the lights belongs to
  9738. * @param mesh The mesh we are binding the information to render
  9739. * @param effect The effect we are binding the data to
  9740. * @param defines The generated defines for the effect
  9741. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9742. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9743. */
  9744. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9745. private static _tempFogColor;
  9746. /**
  9747. * Binds the fog information from the scene to the effect for the given mesh.
  9748. * @param scene The scene the lights belongs to
  9749. * @param mesh The mesh we are binding the information to render
  9750. * @param effect The effect we are binding the data to
  9751. * @param linearSpace Defines if the fog effect is applied in linear space
  9752. */
  9753. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9754. /**
  9755. * Binds the bones information from the mesh to the effect.
  9756. * @param mesh The mesh we are binding the information to render
  9757. * @param effect The effect we are binding the data to
  9758. */
  9759. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9760. /**
  9761. * Binds the morph targets information from the mesh to the effect.
  9762. * @param abstractMesh The mesh we are binding the information to render
  9763. * @param effect The effect we are binding the data to
  9764. */
  9765. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9766. /**
  9767. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9768. * @param defines The generated defines used in the effect
  9769. * @param effect The effect we are binding the data to
  9770. * @param scene The scene we are willing to render with logarithmic scale for
  9771. */
  9772. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9773. /**
  9774. * Binds the clip plane information from the scene to the effect.
  9775. * @param scene The scene the clip plane information are extracted from
  9776. * @param effect The effect we are binding the data to
  9777. */
  9778. static BindClipPlane(effect: Effect, scene: Scene): void;
  9779. }
  9780. }
  9781. declare module BABYLON {
  9782. /** @hidden */
  9783. export var shadowMapPixelShader: {
  9784. name: string;
  9785. shader: string;
  9786. };
  9787. }
  9788. declare module BABYLON {
  9789. /** @hidden */
  9790. export var bonesDeclaration: {
  9791. name: string;
  9792. shader: string;
  9793. };
  9794. }
  9795. declare module BABYLON {
  9796. /** @hidden */
  9797. export var morphTargetsVertexGlobalDeclaration: {
  9798. name: string;
  9799. shader: string;
  9800. };
  9801. }
  9802. declare module BABYLON {
  9803. /** @hidden */
  9804. export var morphTargetsVertexDeclaration: {
  9805. name: string;
  9806. shader: string;
  9807. };
  9808. }
  9809. declare module BABYLON {
  9810. /** @hidden */
  9811. export var instancesDeclaration: {
  9812. name: string;
  9813. shader: string;
  9814. };
  9815. }
  9816. declare module BABYLON {
  9817. /** @hidden */
  9818. export var helperFunctions: {
  9819. name: string;
  9820. shader: string;
  9821. };
  9822. }
  9823. declare module BABYLON {
  9824. /** @hidden */
  9825. export var morphTargetsVertex: {
  9826. name: string;
  9827. shader: string;
  9828. };
  9829. }
  9830. declare module BABYLON {
  9831. /** @hidden */
  9832. export var instancesVertex: {
  9833. name: string;
  9834. shader: string;
  9835. };
  9836. }
  9837. declare module BABYLON {
  9838. /** @hidden */
  9839. export var bonesVertex: {
  9840. name: string;
  9841. shader: string;
  9842. };
  9843. }
  9844. declare module BABYLON {
  9845. /** @hidden */
  9846. export var shadowMapVertexShader: {
  9847. name: string;
  9848. shader: string;
  9849. };
  9850. }
  9851. declare module BABYLON {
  9852. /** @hidden */
  9853. export var depthBoxBlurPixelShader: {
  9854. name: string;
  9855. shader: string;
  9856. };
  9857. }
  9858. declare module BABYLON {
  9859. /**
  9860. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9861. */
  9862. export interface ICustomShaderOptions {
  9863. /**
  9864. * Gets or sets the custom shader name to use
  9865. */
  9866. shaderName: string;
  9867. /**
  9868. * The list of attribute names used in the shader
  9869. */
  9870. attributes?: string[];
  9871. /**
  9872. * The list of unifrom names used in the shader
  9873. */
  9874. uniforms?: string[];
  9875. /**
  9876. * The list of sampler names used in the shader
  9877. */
  9878. samplers?: string[];
  9879. /**
  9880. * The list of defines used in the shader
  9881. */
  9882. defines?: string[];
  9883. }
  9884. /**
  9885. * Interface to implement to create a shadow generator compatible with BJS.
  9886. */
  9887. export interface IShadowGenerator {
  9888. /**
  9889. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9890. * @returns The render target texture if present otherwise, null
  9891. */
  9892. getShadowMap(): Nullable<RenderTargetTexture>;
  9893. /**
  9894. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9895. * @returns The render target texture if the shadow map is present otherwise, null
  9896. */
  9897. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9898. /**
  9899. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9900. * @param subMesh The submesh we want to render in the shadow map
  9901. * @param useInstances Defines wether will draw in the map using instances
  9902. * @returns true if ready otherwise, false
  9903. */
  9904. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9905. /**
  9906. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9907. * @param defines Defines of the material we want to update
  9908. * @param lightIndex Index of the light in the enabled light list of the material
  9909. */
  9910. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9911. /**
  9912. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9913. * defined in the generator but impacting the effect).
  9914. * It implies the unifroms available on the materials are the standard BJS ones.
  9915. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9916. * @param effect The effect we are binfing the information for
  9917. */
  9918. bindShadowLight(lightIndex: string, effect: Effect): void;
  9919. /**
  9920. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9921. * (eq to shadow prjection matrix * light transform matrix)
  9922. * @returns The transform matrix used to create the shadow map
  9923. */
  9924. getTransformMatrix(): Matrix;
  9925. /**
  9926. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9927. * Cube and 2D textures for instance.
  9928. */
  9929. recreateShadowMap(): void;
  9930. /**
  9931. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9932. * @param onCompiled Callback triggered at the and of the effects compilation
  9933. * @param options Sets of optional options forcing the compilation with different modes
  9934. */
  9935. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9936. useInstances: boolean;
  9937. }>): void;
  9938. /**
  9939. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9940. * @param options Sets of optional options forcing the compilation with different modes
  9941. * @returns A promise that resolves when the compilation completes
  9942. */
  9943. forceCompilationAsync(options?: Partial<{
  9944. useInstances: boolean;
  9945. }>): Promise<void>;
  9946. /**
  9947. * Serializes the shadow generator setup to a json object.
  9948. * @returns The serialized JSON object
  9949. */
  9950. serialize(): any;
  9951. /**
  9952. * Disposes the Shadow map and related Textures and effects.
  9953. */
  9954. dispose(): void;
  9955. }
  9956. /**
  9957. * Default implementation IShadowGenerator.
  9958. * This is the main object responsible of generating shadows in the framework.
  9959. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9960. */
  9961. export class ShadowGenerator implements IShadowGenerator {
  9962. /**
  9963. * Shadow generator mode None: no filtering applied.
  9964. */
  9965. static readonly FILTER_NONE: number;
  9966. /**
  9967. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9968. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9969. */
  9970. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9971. /**
  9972. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9973. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9974. */
  9975. static readonly FILTER_POISSONSAMPLING: number;
  9976. /**
  9977. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9978. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9979. */
  9980. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9981. /**
  9982. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9983. * edge artifacts on steep falloff.
  9984. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9985. */
  9986. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9987. /**
  9988. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9989. * edge artifacts on steep falloff.
  9990. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9991. */
  9992. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9993. /**
  9994. * Shadow generator mode PCF: Percentage Closer Filtering
  9995. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9996. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9997. */
  9998. static readonly FILTER_PCF: number;
  9999. /**
  10000. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  10001. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10002. * Contact Hardening
  10003. */
  10004. static readonly FILTER_PCSS: number;
  10005. /**
  10006. * Reserved for PCF and PCSS
  10007. * Highest Quality.
  10008. *
  10009. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  10010. *
  10011. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  10012. */
  10013. static readonly QUALITY_HIGH: number;
  10014. /**
  10015. * Reserved for PCF and PCSS
  10016. * Good tradeoff for quality/perf cross devices
  10017. *
  10018. * Execute PCF on a 3*3 kernel.
  10019. *
  10020. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  10021. */
  10022. static readonly QUALITY_MEDIUM: number;
  10023. /**
  10024. * Reserved for PCF and PCSS
  10025. * The lowest quality but the fastest.
  10026. *
  10027. * Execute PCF on a 1*1 kernel.
  10028. *
  10029. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  10030. */
  10031. static readonly QUALITY_LOW: number;
  10032. /** Gets or sets the custom shader name to use */
  10033. customShaderOptions: ICustomShaderOptions;
  10034. /**
  10035. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  10036. */
  10037. onBeforeShadowMapRenderObservable: Observable<Effect>;
  10038. private _bias;
  10039. /**
  10040. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10041. */
  10042. /**
  10043. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10044. */
  10045. bias: number;
  10046. private _normalBias;
  10047. /**
  10048. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10049. */
  10050. /**
  10051. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10052. */
  10053. normalBias: number;
  10054. private _blurBoxOffset;
  10055. /**
  10056. * Gets the blur box offset: offset applied during the blur pass.
  10057. * Only useful if useKernelBlur = false
  10058. */
  10059. /**
  10060. * Sets the blur box offset: offset applied during the blur pass.
  10061. * Only useful if useKernelBlur = false
  10062. */
  10063. blurBoxOffset: number;
  10064. private _blurScale;
  10065. /**
  10066. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10067. * 2 means half of the size.
  10068. */
  10069. /**
  10070. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10071. * 2 means half of the size.
  10072. */
  10073. blurScale: number;
  10074. private _blurKernel;
  10075. /**
  10076. * Gets the blur kernel: kernel size of the blur pass.
  10077. * Only useful if useKernelBlur = true
  10078. */
  10079. /**
  10080. * Sets the blur kernel: kernel size of the blur pass.
  10081. * Only useful if useKernelBlur = true
  10082. */
  10083. blurKernel: number;
  10084. private _useKernelBlur;
  10085. /**
  10086. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  10087. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10088. */
  10089. /**
  10090. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  10091. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10092. */
  10093. useKernelBlur: boolean;
  10094. private _depthScale;
  10095. /**
  10096. * Gets the depth scale used in ESM mode.
  10097. */
  10098. /**
  10099. * Sets the depth scale used in ESM mode.
  10100. * This can override the scale stored on the light.
  10101. */
  10102. depthScale: number;
  10103. private _filter;
  10104. /**
  10105. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10106. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10107. */
  10108. /**
  10109. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10110. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10111. */
  10112. filter: number;
  10113. /**
  10114. * Gets if the current filter is set to Poisson Sampling.
  10115. */
  10116. /**
  10117. * Sets the current filter to Poisson Sampling.
  10118. */
  10119. usePoissonSampling: boolean;
  10120. /**
  10121. * Gets if the current filter is set to ESM.
  10122. */
  10123. /**
  10124. * Sets the current filter is to ESM.
  10125. */
  10126. useExponentialShadowMap: boolean;
  10127. /**
  10128. * Gets if the current filter is set to filtered ESM.
  10129. */
  10130. /**
  10131. * Gets if the current filter is set to filtered ESM.
  10132. */
  10133. useBlurExponentialShadowMap: boolean;
  10134. /**
  10135. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10136. * exponential to prevent steep falloff artifacts).
  10137. */
  10138. /**
  10139. * Sets the current filter to "close ESM" (using the inverse of the
  10140. * exponential to prevent steep falloff artifacts).
  10141. */
  10142. useCloseExponentialShadowMap: boolean;
  10143. /**
  10144. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10145. * exponential to prevent steep falloff artifacts).
  10146. */
  10147. /**
  10148. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10149. * exponential to prevent steep falloff artifacts).
  10150. */
  10151. useBlurCloseExponentialShadowMap: boolean;
  10152. /**
  10153. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10154. */
  10155. /**
  10156. * Sets the current filter to "PCF" (percentage closer filtering).
  10157. */
  10158. usePercentageCloserFiltering: boolean;
  10159. private _filteringQuality;
  10160. /**
  10161. * Gets the PCF or PCSS Quality.
  10162. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10163. */
  10164. /**
  10165. * Sets the PCF or PCSS Quality.
  10166. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10167. */
  10168. filteringQuality: number;
  10169. /**
  10170. * Gets if the current filter is set to "PCSS" (contact hardening).
  10171. */
  10172. /**
  10173. * Sets the current filter to "PCSS" (contact hardening).
  10174. */
  10175. useContactHardeningShadow: boolean;
  10176. private _contactHardeningLightSizeUVRatio;
  10177. /**
  10178. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10179. * Using a ratio helps keeping shape stability independently of the map size.
  10180. *
  10181. * It does not account for the light projection as it was having too much
  10182. * instability during the light setup or during light position changes.
  10183. *
  10184. * Only valid if useContactHardeningShadow is true.
  10185. */
  10186. /**
  10187. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10188. * Using a ratio helps keeping shape stability independently of the map size.
  10189. *
  10190. * It does not account for the light projection as it was having too much
  10191. * instability during the light setup or during light position changes.
  10192. *
  10193. * Only valid if useContactHardeningShadow is true.
  10194. */
  10195. contactHardeningLightSizeUVRatio: number;
  10196. private _darkness;
  10197. /**
  10198. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10199. * 0 means strongest and 1 would means no shadow.
  10200. * @returns the darkness.
  10201. */
  10202. getDarkness(): number;
  10203. /**
  10204. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10205. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10206. * @returns the shadow generator allowing fluent coding.
  10207. */
  10208. setDarkness(darkness: number): ShadowGenerator;
  10209. private _transparencyShadow;
  10210. /**
  10211. * Sets the ability to have transparent shadow (boolean).
  10212. * @param transparent True if transparent else False
  10213. * @returns the shadow generator allowing fluent coding
  10214. */
  10215. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10216. private _shadowMap;
  10217. private _shadowMap2;
  10218. /**
  10219. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10220. * @returns The render target texture if present otherwise, null
  10221. */
  10222. getShadowMap(): Nullable<RenderTargetTexture>;
  10223. /**
  10224. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10225. * @returns The render target texture if the shadow map is present otherwise, null
  10226. */
  10227. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10228. /**
  10229. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10230. * @param mesh Mesh to add
  10231. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10232. * @returns the Shadow Generator itself
  10233. */
  10234. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10235. /**
  10236. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10237. * @param mesh Mesh to remove
  10238. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10239. * @returns the Shadow Generator itself
  10240. */
  10241. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10242. /**
  10243. * Controls the extent to which the shadows fade out at the edge of the frustum
  10244. * Used only by directionals and spots
  10245. */
  10246. frustumEdgeFalloff: number;
  10247. private _light;
  10248. /**
  10249. * Returns the associated light object.
  10250. * @returns the light generating the shadow
  10251. */
  10252. getLight(): IShadowLight;
  10253. /**
  10254. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10255. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10256. * It might on the other hand introduce peter panning.
  10257. */
  10258. forceBackFacesOnly: boolean;
  10259. private _scene;
  10260. private _lightDirection;
  10261. private _effect;
  10262. private _viewMatrix;
  10263. private _projectionMatrix;
  10264. private _transformMatrix;
  10265. private _cachedPosition;
  10266. private _cachedDirection;
  10267. private _cachedDefines;
  10268. private _currentRenderID;
  10269. private _boxBlurPostprocess;
  10270. private _kernelBlurXPostprocess;
  10271. private _kernelBlurYPostprocess;
  10272. private _blurPostProcesses;
  10273. private _mapSize;
  10274. private _currentFaceIndex;
  10275. private _currentFaceIndexCache;
  10276. private _textureType;
  10277. private _defaultTextureMatrix;
  10278. /** @hidden */
  10279. static _SceneComponentInitialization: (scene: Scene) => void;
  10280. /**
  10281. * Creates a ShadowGenerator object.
  10282. * A ShadowGenerator is the required tool to use the shadows.
  10283. * Each light casting shadows needs to use its own ShadowGenerator.
  10284. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10285. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10286. * @param light The light object generating the shadows.
  10287. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  10288. */
  10289. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10290. private _initializeGenerator;
  10291. private _initializeShadowMap;
  10292. private _initializeBlurRTTAndPostProcesses;
  10293. private _renderForShadowMap;
  10294. private _renderSubMeshForShadowMap;
  10295. private _applyFilterValues;
  10296. /**
  10297. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10298. * @param onCompiled Callback triggered at the and of the effects compilation
  10299. * @param options Sets of optional options forcing the compilation with different modes
  10300. */
  10301. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10302. useInstances: boolean;
  10303. }>): void;
  10304. /**
  10305. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10306. * @param options Sets of optional options forcing the compilation with different modes
  10307. * @returns A promise that resolves when the compilation completes
  10308. */
  10309. forceCompilationAsync(options?: Partial<{
  10310. useInstances: boolean;
  10311. }>): Promise<void>;
  10312. /**
  10313. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10314. * @param subMesh The submesh we want to render in the shadow map
  10315. * @param useInstances Defines wether will draw in the map using instances
  10316. * @returns true if ready otherwise, false
  10317. */
  10318. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10319. /**
  10320. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10321. * @param defines Defines of the material we want to update
  10322. * @param lightIndex Index of the light in the enabled light list of the material
  10323. */
  10324. prepareDefines(defines: any, lightIndex: number): void;
  10325. /**
  10326. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10327. * defined in the generator but impacting the effect).
  10328. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10329. * @param effect The effect we are binfing the information for
  10330. */
  10331. bindShadowLight(lightIndex: string, effect: Effect): void;
  10332. /**
  10333. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10334. * (eq to shadow prjection matrix * light transform matrix)
  10335. * @returns The transform matrix used to create the shadow map
  10336. */
  10337. getTransformMatrix(): Matrix;
  10338. /**
  10339. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10340. * Cube and 2D textures for instance.
  10341. */
  10342. recreateShadowMap(): void;
  10343. private _disposeBlurPostProcesses;
  10344. private _disposeRTTandPostProcesses;
  10345. /**
  10346. * Disposes the ShadowGenerator.
  10347. * Returns nothing.
  10348. */
  10349. dispose(): void;
  10350. /**
  10351. * Serializes the shadow generator setup to a json object.
  10352. * @returns The serialized JSON object
  10353. */
  10354. serialize(): any;
  10355. /**
  10356. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10357. * @param parsedShadowGenerator The JSON object to parse
  10358. * @param scene The scene to create the shadow map for
  10359. * @returns The parsed shadow generator
  10360. */
  10361. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10362. }
  10363. }
  10364. declare module BABYLON {
  10365. /**
  10366. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10367. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10368. * 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.
  10369. */
  10370. export abstract class Light extends Node {
  10371. /**
  10372. * Falloff Default: light is falling off following the material specification:
  10373. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10374. */
  10375. static readonly FALLOFF_DEFAULT: number;
  10376. /**
  10377. * Falloff Physical: light is falling off following the inverse squared distance law.
  10378. */
  10379. static readonly FALLOFF_PHYSICAL: number;
  10380. /**
  10381. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10382. * to enhance interoperability with other engines.
  10383. */
  10384. static readonly FALLOFF_GLTF: number;
  10385. /**
  10386. * Falloff Standard: light is falling off like in the standard material
  10387. * to enhance interoperability with other materials.
  10388. */
  10389. static readonly FALLOFF_STANDARD: number;
  10390. /**
  10391. * If every light affecting the material is in this lightmapMode,
  10392. * material.lightmapTexture adds or multiplies
  10393. * (depends on material.useLightmapAsShadowmap)
  10394. * after every other light calculations.
  10395. */
  10396. static readonly LIGHTMAP_DEFAULT: number;
  10397. /**
  10398. * material.lightmapTexture as only diffuse lighting from this light
  10399. * adds only specular lighting from this light
  10400. * adds dynamic shadows
  10401. */
  10402. static readonly LIGHTMAP_SPECULAR: number;
  10403. /**
  10404. * material.lightmapTexture as only lighting
  10405. * no light calculation from this light
  10406. * only adds dynamic shadows from this light
  10407. */
  10408. static readonly LIGHTMAP_SHADOWSONLY: number;
  10409. /**
  10410. * Each light type uses the default quantity according to its type:
  10411. * point/spot lights use luminous intensity
  10412. * directional lights use illuminance
  10413. */
  10414. static readonly INTENSITYMODE_AUTOMATIC: number;
  10415. /**
  10416. * lumen (lm)
  10417. */
  10418. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10419. /**
  10420. * candela (lm/sr)
  10421. */
  10422. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10423. /**
  10424. * lux (lm/m^2)
  10425. */
  10426. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10427. /**
  10428. * nit (cd/m^2)
  10429. */
  10430. static readonly INTENSITYMODE_LUMINANCE: number;
  10431. /**
  10432. * Light type const id of the point light.
  10433. */
  10434. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10435. /**
  10436. * Light type const id of the directional light.
  10437. */
  10438. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10439. /**
  10440. * Light type const id of the spot light.
  10441. */
  10442. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10443. /**
  10444. * Light type const id of the hemispheric light.
  10445. */
  10446. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10447. /**
  10448. * Diffuse gives the basic color to an object.
  10449. */
  10450. diffuse: Color3;
  10451. /**
  10452. * Specular produces a highlight color on an object.
  10453. * Note: This is note affecting PBR materials.
  10454. */
  10455. specular: Color3;
  10456. /**
  10457. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10458. * falling off base on range or angle.
  10459. * This can be set to any values in Light.FALLOFF_x.
  10460. *
  10461. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10462. * other types of materials.
  10463. */
  10464. falloffType: number;
  10465. /**
  10466. * Strength of the light.
  10467. * Note: By default it is define in the framework own unit.
  10468. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10469. */
  10470. intensity: number;
  10471. private _range;
  10472. protected _inverseSquaredRange: number;
  10473. /**
  10474. * Defines how far from the source the light is impacting in scene units.
  10475. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10476. */
  10477. /**
  10478. * Defines how far from the source the light is impacting in scene units.
  10479. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10480. */
  10481. range: number;
  10482. /**
  10483. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10484. * of light.
  10485. */
  10486. private _photometricScale;
  10487. private _intensityMode;
  10488. /**
  10489. * Gets the photometric scale used to interpret the intensity.
  10490. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10491. */
  10492. /**
  10493. * Sets the photometric scale used to interpret the intensity.
  10494. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10495. */
  10496. intensityMode: number;
  10497. private _radius;
  10498. /**
  10499. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10500. */
  10501. /**
  10502. * sets the light radius used by PBR Materials to simulate soft area lights.
  10503. */
  10504. radius: number;
  10505. private _renderPriority;
  10506. /**
  10507. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10508. * exceeding the number allowed of the materials.
  10509. */
  10510. renderPriority: number;
  10511. private _shadowEnabled;
  10512. /**
  10513. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10514. * the current shadow generator.
  10515. */
  10516. /**
  10517. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10518. * the current shadow generator.
  10519. */
  10520. shadowEnabled: boolean;
  10521. private _includedOnlyMeshes;
  10522. /**
  10523. * Gets the only meshes impacted by this light.
  10524. */
  10525. /**
  10526. * Sets the only meshes impacted by this light.
  10527. */
  10528. includedOnlyMeshes: AbstractMesh[];
  10529. private _excludedMeshes;
  10530. /**
  10531. * Gets the meshes not impacted by this light.
  10532. */
  10533. /**
  10534. * Sets the meshes not impacted by this light.
  10535. */
  10536. excludedMeshes: AbstractMesh[];
  10537. private _excludeWithLayerMask;
  10538. /**
  10539. * Gets the layer id use to find what meshes are not impacted by the light.
  10540. * Inactive if 0
  10541. */
  10542. /**
  10543. * Sets the layer id use to find what meshes are not impacted by the light.
  10544. * Inactive if 0
  10545. */
  10546. excludeWithLayerMask: number;
  10547. private _includeOnlyWithLayerMask;
  10548. /**
  10549. * Gets the layer id use to find what meshes are impacted by the light.
  10550. * Inactive if 0
  10551. */
  10552. /**
  10553. * Sets the layer id use to find what meshes are impacted by the light.
  10554. * Inactive if 0
  10555. */
  10556. includeOnlyWithLayerMask: number;
  10557. private _lightmapMode;
  10558. /**
  10559. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10560. */
  10561. /**
  10562. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10563. */
  10564. lightmapMode: number;
  10565. /**
  10566. * Shadow generator associted to the light.
  10567. * @hidden Internal use only.
  10568. */
  10569. _shadowGenerator: Nullable<IShadowGenerator>;
  10570. /**
  10571. * @hidden Internal use only.
  10572. */
  10573. _excludedMeshesIds: string[];
  10574. /**
  10575. * @hidden Internal use only.
  10576. */
  10577. _includedOnlyMeshesIds: string[];
  10578. /**
  10579. * The current light unifom buffer.
  10580. * @hidden Internal use only.
  10581. */
  10582. _uniformBuffer: UniformBuffer;
  10583. /**
  10584. * Creates a Light object in the scene.
  10585. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10586. * @param name The firendly name of the light
  10587. * @param scene The scene the light belongs too
  10588. */
  10589. constructor(name: string, scene: Scene);
  10590. protected abstract _buildUniformLayout(): void;
  10591. /**
  10592. * Sets the passed Effect "effect" with the Light information.
  10593. * @param effect The effect to update
  10594. * @param lightIndex The index of the light in the effect to update
  10595. * @returns The light
  10596. */
  10597. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10598. /**
  10599. * Returns the string "Light".
  10600. * @returns the class name
  10601. */
  10602. getClassName(): string;
  10603. /** @hidden */
  10604. readonly _isLight: boolean;
  10605. /**
  10606. * Converts the light information to a readable string for debug purpose.
  10607. * @param fullDetails Supports for multiple levels of logging within scene loading
  10608. * @returns the human readable light info
  10609. */
  10610. toString(fullDetails?: boolean): string;
  10611. /** @hidden */
  10612. protected _syncParentEnabledState(): void;
  10613. /**
  10614. * Set the enabled state of this node.
  10615. * @param value - the new enabled state
  10616. */
  10617. setEnabled(value: boolean): void;
  10618. /**
  10619. * Returns the Light associated shadow generator if any.
  10620. * @return the associated shadow generator.
  10621. */
  10622. getShadowGenerator(): Nullable<IShadowGenerator>;
  10623. /**
  10624. * Returns a Vector3, the absolute light position in the World.
  10625. * @returns the world space position of the light
  10626. */
  10627. getAbsolutePosition(): Vector3;
  10628. /**
  10629. * Specifies if the light will affect the passed mesh.
  10630. * @param mesh The mesh to test against the light
  10631. * @return true the mesh is affected otherwise, false.
  10632. */
  10633. canAffectMesh(mesh: AbstractMesh): boolean;
  10634. /**
  10635. * Sort function to order lights for rendering.
  10636. * @param a First Light object to compare to second.
  10637. * @param b Second Light object to compare first.
  10638. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10639. */
  10640. static CompareLightsPriority(a: Light, b: Light): number;
  10641. /**
  10642. * Releases resources associated with this node.
  10643. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10644. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10645. */
  10646. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10647. /**
  10648. * Returns the light type ID (integer).
  10649. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10650. */
  10651. getTypeID(): number;
  10652. /**
  10653. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10654. * @returns the scaled intensity in intensity mode unit
  10655. */
  10656. getScaledIntensity(): number;
  10657. /**
  10658. * Returns a new Light object, named "name", from the current one.
  10659. * @param name The name of the cloned light
  10660. * @returns the new created light
  10661. */
  10662. clone(name: string): Nullable<Light>;
  10663. /**
  10664. * Serializes the current light into a Serialization object.
  10665. * @returns the serialized object.
  10666. */
  10667. serialize(): any;
  10668. /**
  10669. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10670. * This new light is named "name" and added to the passed scene.
  10671. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10672. * @param name The friendly name of the light
  10673. * @param scene The scene the new light will belong to
  10674. * @returns the constructor function
  10675. */
  10676. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10677. /**
  10678. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10679. * @param parsedLight The JSON representation of the light
  10680. * @param scene The scene to create the parsed light in
  10681. * @returns the created light after parsing
  10682. */
  10683. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10684. private _hookArrayForExcluded;
  10685. private _hookArrayForIncludedOnly;
  10686. private _resyncMeshes;
  10687. /**
  10688. * Forces the meshes to update their light related information in their rendering used effects
  10689. * @hidden Internal Use Only
  10690. */
  10691. _markMeshesAsLightDirty(): void;
  10692. /**
  10693. * Recomputes the cached photometric scale if needed.
  10694. */
  10695. private _computePhotometricScale;
  10696. /**
  10697. * Returns the Photometric Scale according to the light type and intensity mode.
  10698. */
  10699. private _getPhotometricScale;
  10700. /**
  10701. * Reorder the light in the scene according to their defined priority.
  10702. * @hidden Internal Use Only
  10703. */
  10704. _reorderLightsInScene(): void;
  10705. /**
  10706. * Prepares the list of defines specific to the light type.
  10707. * @param defines the list of defines
  10708. * @param lightIndex defines the index of the light for the effect
  10709. */
  10710. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10711. }
  10712. }
  10713. declare module BABYLON {
  10714. /**
  10715. * The HemisphericLight simulates the ambient environment light,
  10716. * so the passed direction is the light reflection direction, not the incoming direction.
  10717. */
  10718. export class HemisphericLight extends Light {
  10719. /**
  10720. * The groundColor is the light in the opposite direction to the one specified during creation.
  10721. * 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.
  10722. */
  10723. groundColor: Color3;
  10724. /**
  10725. * The light reflection direction, not the incoming direction.
  10726. */
  10727. direction: Vector3;
  10728. /**
  10729. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  10730. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  10731. * The HemisphericLight can't cast shadows.
  10732. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10733. * @param name The friendly name of the light
  10734. * @param direction The direction of the light reflection
  10735. * @param scene The scene the light belongs to
  10736. */
  10737. constructor(name: string, direction: Vector3, scene: Scene);
  10738. protected _buildUniformLayout(): void;
  10739. /**
  10740. * Returns the string "HemisphericLight".
  10741. * @return The class name
  10742. */
  10743. getClassName(): string;
  10744. /**
  10745. * Sets the HemisphericLight direction towards the passed target (Vector3).
  10746. * Returns the updated direction.
  10747. * @param target The target the direction should point to
  10748. * @return The computed direction
  10749. */
  10750. setDirectionToTarget(target: Vector3): Vector3;
  10751. /**
  10752. * Returns the shadow generator associated to the light.
  10753. * @returns Always null for hemispheric lights because it does not support shadows.
  10754. */
  10755. getShadowGenerator(): Nullable<IShadowGenerator>;
  10756. /**
  10757. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  10758. * @param effect The effect to update
  10759. * @param lightIndex The index of the light in the effect to update
  10760. * @returns The hemispheric light
  10761. */
  10762. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  10763. /**
  10764. * Computes the world matrix of the node
  10765. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10766. * @param useWasUpdatedFlag defines a reserved property
  10767. * @returns the world matrix
  10768. */
  10769. computeWorldMatrix(): Matrix;
  10770. /**
  10771. * Returns the integer 3.
  10772. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10773. */
  10774. getTypeID(): number;
  10775. /**
  10776. * Prepares the list of defines specific to the light type.
  10777. * @param defines the list of defines
  10778. * @param lightIndex defines the index of the light for the effect
  10779. */
  10780. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10781. }
  10782. }
  10783. declare module BABYLON {
  10784. /**
  10785. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  10786. * IMPORTANT!! The data is right-hand data.
  10787. * @export
  10788. * @interface DevicePose
  10789. */
  10790. export interface DevicePose {
  10791. /**
  10792. * The position of the device, values in array are [x,y,z].
  10793. */
  10794. readonly position: Nullable<Float32Array>;
  10795. /**
  10796. * The linearVelocity of the device, values in array are [x,y,z].
  10797. */
  10798. readonly linearVelocity: Nullable<Float32Array>;
  10799. /**
  10800. * The linearAcceleration of the device, values in array are [x,y,z].
  10801. */
  10802. readonly linearAcceleration: Nullable<Float32Array>;
  10803. /**
  10804. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  10805. */
  10806. readonly orientation: Nullable<Float32Array>;
  10807. /**
  10808. * The angularVelocity of the device, values in array are [x,y,z].
  10809. */
  10810. readonly angularVelocity: Nullable<Float32Array>;
  10811. /**
  10812. * The angularAcceleration of the device, values in array are [x,y,z].
  10813. */
  10814. readonly angularAcceleration: Nullable<Float32Array>;
  10815. }
  10816. /**
  10817. * Interface representing a pose controlled object in Babylon.
  10818. * A pose controlled object has both regular pose values as well as pose values
  10819. * from an external device such as a VR head mounted display
  10820. */
  10821. export interface PoseControlled {
  10822. /**
  10823. * The position of the object in babylon space.
  10824. */
  10825. position: Vector3;
  10826. /**
  10827. * The rotation quaternion of the object in babylon space.
  10828. */
  10829. rotationQuaternion: Quaternion;
  10830. /**
  10831. * The position of the device in babylon space.
  10832. */
  10833. devicePosition?: Vector3;
  10834. /**
  10835. * The rotation quaternion of the device in babylon space.
  10836. */
  10837. deviceRotationQuaternion: Quaternion;
  10838. /**
  10839. * The raw pose coming from the device.
  10840. */
  10841. rawPose: Nullable<DevicePose>;
  10842. /**
  10843. * The scale of the device to be used when translating from device space to babylon space.
  10844. */
  10845. deviceScaleFactor: number;
  10846. /**
  10847. * Updates the poseControlled values based on the input device pose.
  10848. * @param poseData the pose data to update the object with
  10849. */
  10850. updateFromDevice(poseData: DevicePose): void;
  10851. }
  10852. /**
  10853. * Set of options to customize the webVRCamera
  10854. */
  10855. export interface WebVROptions {
  10856. /**
  10857. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  10858. */
  10859. trackPosition?: boolean;
  10860. /**
  10861. * Sets the scale of the vrDevice in babylon space. (default: 1)
  10862. */
  10863. positionScale?: number;
  10864. /**
  10865. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  10866. */
  10867. displayName?: string;
  10868. /**
  10869. * Should the native controller meshes be initialized. (default: true)
  10870. */
  10871. controllerMeshes?: boolean;
  10872. /**
  10873. * Creating a default HemiLight only on controllers. (default: true)
  10874. */
  10875. defaultLightingOnControllers?: boolean;
  10876. /**
  10877. * If you don't want to use the default VR button of the helper. (default: false)
  10878. */
  10879. useCustomVRButton?: boolean;
  10880. /**
  10881. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  10882. */
  10883. customVRButton?: HTMLButtonElement;
  10884. /**
  10885. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  10886. */
  10887. rayLength?: number;
  10888. /**
  10889. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  10890. */
  10891. defaultHeight?: number;
  10892. }
  10893. /**
  10894. * This represents a WebVR camera.
  10895. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  10896. * @example http://doc.babylonjs.com/how_to/webvr_camera
  10897. */
  10898. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  10899. private webVROptions;
  10900. /**
  10901. * @hidden
  10902. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  10903. */
  10904. _vrDevice: any;
  10905. /**
  10906. * The rawPose of the vrDevice.
  10907. */
  10908. rawPose: Nullable<DevicePose>;
  10909. private _onVREnabled;
  10910. private _specsVersion;
  10911. private _attached;
  10912. private _frameData;
  10913. protected _descendants: Array<Node>;
  10914. private _deviceRoomPosition;
  10915. /** @hidden */
  10916. _deviceRoomRotationQuaternion: Quaternion;
  10917. private _standingMatrix;
  10918. /**
  10919. * Represents device position in babylon space.
  10920. */
  10921. devicePosition: Vector3;
  10922. /**
  10923. * Represents device rotation in babylon space.
  10924. */
  10925. deviceRotationQuaternion: Quaternion;
  10926. /**
  10927. * The scale of the device to be used when translating from device space to babylon space.
  10928. */
  10929. deviceScaleFactor: number;
  10930. private _deviceToWorld;
  10931. private _worldToDevice;
  10932. /**
  10933. * References to the webVR controllers for the vrDevice.
  10934. */
  10935. controllers: Array<WebVRController>;
  10936. /**
  10937. * Emits an event when a controller is attached.
  10938. */
  10939. onControllersAttachedObservable: Observable<WebVRController[]>;
  10940. /**
  10941. * Emits an event when a controller's mesh has been loaded;
  10942. */
  10943. onControllerMeshLoadedObservable: Observable<WebVRController>;
  10944. /**
  10945. * Emits an event when the HMD's pose has been updated.
  10946. */
  10947. onPoseUpdatedFromDeviceObservable: Observable<any>;
  10948. private _poseSet;
  10949. /**
  10950. * If the rig cameras be used as parent instead of this camera.
  10951. */
  10952. rigParenting: boolean;
  10953. private _lightOnControllers;
  10954. private _defaultHeight?;
  10955. /**
  10956. * Instantiates a WebVRFreeCamera.
  10957. * @param name The name of the WebVRFreeCamera
  10958. * @param position The starting anchor position for the camera
  10959. * @param scene The scene the camera belongs to
  10960. * @param webVROptions a set of customizable options for the webVRCamera
  10961. */
  10962. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  10963. /**
  10964. * Gets the device distance from the ground in meters.
  10965. * @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.
  10966. */
  10967. deviceDistanceToRoomGround(): number;
  10968. /**
  10969. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  10970. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  10971. */
  10972. useStandingMatrix(callback?: (bool: boolean) => void): void;
  10973. /**
  10974. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  10975. * @returns A promise with a boolean set to if the standing matrix is supported.
  10976. */
  10977. useStandingMatrixAsync(): Promise<boolean>;
  10978. /**
  10979. * Disposes the camera
  10980. */
  10981. dispose(): void;
  10982. /**
  10983. * Gets a vrController by name.
  10984. * @param name The name of the controller to retreive
  10985. * @returns the controller matching the name specified or null if not found
  10986. */
  10987. getControllerByName(name: string): Nullable<WebVRController>;
  10988. private _leftController;
  10989. /**
  10990. * The controller corrisponding to the users left hand.
  10991. */
  10992. readonly leftController: Nullable<WebVRController>;
  10993. private _rightController;
  10994. /**
  10995. * The controller corrisponding to the users right hand.
  10996. */
  10997. readonly rightController: Nullable<WebVRController>;
  10998. /**
  10999. * Casts a ray forward from the vrCamera's gaze.
  11000. * @param length Length of the ray (default: 100)
  11001. * @returns the ray corrisponding to the gaze
  11002. */
  11003. getForwardRay(length?: number): Ray;
  11004. /**
  11005. * @hidden
  11006. * Updates the camera based on device's frame data
  11007. */
  11008. _checkInputs(): void;
  11009. /**
  11010. * Updates the poseControlled values based on the input device pose.
  11011. * @param poseData Pose coming from the device
  11012. */
  11013. updateFromDevice(poseData: DevicePose): void;
  11014. private _htmlElementAttached;
  11015. private _detachIfAttached;
  11016. /**
  11017. * WebVR's attach control will start broadcasting frames to the device.
  11018. * Note that in certain browsers (chrome for example) this function must be called
  11019. * within a user-interaction callback. Example:
  11020. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  11021. *
  11022. * @param element html element to attach the vrDevice to
  11023. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  11024. */
  11025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11026. /**
  11027. * Detaches the camera from the html element and disables VR
  11028. *
  11029. * @param element html element to detach from
  11030. */
  11031. detachControl(element: HTMLElement): void;
  11032. /**
  11033. * @returns the name of this class
  11034. */
  11035. getClassName(): string;
  11036. /**
  11037. * Calls resetPose on the vrDisplay
  11038. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  11039. */
  11040. resetToCurrentRotation(): void;
  11041. /**
  11042. * @hidden
  11043. * Updates the rig cameras (left and right eye)
  11044. */
  11045. _updateRigCameras(): void;
  11046. private _workingVector;
  11047. private _oneVector;
  11048. private _workingMatrix;
  11049. private updateCacheCalled;
  11050. private _correctPositionIfNotTrackPosition;
  11051. /**
  11052. * @hidden
  11053. * Updates the cached values of the camera
  11054. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  11055. */
  11056. _updateCache(ignoreParentClass?: boolean): void;
  11057. /**
  11058. * @hidden
  11059. * Get current device position in babylon world
  11060. */
  11061. _computeDevicePosition(): void;
  11062. /**
  11063. * Updates the current device position and rotation in the babylon world
  11064. */
  11065. update(): void;
  11066. /**
  11067. * @hidden
  11068. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  11069. * @returns an identity matrix
  11070. */
  11071. _getViewMatrix(): Matrix;
  11072. private _tmpMatrix;
  11073. /**
  11074. * This function is called by the two RIG cameras.
  11075. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  11076. * @hidden
  11077. */
  11078. _getWebVRViewMatrix(): Matrix;
  11079. /** @hidden */
  11080. _getWebVRProjectionMatrix(): Matrix;
  11081. private _onGamepadConnectedObserver;
  11082. private _onGamepadDisconnectedObserver;
  11083. private _updateCacheWhenTrackingDisabledObserver;
  11084. /**
  11085. * Initializes the controllers and their meshes
  11086. */
  11087. initControllers(): void;
  11088. }
  11089. }
  11090. declare module BABYLON {
  11091. /**
  11092. * Size options for a post process
  11093. */
  11094. export type PostProcessOptions = {
  11095. width: number;
  11096. height: number;
  11097. };
  11098. /**
  11099. * PostProcess can be used to apply a shader to a texture after it has been rendered
  11100. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  11101. */
  11102. export class PostProcess {
  11103. /** Name of the PostProcess. */
  11104. name: string;
  11105. /**
  11106. * Width of the texture to apply the post process on
  11107. */
  11108. width: number;
  11109. /**
  11110. * Height of the texture to apply the post process on
  11111. */
  11112. height: number;
  11113. /**
  11114. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  11115. * @hidden
  11116. */
  11117. _outputTexture: Nullable<InternalTexture>;
  11118. /**
  11119. * Sampling mode used by the shader
  11120. * See https://doc.babylonjs.com/classes/3.1/texture
  11121. */
  11122. renderTargetSamplingMode: number;
  11123. /**
  11124. * Clear color to use when screen clearing
  11125. */
  11126. clearColor: Color4;
  11127. /**
  11128. * If the buffer needs to be cleared before applying the post process. (default: true)
  11129. * Should be set to false if shader will overwrite all previous pixels.
  11130. */
  11131. autoClear: boolean;
  11132. /**
  11133. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  11134. */
  11135. alphaMode: number;
  11136. /**
  11137. * Sets the setAlphaBlendConstants of the babylon engine
  11138. */
  11139. alphaConstants: Color4;
  11140. /**
  11141. * Animations to be used for the post processing
  11142. */
  11143. animations: Animation[];
  11144. /**
  11145. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  11146. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  11147. */
  11148. enablePixelPerfectMode: boolean;
  11149. /**
  11150. * Force the postprocess to be applied without taking in account viewport
  11151. */
  11152. forceFullscreenViewport: boolean;
  11153. /**
  11154. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  11155. *
  11156. * | Value | Type | Description |
  11157. * | ----- | ----------------------------------- | ----------- |
  11158. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  11159. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  11160. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  11161. *
  11162. */
  11163. scaleMode: number;
  11164. /**
  11165. * Force textures to be a power of two (default: false)
  11166. */
  11167. alwaysForcePOT: boolean;
  11168. private _samples;
  11169. /**
  11170. * Number of sample textures (default: 1)
  11171. */
  11172. samples: number;
  11173. /**
  11174. * Modify the scale of the post process to be the same as the viewport (default: false)
  11175. */
  11176. adaptScaleToCurrentViewport: boolean;
  11177. private _camera;
  11178. private _scene;
  11179. private _engine;
  11180. private _options;
  11181. private _reusable;
  11182. private _textureType;
  11183. /**
  11184. * Smart array of input and output textures for the post process.
  11185. * @hidden
  11186. */
  11187. _textures: SmartArray<InternalTexture>;
  11188. /**
  11189. * The index in _textures that corresponds to the output texture.
  11190. * @hidden
  11191. */
  11192. _currentRenderTextureInd: number;
  11193. private _effect;
  11194. private _samplers;
  11195. private _fragmentUrl;
  11196. private _vertexUrl;
  11197. private _parameters;
  11198. private _scaleRatio;
  11199. protected _indexParameters: any;
  11200. private _shareOutputWithPostProcess;
  11201. private _texelSize;
  11202. private _forcedOutputTexture;
  11203. /**
  11204. * Returns the fragment url or shader name used in the post process.
  11205. * @returns the fragment url or name in the shader store.
  11206. */
  11207. getEffectName(): string;
  11208. /**
  11209. * An event triggered when the postprocess is activated.
  11210. */
  11211. onActivateObservable: Observable<Camera>;
  11212. private _onActivateObserver;
  11213. /**
  11214. * A function that is added to the onActivateObservable
  11215. */
  11216. onActivate: Nullable<(camera: Camera) => void>;
  11217. /**
  11218. * An event triggered when the postprocess changes its size.
  11219. */
  11220. onSizeChangedObservable: Observable<PostProcess>;
  11221. private _onSizeChangedObserver;
  11222. /**
  11223. * A function that is added to the onSizeChangedObservable
  11224. */
  11225. onSizeChanged: (postProcess: PostProcess) => void;
  11226. /**
  11227. * An event triggered when the postprocess applies its effect.
  11228. */
  11229. onApplyObservable: Observable<Effect>;
  11230. private _onApplyObserver;
  11231. /**
  11232. * A function that is added to the onApplyObservable
  11233. */
  11234. onApply: (effect: Effect) => void;
  11235. /**
  11236. * An event triggered before rendering the postprocess
  11237. */
  11238. onBeforeRenderObservable: Observable<Effect>;
  11239. private _onBeforeRenderObserver;
  11240. /**
  11241. * A function that is added to the onBeforeRenderObservable
  11242. */
  11243. onBeforeRender: (effect: Effect) => void;
  11244. /**
  11245. * An event triggered after rendering the postprocess
  11246. */
  11247. onAfterRenderObservable: Observable<Effect>;
  11248. private _onAfterRenderObserver;
  11249. /**
  11250. * A function that is added to the onAfterRenderObservable
  11251. */
  11252. onAfterRender: (efect: Effect) => void;
  11253. /**
  11254. * 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
  11255. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  11256. */
  11257. inputTexture: InternalTexture;
  11258. /**
  11259. * Gets the camera which post process is applied to.
  11260. * @returns The camera the post process is applied to.
  11261. */
  11262. getCamera(): Camera;
  11263. /**
  11264. * Gets the texel size of the postprocess.
  11265. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  11266. */
  11267. readonly texelSize: Vector2;
  11268. /**
  11269. * Creates a new instance PostProcess
  11270. * @param name The name of the PostProcess.
  11271. * @param fragmentUrl The url of the fragment shader to be used.
  11272. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  11273. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  11274. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  11275. * @param camera The camera to apply the render pass to.
  11276. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  11277. * @param engine The engine which the post process will be applied. (default: current engine)
  11278. * @param reusable If the post process can be reused on the same frame. (default: false)
  11279. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  11280. * @param textureType Type of textures used when performing the post process. (default: 0)
  11281. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  11282. * @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
  11283. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  11284. */
  11285. constructor(
  11286. /** Name of the PostProcess. */
  11287. 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);
  11288. /**
  11289. * Gets the engine which this post process belongs to.
  11290. * @returns The engine the post process was enabled with.
  11291. */
  11292. getEngine(): Engine;
  11293. /**
  11294. * The effect that is created when initializing the post process.
  11295. * @returns The created effect corrisponding the the postprocess.
  11296. */
  11297. getEffect(): Effect;
  11298. /**
  11299. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  11300. * @param postProcess The post process to share the output with.
  11301. * @returns This post process.
  11302. */
  11303. shareOutputWith(postProcess: PostProcess): PostProcess;
  11304. /**
  11305. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  11306. * This should be called if the post process that shares output with this post process is disabled/disposed.
  11307. */
  11308. useOwnOutput(): void;
  11309. /**
  11310. * Updates the effect with the current post process compile time values and recompiles the shader.
  11311. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  11312. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  11313. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  11314. * @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
  11315. * @param onCompiled Called when the shader has been compiled.
  11316. * @param onError Called if there is an error when compiling a shader.
  11317. */
  11318. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  11319. /**
  11320. * The post process is reusable if it can be used multiple times within one frame.
  11321. * @returns If the post process is reusable
  11322. */
  11323. isReusable(): boolean;
  11324. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  11325. markTextureDirty(): void;
  11326. /**
  11327. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  11328. * 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.
  11329. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  11330. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  11331. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  11332. * @returns The target texture that was bound to be written to.
  11333. */
  11334. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  11335. /**
  11336. * If the post process is supported.
  11337. */
  11338. readonly isSupported: boolean;
  11339. /**
  11340. * The aspect ratio of the output texture.
  11341. */
  11342. readonly aspectRatio: number;
  11343. /**
  11344. * Get a value indicating if the post-process is ready to be used
  11345. * @returns true if the post-process is ready (shader is compiled)
  11346. */
  11347. isReady(): boolean;
  11348. /**
  11349. * Binds all textures and uniforms to the shader, this will be run on every pass.
  11350. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  11351. */
  11352. apply(): Nullable<Effect>;
  11353. private _disposeTextures;
  11354. /**
  11355. * Disposes the post process.
  11356. * @param camera The camera to dispose the post process on.
  11357. */
  11358. dispose(camera?: Camera): void;
  11359. }
  11360. }
  11361. declare module BABYLON {
  11362. /** @hidden */
  11363. export var kernelBlurVaryingDeclaration: {
  11364. name: string;
  11365. shader: string;
  11366. };
  11367. }
  11368. declare module BABYLON {
  11369. /** @hidden */
  11370. export var kernelBlurFragment: {
  11371. name: string;
  11372. shader: string;
  11373. };
  11374. }
  11375. declare module BABYLON {
  11376. /** @hidden */
  11377. export var kernelBlurFragment2: {
  11378. name: string;
  11379. shader: string;
  11380. };
  11381. }
  11382. declare module BABYLON {
  11383. /** @hidden */
  11384. export var kernelBlurPixelShader: {
  11385. name: string;
  11386. shader: string;
  11387. };
  11388. }
  11389. declare module BABYLON {
  11390. /** @hidden */
  11391. export var kernelBlurVertex: {
  11392. name: string;
  11393. shader: string;
  11394. };
  11395. }
  11396. declare module BABYLON {
  11397. /** @hidden */
  11398. export var kernelBlurVertexShader: {
  11399. name: string;
  11400. shader: string;
  11401. };
  11402. }
  11403. declare module BABYLON {
  11404. /**
  11405. * The Blur Post Process which blurs an image based on a kernel and direction.
  11406. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  11407. */
  11408. export class BlurPostProcess extends PostProcess {
  11409. /** The direction in which to blur the image. */
  11410. direction: Vector2;
  11411. private blockCompilation;
  11412. protected _kernel: number;
  11413. protected _idealKernel: number;
  11414. protected _packedFloat: boolean;
  11415. private _staticDefines;
  11416. /**
  11417. * Sets the length in pixels of the blur sample region
  11418. */
  11419. /**
  11420. * Gets the length in pixels of the blur sample region
  11421. */
  11422. kernel: number;
  11423. /**
  11424. * Sets wether or not the blur needs to unpack/repack floats
  11425. */
  11426. /**
  11427. * Gets wether or not the blur is unpacking/repacking floats
  11428. */
  11429. packedFloat: boolean;
  11430. /**
  11431. * Creates a new instance BlurPostProcess
  11432. * @param name The name of the effect.
  11433. * @param direction The direction in which to blur the image.
  11434. * @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.
  11435. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  11436. * @param camera The camera to apply the render pass to.
  11437. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  11438. * @param engine The engine which the post process will be applied. (default: current engine)
  11439. * @param reusable If the post process can be reused on the same frame. (default: false)
  11440. * @param textureType Type of textures used when performing the post process. (default: 0)
  11441. * @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)
  11442. */
  11443. constructor(name: string,
  11444. /** The direction in which to blur the image. */
  11445. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  11446. /**
  11447. * Updates the effect with the current post process compile time values and recompiles the shader.
  11448. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  11449. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  11450. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  11451. * @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
  11452. * @param onCompiled Called when the shader has been compiled.
  11453. * @param onError Called if there is an error when compiling a shader.
  11454. */
  11455. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  11456. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  11457. /**
  11458. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  11459. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  11460. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  11461. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  11462. * The gaps between physical kernels are compensated for in the weighting of the samples
  11463. * @param idealKernel Ideal blur kernel.
  11464. * @return Nearest best kernel.
  11465. */
  11466. protected _nearestBestKernel(idealKernel: number): number;
  11467. /**
  11468. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  11469. * @param x The point on the Gaussian distribution to sample.
  11470. * @return the value of the Gaussian function at x.
  11471. */
  11472. protected _gaussianWeight(x: number): number;
  11473. /**
  11474. * Generates a string that can be used as a floating point number in GLSL.
  11475. * @param x Value to print.
  11476. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  11477. * @return GLSL float string.
  11478. */
  11479. protected _glslFloat(x: number, decimalFigures?: number): string;
  11480. }
  11481. }
  11482. declare module BABYLON {
  11483. /**
  11484. * Mirror texture can be used to simulate the view from a mirror in a scene.
  11485. * It will dynamically be rendered every frame to adapt to the camera point of view.
  11486. * You can then easily use it as a reflectionTexture on a flat surface.
  11487. * In case the surface is not a plane, please consider relying on reflection probes.
  11488. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  11489. */
  11490. export class MirrorTexture extends RenderTargetTexture {
  11491. private scene;
  11492. /**
  11493. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  11494. * It is possible to directly set the mirrorPlane by directly using a 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.
  11495. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  11496. */
  11497. mirrorPlane: Plane;
  11498. /**
  11499. * Define the blur ratio used to blur the reflection if needed.
  11500. */
  11501. blurRatio: number;
  11502. /**
  11503. * Define the adaptive blur kernel used to blur the reflection if needed.
  11504. * This will autocompute the closest best match for the `blurKernel`
  11505. */
  11506. adaptiveBlurKernel: number;
  11507. /**
  11508. * Define the blur kernel used to blur the reflection if needed.
  11509. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  11510. */
  11511. blurKernel: number;
  11512. /**
  11513. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  11514. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  11515. */
  11516. blurKernelX: number;
  11517. /**
  11518. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  11519. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  11520. */
  11521. blurKernelY: number;
  11522. private _autoComputeBlurKernel;
  11523. protected _onRatioRescale(): void;
  11524. private _updateGammaSpace;
  11525. private _imageProcessingConfigChangeObserver;
  11526. private _transformMatrix;
  11527. private _mirrorMatrix;
  11528. private _savedViewMatrix;
  11529. private _blurX;
  11530. private _blurY;
  11531. private _adaptiveBlurKernel;
  11532. private _blurKernelX;
  11533. private _blurKernelY;
  11534. private _blurRatio;
  11535. /**
  11536. * Instantiates a Mirror Texture.
  11537. * Mirror texture can be used to simulate the view from a mirror in a scene.
  11538. * It will dynamically be rendered every frame to adapt to the camera point of view.
  11539. * You can then easily use it as a reflectionTexture on a flat surface.
  11540. * In case the surface is not a plane, please consider relying on reflection probes.
  11541. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  11542. * @param name
  11543. * @param size
  11544. * @param scene
  11545. * @param generateMipMaps
  11546. * @param type
  11547. * @param samplingMode
  11548. * @param generateDepthBuffer
  11549. */
  11550. constructor(name: string, size: number | {
  11551. width: number;
  11552. height: number;
  11553. } | {
  11554. ratio: number;
  11555. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  11556. private _preparePostProcesses;
  11557. /**
  11558. * Clone the mirror texture.
  11559. * @returns the cloned texture
  11560. */
  11561. clone(): MirrorTexture;
  11562. /**
  11563. * Serialize the texture to a JSON representation you could use in Parse later on
  11564. * @returns the serialized JSON representation
  11565. */
  11566. serialize(): any;
  11567. /**
  11568. * Dispose the texture and release its associated resources.
  11569. */
  11570. dispose(): void;
  11571. }
  11572. }
  11573. declare module BABYLON {
  11574. /**
  11575. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  11576. * @see http://doc.babylonjs.com/babylon101/materials#texture
  11577. */
  11578. export class Texture extends BaseTexture {
  11579. /** @hidden */
  11580. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  11581. /** @hidden */
  11582. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  11583. /** @hidden */
  11584. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  11585. /** nearest is mag = nearest and min = nearest and mip = linear */
  11586. static readonly NEAREST_SAMPLINGMODE: number;
  11587. /** nearest is mag = nearest and min = nearest and mip = linear */
  11588. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  11589. /** Bilinear is mag = linear and min = linear and mip = nearest */
  11590. static readonly BILINEAR_SAMPLINGMODE: number;
  11591. /** Bilinear is mag = linear and min = linear and mip = nearest */
  11592. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  11593. /** Trilinear is mag = linear and min = linear and mip = linear */
  11594. static readonly TRILINEAR_SAMPLINGMODE: number;
  11595. /** Trilinear is mag = linear and min = linear and mip = linear */
  11596. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  11597. /** mag = nearest and min = nearest and mip = nearest */
  11598. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  11599. /** mag = nearest and min = linear and mip = nearest */
  11600. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  11601. /** mag = nearest and min = linear and mip = linear */
  11602. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  11603. /** mag = nearest and min = linear and mip = none */
  11604. static readonly NEAREST_LINEAR: number;
  11605. /** mag = nearest and min = nearest and mip = none */
  11606. static readonly NEAREST_NEAREST: number;
  11607. /** mag = linear and min = nearest and mip = nearest */
  11608. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  11609. /** mag = linear and min = nearest and mip = linear */
  11610. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  11611. /** mag = linear and min = linear and mip = none */
  11612. static readonly LINEAR_LINEAR: number;
  11613. /** mag = linear and min = nearest and mip = none */
  11614. static readonly LINEAR_NEAREST: number;
  11615. /** Explicit coordinates mode */
  11616. static readonly EXPLICIT_MODE: number;
  11617. /** Spherical coordinates mode */
  11618. static readonly SPHERICAL_MODE: number;
  11619. /** Planar coordinates mode */
  11620. static readonly PLANAR_MODE: number;
  11621. /** Cubic coordinates mode */
  11622. static readonly CUBIC_MODE: number;
  11623. /** Projection coordinates mode */
  11624. static readonly PROJECTION_MODE: number;
  11625. /** Inverse Cubic coordinates mode */
  11626. static readonly SKYBOX_MODE: number;
  11627. /** Inverse Cubic coordinates mode */
  11628. static readonly INVCUBIC_MODE: number;
  11629. /** Equirectangular coordinates mode */
  11630. static readonly EQUIRECTANGULAR_MODE: number;
  11631. /** Equirectangular Fixed coordinates mode */
  11632. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  11633. /** Equirectangular Fixed Mirrored coordinates mode */
  11634. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  11635. /** Texture is not repeating outside of 0..1 UVs */
  11636. static readonly CLAMP_ADDRESSMODE: number;
  11637. /** Texture is repeating outside of 0..1 UVs */
  11638. static readonly WRAP_ADDRESSMODE: number;
  11639. /** Texture is repeating and mirrored */
  11640. static readonly MIRROR_ADDRESSMODE: number;
  11641. /**
  11642. * 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
  11643. */
  11644. static UseSerializedUrlIfAny: boolean;
  11645. /**
  11646. * Define the url of the texture.
  11647. */
  11648. url: Nullable<string>;
  11649. /**
  11650. * Define an offset on the texture to offset the u coordinates of the UVs
  11651. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  11652. */
  11653. uOffset: number;
  11654. /**
  11655. * Define an offset on the texture to offset the v coordinates of the UVs
  11656. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  11657. */
  11658. vOffset: number;
  11659. /**
  11660. * Define an offset on the texture to scale the u coordinates of the UVs
  11661. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  11662. */
  11663. uScale: number;
  11664. /**
  11665. * Define an offset on the texture to scale the v coordinates of the UVs
  11666. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  11667. */
  11668. vScale: number;
  11669. /**
  11670. * Define an offset on the texture to rotate around the u coordinates of the UVs
  11671. * @see http://doc.babylonjs.com/how_to/more_materials
  11672. */
  11673. uAng: number;
  11674. /**
  11675. * Define an offset on the texture to rotate around the v coordinates of the UVs
  11676. * @see http://doc.babylonjs.com/how_to/more_materials
  11677. */
  11678. vAng: number;
  11679. /**
  11680. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  11681. * @see http://doc.babylonjs.com/how_to/more_materials
  11682. */
  11683. wAng: number;
  11684. /**
  11685. * Defines the center of rotation (U)
  11686. */
  11687. uRotationCenter: number;
  11688. /**
  11689. * Defines the center of rotation (V)
  11690. */
  11691. vRotationCenter: number;
  11692. /**
  11693. * Defines the center of rotation (W)
  11694. */
  11695. wRotationCenter: number;
  11696. /**
  11697. * Are mip maps generated for this texture or not.
  11698. */
  11699. readonly noMipmap: boolean;
  11700. private _noMipmap;
  11701. /** @hidden */
  11702. _invertY: boolean;
  11703. private _rowGenerationMatrix;
  11704. private _cachedTextureMatrix;
  11705. private _projectionModeMatrix;
  11706. private _t0;
  11707. private _t1;
  11708. private _t2;
  11709. private _cachedUOffset;
  11710. private _cachedVOffset;
  11711. private _cachedUScale;
  11712. private _cachedVScale;
  11713. private _cachedUAng;
  11714. private _cachedVAng;
  11715. private _cachedWAng;
  11716. private _cachedProjectionMatrixId;
  11717. private _cachedCoordinatesMode;
  11718. /** @hidden */
  11719. protected _initialSamplingMode: number;
  11720. /** @hidden */
  11721. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  11722. private _deleteBuffer;
  11723. protected _format: Nullable<number>;
  11724. private _delayedOnLoad;
  11725. private _delayedOnError;
  11726. /**
  11727. * Observable triggered once the texture has been loaded.
  11728. */
  11729. onLoadObservable: Observable<Texture>;
  11730. protected _isBlocking: boolean;
  11731. /**
  11732. * Is the texture preventing material to render while loading.
  11733. * If false, a default texture will be used instead of the loading one during the preparation step.
  11734. */
  11735. isBlocking: boolean;
  11736. /**
  11737. * Get the current sampling mode associated with the texture.
  11738. */
  11739. readonly samplingMode: number;
  11740. /**
  11741. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  11742. */
  11743. readonly invertY: boolean;
  11744. /**
  11745. * Instantiates a new texture.
  11746. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  11747. * @see http://doc.babylonjs.com/babylon101/materials#texture
  11748. * @param url define the url of the picture to load as a texture
  11749. * @param scene define the scene the texture will belong to
  11750. * @param noMipmap define if the texture will require mip maps or not
  11751. * @param invertY define if the texture needs to be inverted on the y axis during loading
  11752. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  11753. * @param onLoad define a callback triggered when the texture has been loaded
  11754. * @param onError define a callback triggered when an error occurred during the loading session
  11755. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  11756. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  11757. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  11758. */
  11759. 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);
  11760. /**
  11761. * Update the url (and optional buffer) of this texture if url was null during construction.
  11762. * @param url the url of the texture
  11763. * @param buffer the buffer of the texture (defaults to null)
  11764. * @param onLoad callback called when the texture is loaded (defaults to null)
  11765. */
  11766. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  11767. /**
  11768. * Finish the loading sequence of a texture flagged as delayed load.
  11769. * @hidden
  11770. */
  11771. delayLoad(): void;
  11772. private _prepareRowForTextureGeneration;
  11773. /**
  11774. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  11775. * @returns the transform matrix of the texture.
  11776. */
  11777. getTextureMatrix(): Matrix;
  11778. /**
  11779. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  11780. * @returns The reflection texture transform
  11781. */
  11782. getReflectionTextureMatrix(): Matrix;
  11783. /**
  11784. * Clones the texture.
  11785. * @returns the cloned texture
  11786. */
  11787. clone(): Texture;
  11788. /**
  11789. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  11790. * @returns The JSON representation of the texture
  11791. */
  11792. serialize(): any;
  11793. /**
  11794. * Get the current class name of the texture useful for serialization or dynamic coding.
  11795. * @returns "Texture"
  11796. */
  11797. getClassName(): string;
  11798. /**
  11799. * Dispose the texture and release its associated resources.
  11800. */
  11801. dispose(): void;
  11802. /**
  11803. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  11804. * @param parsedTexture Define the JSON representation of the texture
  11805. * @param scene Define the scene the parsed texture should be instantiated in
  11806. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  11807. * @returns The parsed texture if successful
  11808. */
  11809. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  11810. /**
  11811. * Creates a texture from its base 64 representation.
  11812. * @param data Define the base64 payload without the data: prefix
  11813. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  11814. * @param scene Define the scene the texture should belong to
  11815. * @param noMipmap Forces the texture to not create mip map information if true
  11816. * @param invertY define if the texture needs to be inverted on the y axis during loading
  11817. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  11818. * @param onLoad define a callback triggered when the texture has been loaded
  11819. * @param onError define a callback triggered when an error occurred during the loading session
  11820. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  11821. * @returns the created texture
  11822. */
  11823. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  11824. /**
  11825. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  11826. * @param data Define the base64 payload without the data: prefix
  11827. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  11828. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  11829. * @param scene Define the scene the texture should belong to
  11830. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  11831. * @param noMipmap Forces the texture to not create mip map information if true
  11832. * @param invertY define if the texture needs to be inverted on the y axis during loading
  11833. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  11834. * @param onLoad define a callback triggered when the texture has been loaded
  11835. * @param onError define a callback triggered when an error occurred during the loading session
  11836. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  11837. * @returns the created texture
  11838. */
  11839. 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;
  11840. }
  11841. }
  11842. declare module BABYLON {
  11843. /**
  11844. * PostProcessManager is used to manage one or more post processes or post process pipelines
  11845. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  11846. */
  11847. export class PostProcessManager {
  11848. private _scene;
  11849. private _indexBuffer;
  11850. private _vertexBuffers;
  11851. /**
  11852. * Creates a new instance PostProcess
  11853. * @param scene The scene that the post process is associated with.
  11854. */
  11855. constructor(scene: Scene);
  11856. private _prepareBuffers;
  11857. private _buildIndexBuffer;
  11858. /**
  11859. * Rebuilds the vertex buffers of the manager.
  11860. * @hidden
  11861. */
  11862. _rebuild(): void;
  11863. /**
  11864. * Prepares a frame to be run through a post process.
  11865. * @param sourceTexture The input texture to the post procesess. (default: null)
  11866. * @param postProcesses An array of post processes to be run. (default: null)
  11867. * @returns True if the post processes were able to be run.
  11868. * @hidden
  11869. */
  11870. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  11871. /**
  11872. * Manually render a set of post processes to a texture.
  11873. * @param postProcesses An array of post processes to be run.
  11874. * @param targetTexture The target texture to render to.
  11875. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  11876. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  11877. * @param lodLevel defines which lod of the texture to render to
  11878. */
  11879. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  11880. /**
  11881. * Finalize the result of the output of the postprocesses.
  11882. * @param doNotPresent If true the result will not be displayed to the screen.
  11883. * @param targetTexture The target texture to render to.
  11884. * @param faceIndex The index of the face to bind the target texture to.
  11885. * @param postProcesses The array of post processes to render.
  11886. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  11887. * @hidden
  11888. */
  11889. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  11890. /**
  11891. * Disposes of the post process manager.
  11892. */
  11893. dispose(): void;
  11894. }
  11895. }
  11896. declare module BABYLON {
  11897. /**
  11898. * Groups all the scene component constants in one place to ease maintenance.
  11899. * @hidden
  11900. */
  11901. export class SceneComponentConstants {
  11902. static readonly NAME_EFFECTLAYER: string;
  11903. static readonly NAME_LAYER: string;
  11904. static readonly NAME_LENSFLARESYSTEM: string;
  11905. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11906. static readonly NAME_PARTICLESYSTEM: string;
  11907. static readonly NAME_GAMEPAD: string;
  11908. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11909. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11910. static readonly NAME_DEPTHRENDERER: string;
  11911. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11912. static readonly NAME_SPRITE: string;
  11913. static readonly NAME_OUTLINERENDERER: string;
  11914. static readonly NAME_PROCEDURALTEXTURE: string;
  11915. static readonly NAME_SHADOWGENERATOR: string;
  11916. static readonly NAME_OCTREE: string;
  11917. static readonly NAME_PHYSICSENGINE: string;
  11918. static readonly NAME_AUDIO: string;
  11919. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11920. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11921. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11922. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11923. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11924. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11925. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11926. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11927. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11928. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11929. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11930. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11931. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11932. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11933. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11934. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11935. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11936. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11937. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11938. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11939. static readonly STEP_AFTERRENDER_AUDIO: number;
  11940. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11941. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11942. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11943. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11944. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11945. static readonly STEP_POINTERMOVE_SPRITE: number;
  11946. static readonly STEP_POINTERDOWN_SPRITE: number;
  11947. static readonly STEP_POINTERUP_SPRITE: number;
  11948. }
  11949. /**
  11950. * This represents a scene component.
  11951. *
  11952. * This is used to decouple the dependency the scene is having on the different workloads like
  11953. * layers, post processes...
  11954. */
  11955. export interface ISceneComponent {
  11956. /**
  11957. * The name of the component. Each component must have a unique name.
  11958. */
  11959. name: string;
  11960. /**
  11961. * The scene the component belongs to.
  11962. */
  11963. scene: Scene;
  11964. /**
  11965. * Register the component to one instance of a scene.
  11966. */
  11967. register(): void;
  11968. /**
  11969. * Rebuilds the elements related to this component in case of
  11970. * context lost for instance.
  11971. */
  11972. rebuild(): void;
  11973. /**
  11974. * Disposes the component and the associated ressources.
  11975. */
  11976. dispose(): void;
  11977. }
  11978. /**
  11979. * This represents a SERIALIZABLE scene component.
  11980. *
  11981. * This extends Scene Component to add Serialization methods on top.
  11982. */
  11983. export interface ISceneSerializableComponent extends ISceneComponent {
  11984. /**
  11985. * Adds all the element from the container to the scene
  11986. * @param container the container holding the elements
  11987. */
  11988. addFromContainer(container: AbstractScene): void;
  11989. /**
  11990. * Removes all the elements in the container from the scene
  11991. * @param container contains the elements to remove
  11992. */
  11993. removeFromContainer(container: AbstractScene): void;
  11994. /**
  11995. * Serializes the component data to the specified json object
  11996. * @param serializationObject The object to serialize to
  11997. */
  11998. serialize(serializationObject: any): void;
  11999. }
  12000. /**
  12001. * Strong typing of a Mesh related stage step action
  12002. */
  12003. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  12004. /**
  12005. * Strong typing of a Evaluate Sub Mesh related stage step action
  12006. */
  12007. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  12008. /**
  12009. * Strong typing of a Active Mesh related stage step action
  12010. */
  12011. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  12012. /**
  12013. * Strong typing of a Camera related stage step action
  12014. */
  12015. export type CameraStageAction = (camera: Camera) => void;
  12016. /**
  12017. * Strong typing of a Render Target related stage step action
  12018. */
  12019. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  12020. /**
  12021. * Strong typing of a RenderingGroup related stage step action
  12022. */
  12023. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  12024. /**
  12025. * Strong typing of a Mesh Render related stage step action
  12026. */
  12027. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  12028. /**
  12029. * Strong typing of a simple stage step action
  12030. */
  12031. export type SimpleStageAction = () => void;
  12032. /**
  12033. * Strong typing of a render target action.
  12034. */
  12035. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  12036. /**
  12037. * Strong typing of a pointer move action.
  12038. */
  12039. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  12040. /**
  12041. * Strong typing of a pointer up/down action.
  12042. */
  12043. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  12044. /**
  12045. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  12046. * @hidden
  12047. */
  12048. export class Stage<T extends Function> extends Array<{
  12049. index: number;
  12050. component: ISceneComponent;
  12051. action: T;
  12052. }> {
  12053. /**
  12054. * Hide ctor from the rest of the world.
  12055. * @param items The items to add.
  12056. */
  12057. private constructor();
  12058. /**
  12059. * Creates a new Stage.
  12060. * @returns A new instance of a Stage
  12061. */
  12062. static Create<T extends Function>(): Stage<T>;
  12063. /**
  12064. * Registers a step in an ordered way in the targeted stage.
  12065. * @param index Defines the position to register the step in
  12066. * @param component Defines the component attached to the step
  12067. * @param action Defines the action to launch during the step
  12068. */
  12069. registerStep(index: number, component: ISceneComponent, action: T): void;
  12070. /**
  12071. * Clears all the steps from the stage.
  12072. */
  12073. clear(): void;
  12074. }
  12075. }
  12076. declare module BABYLON {
  12077. interface Scene {
  12078. /** @hidden */
  12079. _pointerOverSprite: Nullable<Sprite>;
  12080. /** @hidden */
  12081. _pickedDownSprite: Nullable<Sprite>;
  12082. /** @hidden */
  12083. _tempSpritePickingRay: Nullable<Ray>;
  12084. /**
  12085. * All of the sprite managers added to this scene
  12086. * @see http://doc.babylonjs.com/babylon101/sprites
  12087. */
  12088. spriteManagers: Array<ISpriteManager>;
  12089. /**
  12090. * An event triggered when sprites rendering is about to start
  12091. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  12092. */
  12093. onBeforeSpritesRenderingObservable: Observable<Scene>;
  12094. /**
  12095. * An event triggered when sprites rendering is done
  12096. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  12097. */
  12098. onAfterSpritesRenderingObservable: Observable<Scene>;
  12099. /** @hidden */
  12100. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12101. /** Launch a ray to try to pick a sprite in the scene
  12102. * @param x position on screen
  12103. * @param y position on screen
  12104. * @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
  12105. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  12106. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  12107. * @returns a PickingInfo
  12108. */
  12109. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12110. /** Use the given ray to pick a sprite in the scene
  12111. * @param ray The ray (in world space) to use to pick meshes
  12112. * @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
  12113. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  12114. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  12115. * @returns a PickingInfo
  12116. */
  12117. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12118. /**
  12119. * Force the sprite under the pointer
  12120. * @param sprite defines the sprite to use
  12121. */
  12122. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  12123. /**
  12124. * Gets the sprite under the pointer
  12125. * @returns a Sprite or null if no sprite is under the pointer
  12126. */
  12127. getPointerOverSprite(): Nullable<Sprite>;
  12128. }
  12129. /**
  12130. * Defines the sprite scene component responsible to manage sprites
  12131. * in a given scene.
  12132. */
  12133. export class SpriteSceneComponent implements ISceneComponent {
  12134. /**
  12135. * The component name helpfull to identify the component in the list of scene components.
  12136. */
  12137. readonly name: string;
  12138. /**
  12139. * The scene the component belongs to.
  12140. */
  12141. scene: Scene;
  12142. /** @hidden */
  12143. private _spritePredicate;
  12144. /**
  12145. * Creates a new instance of the component for the given scene
  12146. * @param scene Defines the scene to register the component in
  12147. */
  12148. constructor(scene: Scene);
  12149. /**
  12150. * Registers the component in a given scene
  12151. */
  12152. register(): void;
  12153. /**
  12154. * Rebuilds the elements related to this component in case of
  12155. * context lost for instance.
  12156. */
  12157. rebuild(): void;
  12158. /**
  12159. * Disposes the component and the associated ressources.
  12160. */
  12161. dispose(): void;
  12162. private _pickSpriteButKeepRay;
  12163. private _pointerMove;
  12164. private _pointerDown;
  12165. private _pointerUp;
  12166. }
  12167. }
  12168. declare module BABYLON {
  12169. /** @hidden */
  12170. export var fogFragmentDeclaration: {
  12171. name: string;
  12172. shader: string;
  12173. };
  12174. }
  12175. declare module BABYLON {
  12176. /** @hidden */
  12177. export var fogFragment: {
  12178. name: string;
  12179. shader: string;
  12180. };
  12181. }
  12182. declare module BABYLON {
  12183. /** @hidden */
  12184. export var spritesPixelShader: {
  12185. name: string;
  12186. shader: string;
  12187. };
  12188. }
  12189. declare module BABYLON {
  12190. /** @hidden */
  12191. export var fogVertexDeclaration: {
  12192. name: string;
  12193. shader: string;
  12194. };
  12195. }
  12196. declare module BABYLON {
  12197. /** @hidden */
  12198. export var spritesVertexShader: {
  12199. name: string;
  12200. shader: string;
  12201. };
  12202. }
  12203. declare module BABYLON {
  12204. /**
  12205. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12206. */
  12207. export interface ISpriteManager extends IDisposable {
  12208. /**
  12209. * Restricts the camera to viewing objects with the same layerMask.
  12210. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12211. */
  12212. layerMask: number;
  12213. /**
  12214. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12215. */
  12216. isPickable: boolean;
  12217. /**
  12218. * Specifies the rendering group id for this mesh (0 by default)
  12219. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12220. */
  12221. renderingGroupId: number;
  12222. /**
  12223. * Defines the list of sprites managed by the manager.
  12224. */
  12225. sprites: Array<Sprite>;
  12226. /**
  12227. * Tests the intersection of a sprite with a specific ray.
  12228. * @param ray The ray we are sending to test the collision
  12229. * @param camera The camera space we are sending rays in
  12230. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12231. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12232. * @returns picking info or null.
  12233. */
  12234. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12235. /**
  12236. * Renders the list of sprites on screen.
  12237. */
  12238. render(): void;
  12239. }
  12240. /**
  12241. * Class used to manage multiple sprites on the same spritesheet
  12242. * @see http://doc.babylonjs.com/babylon101/sprites
  12243. */
  12244. export class SpriteManager implements ISpriteManager {
  12245. /** defines the manager's name */
  12246. name: string;
  12247. /** Gets the list of sprites */
  12248. sprites: Sprite[];
  12249. /** Gets or sets the rendering group id (0 by default) */
  12250. renderingGroupId: number;
  12251. /** Gets or sets camera layer mask */
  12252. layerMask: number;
  12253. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12254. fogEnabled: boolean;
  12255. /** Gets or sets a boolean indicating if the sprites are pickable */
  12256. isPickable: boolean;
  12257. /** Defines the default width of a cell in the spritesheet */
  12258. cellWidth: number;
  12259. /** Defines the default height of a cell in the spritesheet */
  12260. cellHeight: number;
  12261. /**
  12262. * An event triggered when the manager is disposed.
  12263. */
  12264. onDisposeObservable: Observable<SpriteManager>;
  12265. private _onDisposeObserver;
  12266. /**
  12267. * Callback called when the manager is disposed
  12268. */
  12269. onDispose: () => void;
  12270. private _capacity;
  12271. private _spriteTexture;
  12272. private _epsilon;
  12273. private _scene;
  12274. private _vertexData;
  12275. private _buffer;
  12276. private _vertexBuffers;
  12277. private _indexBuffer;
  12278. private _effectBase;
  12279. private _effectFog;
  12280. /**
  12281. * Gets or sets the spritesheet texture
  12282. */
  12283. texture: Texture;
  12284. /**
  12285. * Creates a new sprite manager
  12286. * @param name defines the manager's name
  12287. * @param imgUrl defines the sprite sheet url
  12288. * @param capacity defines the maximum allowed number of sprites
  12289. * @param cellSize defines the size of a sprite cell
  12290. * @param scene defines the hosting scene
  12291. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12292. * @param samplingMode defines the smapling mode to use with spritesheet
  12293. */
  12294. constructor(
  12295. /** defines the manager's name */
  12296. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12297. private _appendSpriteVertex;
  12298. /**
  12299. * Intersects the sprites with a ray
  12300. * @param ray defines the ray to intersect with
  12301. * @param camera defines the current active camera
  12302. * @param predicate defines a predicate used to select candidate sprites
  12303. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12304. * @returns null if no hit or a PickingInfo
  12305. */
  12306. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12307. /**
  12308. * Render all child sprites
  12309. */
  12310. render(): void;
  12311. /**
  12312. * Release associated resources
  12313. */
  12314. dispose(): void;
  12315. }
  12316. }
  12317. declare module BABYLON {
  12318. /**
  12319. * Raw texture can help creating a texture directly from an array of data.
  12320. * This can be super useful if you either get the data from an uncompressed source or
  12321. * if you wish to create your texture pixel by pixel.
  12322. */
  12323. export class RawTexture extends Texture {
  12324. /**
  12325. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12326. */
  12327. format: number;
  12328. private _engine;
  12329. /**
  12330. * Instantiates a new RawTexture.
  12331. * Raw texture can help creating a texture directly from an array of data.
  12332. * This can be super useful if you either get the data from an uncompressed source or
  12333. * if you wish to create your texture pixel by pixel.
  12334. * @param data define the array of data to use to create the texture
  12335. * @param width define the width of the texture
  12336. * @param height define the height of the texture
  12337. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12338. * @param scene define the scene the texture belongs to
  12339. * @param generateMipMaps define whether mip maps should be generated or not
  12340. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12341. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12342. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12343. */
  12344. constructor(data: ArrayBufferView, width: number, height: number,
  12345. /**
  12346. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12347. */
  12348. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12349. /**
  12350. * Updates the texture underlying data.
  12351. * @param data Define the new data of the texture
  12352. */
  12353. update(data: ArrayBufferView): void;
  12354. /**
  12355. * Creates a luminance texture from some data.
  12356. * @param data Define the texture data
  12357. * @param width Define the width of the texture
  12358. * @param height Define the height of the texture
  12359. * @param scene Define the scene the texture belongs to
  12360. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12361. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12362. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12363. * @returns the luminance texture
  12364. */
  12365. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12366. /**
  12367. * Creates a luminance alpha texture from some data.
  12368. * @param data Define the texture data
  12369. * @param width Define the width of the texture
  12370. * @param height Define the height of the texture
  12371. * @param scene Define the scene the texture belongs to
  12372. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12373. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12374. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12375. * @returns the luminance alpha texture
  12376. */
  12377. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12378. /**
  12379. * Creates an alpha texture from some data.
  12380. * @param data Define the texture data
  12381. * @param width Define the width of the texture
  12382. * @param height Define the height of the texture
  12383. * @param scene Define the scene the texture belongs to
  12384. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12385. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12386. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12387. * @returns the alpha texture
  12388. */
  12389. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12390. /**
  12391. * Creates a RGB texture from some data.
  12392. * @param data Define the texture data
  12393. * @param width Define the width of the texture
  12394. * @param height Define the height of the texture
  12395. * @param scene Define the scene the texture belongs to
  12396. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12397. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12398. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12399. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12400. * @returns the RGB alpha texture
  12401. */
  12402. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12403. /**
  12404. * Creates a RGBA texture from some data.
  12405. * @param data Define the texture data
  12406. * @param width Define the width of the texture
  12407. * @param height Define the height of the texture
  12408. * @param scene Define the scene the texture belongs to
  12409. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12410. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12411. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12412. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12413. * @returns the RGBA texture
  12414. */
  12415. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12416. /**
  12417. * Creates a R texture from some data.
  12418. * @param data Define the texture data
  12419. * @param width Define the width of the texture
  12420. * @param height Define the height of the texture
  12421. * @param scene Define the scene the texture belongs to
  12422. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12423. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12424. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12425. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12426. * @returns the R texture
  12427. */
  12428. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12429. }
  12430. }
  12431. declare module BABYLON {
  12432. interface AbstractScene {
  12433. /**
  12434. * The list of layers (background and foreground) of the scene
  12435. */
  12436. layers: Array<Layer>;
  12437. }
  12438. /**
  12439. * Defines the layer scene component responsible to manage any layers
  12440. * in a given scene.
  12441. */
  12442. export class LayerSceneComponent implements ISceneComponent {
  12443. /**
  12444. * The component name helpfull to identify the component in the list of scene components.
  12445. */
  12446. readonly name: string;
  12447. /**
  12448. * The scene the component belongs to.
  12449. */
  12450. scene: Scene;
  12451. private _engine;
  12452. /**
  12453. * Creates a new instance of the component for the given scene
  12454. * @param scene Defines the scene to register the component in
  12455. */
  12456. constructor(scene: Scene);
  12457. /**
  12458. * Registers the component in a given scene
  12459. */
  12460. register(): void;
  12461. /**
  12462. * Rebuilds the elements related to this component in case of
  12463. * context lost for instance.
  12464. */
  12465. rebuild(): void;
  12466. /**
  12467. * Disposes the component and the associated ressources.
  12468. */
  12469. dispose(): void;
  12470. private _draw;
  12471. private _drawCameraPredicate;
  12472. private _drawCameraBackground;
  12473. private _drawCameraForeground;
  12474. private _drawRenderTargetPredicate;
  12475. private _drawRenderTargetBackground;
  12476. private _drawRenderTargetForeground;
  12477. }
  12478. }
  12479. declare module BABYLON {
  12480. /** @hidden */
  12481. export var layerPixelShader: {
  12482. name: string;
  12483. shader: string;
  12484. };
  12485. }
  12486. declare module BABYLON {
  12487. /** @hidden */
  12488. export var layerVertexShader: {
  12489. name: string;
  12490. shader: string;
  12491. };
  12492. }
  12493. declare module BABYLON {
  12494. /**
  12495. * This represents a full screen 2d layer.
  12496. * This can be useful to display a picture in the background of your scene for instance.
  12497. * @see https://www.babylonjs-playground.com/#08A2BS#1
  12498. */
  12499. export class Layer {
  12500. /**
  12501. * Define the name of the layer.
  12502. */
  12503. name: string;
  12504. /**
  12505. * Define the texture the layer should display.
  12506. */
  12507. texture: Nullable<Texture>;
  12508. /**
  12509. * Is the layer in background or foreground.
  12510. */
  12511. isBackground: boolean;
  12512. /**
  12513. * Define the color of the layer (instead of texture).
  12514. */
  12515. color: Color4;
  12516. /**
  12517. * Define the scale of the layer in order to zoom in out of the texture.
  12518. */
  12519. scale: Vector2;
  12520. /**
  12521. * Define an offset for the layer in order to shift the texture.
  12522. */
  12523. offset: Vector2;
  12524. /**
  12525. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  12526. */
  12527. alphaBlendingMode: number;
  12528. /**
  12529. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  12530. * Alpha test will not mix with the background color in case of transparency.
  12531. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  12532. */
  12533. alphaTest: boolean;
  12534. /**
  12535. * Define a mask to restrict the layer to only some of the scene cameras.
  12536. */
  12537. layerMask: number;
  12538. /**
  12539. * Define the list of render target the layer is visible into.
  12540. */
  12541. renderTargetTextures: RenderTargetTexture[];
  12542. /**
  12543. * Define if the layer is only used in renderTarget or if it also
  12544. * renders in the main frame buffer of the canvas.
  12545. */
  12546. renderOnlyInRenderTargetTextures: boolean;
  12547. private _scene;
  12548. private _vertexBuffers;
  12549. private _indexBuffer;
  12550. private _effect;
  12551. private _alphaTestEffect;
  12552. /**
  12553. * An event triggered when the layer is disposed.
  12554. */
  12555. onDisposeObservable: Observable<Layer>;
  12556. private _onDisposeObserver;
  12557. /**
  12558. * Back compatibility with callback before the onDisposeObservable existed.
  12559. * The set callback will be triggered when the layer has been disposed.
  12560. */
  12561. onDispose: () => void;
  12562. /**
  12563. * An event triggered before rendering the scene
  12564. */
  12565. onBeforeRenderObservable: Observable<Layer>;
  12566. private _onBeforeRenderObserver;
  12567. /**
  12568. * Back compatibility with callback before the onBeforeRenderObservable existed.
  12569. * The set callback will be triggered just before rendering the layer.
  12570. */
  12571. onBeforeRender: () => void;
  12572. /**
  12573. * An event triggered after rendering the scene
  12574. */
  12575. onAfterRenderObservable: Observable<Layer>;
  12576. private _onAfterRenderObserver;
  12577. /**
  12578. * Back compatibility with callback before the onAfterRenderObservable existed.
  12579. * The set callback will be triggered just after rendering the layer.
  12580. */
  12581. onAfterRender: () => void;
  12582. /**
  12583. * Instantiates a new layer.
  12584. * This represents a full screen 2d layer.
  12585. * This can be useful to display a picture in the background of your scene for instance.
  12586. * @see https://www.babylonjs-playground.com/#08A2BS#1
  12587. * @param name Define the name of the layer in the scene
  12588. * @param imgUrl Define the url of the texture to display in the layer
  12589. * @param scene Define the scene the layer belongs to
  12590. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  12591. * @param color Defines a color for the layer
  12592. */
  12593. constructor(
  12594. /**
  12595. * Define the name of the layer.
  12596. */
  12597. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  12598. private _createIndexBuffer;
  12599. /** @hidden */
  12600. _rebuild(): void;
  12601. /**
  12602. * Renders the layer in the scene.
  12603. */
  12604. render(): void;
  12605. /**
  12606. * Disposes and releases the associated ressources.
  12607. */
  12608. dispose(): void;
  12609. }
  12610. }
  12611. declare module BABYLON {
  12612. interface AbstractScene {
  12613. /**
  12614. * The list of procedural textures added to the scene
  12615. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12616. */
  12617. proceduralTextures: Array<ProceduralTexture>;
  12618. }
  12619. /**
  12620. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  12621. * in a given scene.
  12622. */
  12623. export class ProceduralTextureSceneComponent implements ISceneComponent {
  12624. /**
  12625. * The component name helpfull to identify the component in the list of scene components.
  12626. */
  12627. readonly name: string;
  12628. /**
  12629. * The scene the component belongs to.
  12630. */
  12631. scene: Scene;
  12632. /**
  12633. * Creates a new instance of the component for the given scene
  12634. * @param scene Defines the scene to register the component in
  12635. */
  12636. constructor(scene: Scene);
  12637. /**
  12638. * Registers the component in a given scene
  12639. */
  12640. register(): void;
  12641. /**
  12642. * Rebuilds the elements related to this component in case of
  12643. * context lost for instance.
  12644. */
  12645. rebuild(): void;
  12646. /**
  12647. * Disposes the component and the associated ressources.
  12648. */
  12649. dispose(): void;
  12650. private _beforeClear;
  12651. }
  12652. }
  12653. declare module BABYLON {
  12654. /** @hidden */
  12655. export var proceduralVertexShader: {
  12656. name: string;
  12657. shader: string;
  12658. };
  12659. }
  12660. declare module BABYLON {
  12661. /**
  12662. * 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 calmpler' images.
  12663. * This is the base class of any Procedural texture and contains most of the shareable code.
  12664. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12665. */
  12666. export class ProceduralTexture extends Texture {
  12667. isCube: boolean;
  12668. /**
  12669. * Define if the texture is enabled or not (disabled texture will not render)
  12670. */
  12671. isEnabled: boolean;
  12672. /**
  12673. * Define if the texture must be cleared before rendering (default is true)
  12674. */
  12675. autoClear: boolean;
  12676. /**
  12677. * Callback called when the texture is generated
  12678. */
  12679. onGenerated: () => void;
  12680. /**
  12681. * Event raised when the texture is generated
  12682. */
  12683. onGeneratedObservable: Observable<ProceduralTexture>;
  12684. /** @hidden */
  12685. _generateMipMaps: boolean;
  12686. /** @hidden **/
  12687. _effect: Effect;
  12688. /** @hidden */
  12689. _textures: {
  12690. [key: string]: Texture;
  12691. };
  12692. private _size;
  12693. private _currentRefreshId;
  12694. private _refreshRate;
  12695. private _vertexBuffers;
  12696. private _indexBuffer;
  12697. private _uniforms;
  12698. private _samplers;
  12699. private _fragment;
  12700. private _floats;
  12701. private _ints;
  12702. private _floatsArrays;
  12703. private _colors3;
  12704. private _colors4;
  12705. private _vectors2;
  12706. private _vectors3;
  12707. private _matrices;
  12708. private _fallbackTexture;
  12709. private _fallbackTextureUsed;
  12710. private _engine;
  12711. private _cachedDefines;
  12712. private _contentUpdateId;
  12713. private _contentData;
  12714. /**
  12715. * Instantiates a new procedural texture.
  12716. * 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.
  12717. * This is the base class of any Procedural texture and contains most of the shareable code.
  12718. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12719. * @param name Define the name of the texture
  12720. * @param size Define the size of the texture to create
  12721. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12722. * @param scene Define the scene the texture belongs to
  12723. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12724. * @param generateMipMaps Define if the texture should creates mip maps or not
  12725. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12726. */
  12727. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  12728. /**
  12729. * The effect that is created when initializing the post process.
  12730. * @returns The created effect corrisponding the the postprocess.
  12731. */
  12732. getEffect(): Effect;
  12733. /**
  12734. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12735. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12736. */
  12737. getContent(): Nullable<ArrayBufferView>;
  12738. private _createIndexBuffer;
  12739. /** @hidden */
  12740. _rebuild(): void;
  12741. /**
  12742. * Resets the texture in order to recreate its associated resources.
  12743. * This can be called in case of context loss
  12744. */
  12745. reset(): void;
  12746. protected _getDefines(): string;
  12747. /**
  12748. * Is the texture ready to be used ? (rendered at least once)
  12749. * @returns true if ready, otherwise, false.
  12750. */
  12751. isReady(): boolean;
  12752. /**
  12753. * Resets the refresh counter of the texture and start bak from scratch.
  12754. * Could be useful to regenerate the texture if it is setup to render only once.
  12755. */
  12756. resetRefreshCounter(): void;
  12757. /**
  12758. * Set the fragment shader to use in order to render the texture.
  12759. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12760. */
  12761. setFragment(fragment: any): void;
  12762. /**
  12763. * Define the refresh rate of the texture or the rendering frequency.
  12764. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12765. */
  12766. refreshRate: number;
  12767. /** @hidden */
  12768. _shouldRender(): boolean;
  12769. /**
  12770. * Get the size the texture is rendering at.
  12771. * @returns the size (texture is always squared)
  12772. */
  12773. getRenderSize(): number;
  12774. /**
  12775. * Resize the texture to new value.
  12776. * @param size Define the new size the texture should have
  12777. * @param generateMipMaps Define whether the new texture should create mip maps
  12778. */
  12779. resize(size: number, generateMipMaps: boolean): void;
  12780. private _checkUniform;
  12781. /**
  12782. * Set a texture in the shader program used to render.
  12783. * @param name Define the name of the uniform samplers as defined in the shader
  12784. * @param texture Define the texture to bind to this sampler
  12785. * @return the texture itself allowing "fluent" like uniform updates
  12786. */
  12787. setTexture(name: string, texture: Texture): ProceduralTexture;
  12788. /**
  12789. * Set a float in the shader.
  12790. * @param name Define the name of the uniform as defined in the shader
  12791. * @param value Define the value to give to the uniform
  12792. * @return the texture itself allowing "fluent" like uniform updates
  12793. */
  12794. setFloat(name: string, value: number): ProceduralTexture;
  12795. /**
  12796. * Set a int in the shader.
  12797. * @param name Define the name of the uniform as defined in the shader
  12798. * @param value Define the value to give to the uniform
  12799. * @return the texture itself allowing "fluent" like uniform updates
  12800. */
  12801. setInt(name: string, value: number): ProceduralTexture;
  12802. /**
  12803. * Set an array of floats in the shader.
  12804. * @param name Define the name of the uniform as defined in the shader
  12805. * @param value Define the value to give to the uniform
  12806. * @return the texture itself allowing "fluent" like uniform updates
  12807. */
  12808. setFloats(name: string, value: number[]): ProceduralTexture;
  12809. /**
  12810. * Set a vec3 in the shader from a Color3.
  12811. * @param name Define the name of the uniform as defined in the shader
  12812. * @param value Define the value to give to the uniform
  12813. * @return the texture itself allowing "fluent" like uniform updates
  12814. */
  12815. setColor3(name: string, value: Color3): ProceduralTexture;
  12816. /**
  12817. * Set a vec4 in the shader from a Color4.
  12818. * @param name Define the name of the uniform as defined in the shader
  12819. * @param value Define the value to give to the uniform
  12820. * @return the texture itself allowing "fluent" like uniform updates
  12821. */
  12822. setColor4(name: string, value: Color4): ProceduralTexture;
  12823. /**
  12824. * Set a vec2 in the shader from a Vector2.
  12825. * @param name Define the name of the uniform as defined in the shader
  12826. * @param value Define the value to give to the uniform
  12827. * @return the texture itself allowing "fluent" like uniform updates
  12828. */
  12829. setVector2(name: string, value: Vector2): ProceduralTexture;
  12830. /**
  12831. * Set a vec3 in the shader from a Vector3.
  12832. * @param name Define the name of the uniform as defined in the shader
  12833. * @param value Define the value to give to the uniform
  12834. * @return the texture itself allowing "fluent" like uniform updates
  12835. */
  12836. setVector3(name: string, value: Vector3): ProceduralTexture;
  12837. /**
  12838. * Set a mat4 in the shader from a MAtrix.
  12839. * @param name Define the name of the uniform as defined in the shader
  12840. * @param value Define the value to give to the uniform
  12841. * @return the texture itself allowing "fluent" like uniform updates
  12842. */
  12843. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12844. /**
  12845. * Render the texture to its associated render target.
  12846. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12847. */
  12848. render(useCameraPostProcess?: boolean): void;
  12849. /**
  12850. * Clone the texture.
  12851. * @returns the cloned texture
  12852. */
  12853. clone(): ProceduralTexture;
  12854. /**
  12855. * Dispose the texture and release its asoociated resources.
  12856. */
  12857. dispose(): void;
  12858. }
  12859. }
  12860. declare module BABYLON {
  12861. /**
  12862. * This represents the base class for particle system in Babylon.
  12863. * 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.
  12864. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12865. * @example https://doc.babylonjs.com/babylon101/particles
  12866. */
  12867. export class BaseParticleSystem {
  12868. /**
  12869. * Source color is added to the destination color without alpha affecting the result
  12870. */
  12871. static BLENDMODE_ONEONE: number;
  12872. /**
  12873. * Blend current color and particle color using particle’s alpha
  12874. */
  12875. static BLENDMODE_STANDARD: number;
  12876. /**
  12877. * Add current color and particle color multiplied by particle’s alpha
  12878. */
  12879. static BLENDMODE_ADD: number;
  12880. /**
  12881. * Multiply current color with particle color
  12882. */
  12883. static BLENDMODE_MULTIPLY: number;
  12884. /**
  12885. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12886. */
  12887. static BLENDMODE_MULTIPLYADD: number;
  12888. /**
  12889. * List of animations used by the particle system.
  12890. */
  12891. animations: Animation[];
  12892. /**
  12893. * The id of the Particle system.
  12894. */
  12895. id: string;
  12896. /**
  12897. * The friendly name of the Particle system.
  12898. */
  12899. name: string;
  12900. /**
  12901. * The rendering group used by the Particle system to chose when to render.
  12902. */
  12903. renderingGroupId: number;
  12904. /**
  12905. * The emitter represents the Mesh or position we are attaching the particle system to.
  12906. */
  12907. emitter: Nullable<AbstractMesh | Vector3>;
  12908. /**
  12909. * The maximum number of particles to emit per frame
  12910. */
  12911. emitRate: number;
  12912. /**
  12913. * If you want to launch only a few particles at once, that can be done, as well.
  12914. */
  12915. manualEmitCount: number;
  12916. /**
  12917. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12918. */
  12919. updateSpeed: number;
  12920. /**
  12921. * The amount of time the particle system is running (depends of the overall update speed).
  12922. */
  12923. targetStopDuration: number;
  12924. /**
  12925. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12926. */
  12927. disposeOnStop: boolean;
  12928. /**
  12929. * Minimum power of emitting particles.
  12930. */
  12931. minEmitPower: number;
  12932. /**
  12933. * Maximum power of emitting particles.
  12934. */
  12935. maxEmitPower: number;
  12936. /**
  12937. * Minimum life time of emitting particles.
  12938. */
  12939. minLifeTime: number;
  12940. /**
  12941. * Maximum life time of emitting particles.
  12942. */
  12943. maxLifeTime: number;
  12944. /**
  12945. * Minimum Size of emitting particles.
  12946. */
  12947. minSize: number;
  12948. /**
  12949. * Maximum Size of emitting particles.
  12950. */
  12951. maxSize: number;
  12952. /**
  12953. * Minimum scale of emitting particles on X axis.
  12954. */
  12955. minScaleX: number;
  12956. /**
  12957. * Maximum scale of emitting particles on X axis.
  12958. */
  12959. maxScaleX: number;
  12960. /**
  12961. * Minimum scale of emitting particles on Y axis.
  12962. */
  12963. minScaleY: number;
  12964. /**
  12965. * Maximum scale of emitting particles on Y axis.
  12966. */
  12967. maxScaleY: number;
  12968. /**
  12969. * Gets or sets the minimal initial rotation in radians.
  12970. */
  12971. minInitialRotation: number;
  12972. /**
  12973. * Gets or sets the maximal initial rotation in radians.
  12974. */
  12975. maxInitialRotation: number;
  12976. /**
  12977. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12978. */
  12979. minAngularSpeed: number;
  12980. /**
  12981. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12982. */
  12983. maxAngularSpeed: number;
  12984. /**
  12985. * The texture used to render each particle. (this can be a spritesheet)
  12986. */
  12987. particleTexture: Nullable<Texture>;
  12988. /**
  12989. * The layer mask we are rendering the particles through.
  12990. */
  12991. layerMask: number;
  12992. /**
  12993. * This can help using your own shader to render the particle system.
  12994. * The according effect will be created
  12995. */
  12996. customShader: any;
  12997. /**
  12998. * By default particle system starts as soon as they are created. This prevents the
  12999. * automatic start to happen and let you decide when to start emitting particles.
  13000. */
  13001. preventAutoStart: boolean;
  13002. private _noiseTexture;
  13003. /**
  13004. * Gets or sets a texture used to add random noise to particle positions
  13005. */
  13006. noiseTexture: Nullable<ProceduralTexture>;
  13007. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13008. noiseStrength: Vector3;
  13009. /**
  13010. * Callback triggered when the particle animation is ending.
  13011. */
  13012. onAnimationEnd: Nullable<() => void>;
  13013. /**
  13014. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  13015. */
  13016. blendMode: number;
  13017. /**
  13018. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  13019. * to override the particles.
  13020. */
  13021. forceDepthWrite: boolean;
  13022. /** 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 */
  13023. preWarmCycles: number;
  13024. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  13025. preWarmStepOffset: number;
  13026. /**
  13027. * 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)
  13028. */
  13029. spriteCellChangeSpeed: number;
  13030. /**
  13031. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13032. */
  13033. startSpriteCellID: number;
  13034. /**
  13035. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13036. */
  13037. endSpriteCellID: number;
  13038. /**
  13039. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13040. */
  13041. spriteCellWidth: number;
  13042. /**
  13043. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13044. */
  13045. spriteCellHeight: number;
  13046. /**
  13047. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13048. */
  13049. spriteRandomStartCell: boolean;
  13050. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13051. translationPivot: Vector2;
  13052. /** @hidden */
  13053. protected _isAnimationSheetEnabled: boolean;
  13054. /**
  13055. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13056. */
  13057. beginAnimationOnStart: boolean;
  13058. /**
  13059. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13060. */
  13061. beginAnimationFrom: number;
  13062. /**
  13063. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13064. */
  13065. beginAnimationTo: number;
  13066. /**
  13067. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13068. */
  13069. beginAnimationLoop: boolean;
  13070. /**
  13071. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  13072. */
  13073. isAnimationSheetEnabled: boolean;
  13074. /**
  13075. * Get hosting scene
  13076. * @returns the scene
  13077. */
  13078. getScene(): Scene;
  13079. /**
  13080. * You can use gravity if you want to give an orientation to your particles.
  13081. */
  13082. gravity: Vector3;
  13083. protected _colorGradients: Nullable<Array<ColorGradient>>;
  13084. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  13085. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  13086. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  13087. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  13088. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  13089. protected _dragGradients: Nullable<Array<FactorGradient>>;
  13090. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  13091. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  13092. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  13093. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  13094. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  13095. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  13096. /**
  13097. * Defines the delay in milliseconds before starting the system (0 by default)
  13098. */
  13099. startDelay: number;
  13100. /**
  13101. * Gets the current list of drag gradients.
  13102. * You must use addDragGradient and removeDragGradient to udpate this list
  13103. * @returns the list of drag gradients
  13104. */
  13105. getDragGradients(): Nullable<Array<FactorGradient>>;
  13106. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13107. limitVelocityDamping: number;
  13108. /**
  13109. * Gets the current list of limit velocity gradients.
  13110. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13111. * @returns the list of limit velocity gradients
  13112. */
  13113. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13114. /**
  13115. * Gets the current list of color gradients.
  13116. * You must use addColorGradient and removeColorGradient to udpate this list
  13117. * @returns the list of color gradients
  13118. */
  13119. getColorGradients(): Nullable<Array<ColorGradient>>;
  13120. /**
  13121. * Gets the current list of size gradients.
  13122. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13123. * @returns the list of size gradients
  13124. */
  13125. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13126. /**
  13127. * Gets the current list of color remap gradients.
  13128. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13129. * @returns the list of color remap gradients
  13130. */
  13131. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13132. /**
  13133. * Gets the current list of alpha remap gradients.
  13134. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13135. * @returns the list of alpha remap gradients
  13136. */
  13137. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13138. /**
  13139. * Gets the current list of life time gradients.
  13140. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13141. * @returns the list of life time gradients
  13142. */
  13143. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13144. /**
  13145. * Gets the current list of angular speed gradients.
  13146. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13147. * @returns the list of angular speed gradients
  13148. */
  13149. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13150. /**
  13151. * Gets the current list of velocity gradients.
  13152. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13153. * @returns the list of velocity gradients
  13154. */
  13155. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13156. /**
  13157. * Gets the current list of start size gradients.
  13158. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13159. * @returns the list of start size gradients
  13160. */
  13161. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13162. /**
  13163. * Gets the current list of emit rate gradients.
  13164. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13165. * @returns the list of emit rate gradients
  13166. */
  13167. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13168. /**
  13169. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13170. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13171. */
  13172. direction1: Vector3;
  13173. /**
  13174. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13175. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13176. */
  13177. direction2: Vector3;
  13178. /**
  13179. * 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.
  13180. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13181. */
  13182. minEmitBox: Vector3;
  13183. /**
  13184. * 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.
  13185. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13186. */
  13187. maxEmitBox: Vector3;
  13188. /**
  13189. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  13190. */
  13191. color1: Color4;
  13192. /**
  13193. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  13194. */
  13195. color2: Color4;
  13196. /**
  13197. * Color the particle will have at the end of its lifetime
  13198. */
  13199. colorDead: Color4;
  13200. /**
  13201. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  13202. */
  13203. textureMask: Color4;
  13204. /**
  13205. * The particle emitter type defines the emitter used by the particle system.
  13206. * It can be for example box, sphere, or cone...
  13207. */
  13208. particleEmitterType: IParticleEmitterType;
  13209. /** @hidden */
  13210. _isSubEmitter: boolean;
  13211. /**
  13212. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13213. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13214. */
  13215. billboardMode: number;
  13216. protected _isBillboardBased: boolean;
  13217. /**
  13218. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13219. */
  13220. isBillboardBased: boolean;
  13221. /**
  13222. * The scene the particle system belongs to.
  13223. */
  13224. protected _scene: Scene;
  13225. /**
  13226. * Local cache of defines for image processing.
  13227. */
  13228. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  13229. /**
  13230. * Default configuration related to image processing available in the standard Material.
  13231. */
  13232. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  13233. /**
  13234. * Gets the image processing configuration used either in this material.
  13235. */
  13236. /**
  13237. * Sets the Default image processing configuration used either in the this material.
  13238. *
  13239. * If sets to null, the scene one is in use.
  13240. */
  13241. imageProcessingConfiguration: ImageProcessingConfiguration;
  13242. /**
  13243. * Attaches a new image processing configuration to the Standard Material.
  13244. * @param configuration
  13245. */
  13246. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  13247. /** @hidden */
  13248. protected _reset(): void;
  13249. /** @hidden */
  13250. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  13251. /**
  13252. * Instantiates a particle system.
  13253. * 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.
  13254. * @param name The name of the particle system
  13255. */
  13256. constructor(name: string);
  13257. /**
  13258. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13259. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13260. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13261. * @returns the emitter
  13262. */
  13263. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13264. /**
  13265. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13266. * @param radius The radius of the hemisphere to emit from
  13267. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13268. * @returns the emitter
  13269. */
  13270. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  13271. /**
  13272. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13273. * @param radius The radius of the sphere to emit from
  13274. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13275. * @returns the emitter
  13276. */
  13277. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  13278. /**
  13279. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13280. * @param radius The radius of the sphere to emit from
  13281. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13282. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13283. * @returns the emitter
  13284. */
  13285. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  13286. /**
  13287. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13288. * @param radius The radius of the emission cylinder
  13289. * @param height The height of the emission cylinder
  13290. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13291. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13292. * @returns the emitter
  13293. */
  13294. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  13295. /**
  13296. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13297. * @param radius The radius of the cylinder to emit from
  13298. * @param height The height of the emission cylinder
  13299. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13300. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13301. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13302. * @returns the emitter
  13303. */
  13304. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  13305. /**
  13306. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13307. * @param radius The radius of the cone to emit from
  13308. * @param angle The base angle of the cone
  13309. * @returns the emitter
  13310. */
  13311. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  13312. /**
  13313. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13314. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13315. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13316. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13317. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13318. * @returns the emitter
  13319. */
  13320. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13321. }
  13322. }
  13323. declare module BABYLON {
  13324. /**
  13325. * Type of sub emitter
  13326. */
  13327. export enum SubEmitterType {
  13328. /**
  13329. * Attached to the particle over it's lifetime
  13330. */
  13331. ATTACHED = 0,
  13332. /**
  13333. * Created when the particle dies
  13334. */
  13335. END = 1
  13336. }
  13337. /**
  13338. * Sub emitter class used to emit particles from an existing particle
  13339. */
  13340. export class SubEmitter {
  13341. /**
  13342. * the particle system to be used by the sub emitter
  13343. */
  13344. particleSystem: ParticleSystem;
  13345. /**
  13346. * Type of the submitter (Default: END)
  13347. */
  13348. type: SubEmitterType;
  13349. /**
  13350. * 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)
  13351. * Note: This only is supported when using an emitter of type Mesh
  13352. */
  13353. inheritDirection: boolean;
  13354. /**
  13355. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  13356. */
  13357. inheritedVelocityAmount: number;
  13358. /**
  13359. * Creates a sub emitter
  13360. * @param particleSystem the particle system to be used by the sub emitter
  13361. */
  13362. constructor(
  13363. /**
  13364. * the particle system to be used by the sub emitter
  13365. */
  13366. particleSystem: ParticleSystem);
  13367. /**
  13368. * Clones the sub emitter
  13369. * @returns the cloned sub emitter
  13370. */
  13371. clone(): SubEmitter;
  13372. /**
  13373. * Serialize current object to a JSON object
  13374. * @returns the serialized object
  13375. */
  13376. serialize(): any;
  13377. /** @hidden */
  13378. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  13379. /**
  13380. * Creates a new SubEmitter from a serialized JSON version
  13381. * @param serializationObject defines the JSON object to read from
  13382. * @param scene defines the hosting scene
  13383. * @param rootUrl defines the rootUrl for data loading
  13384. * @returns a new SubEmitter
  13385. */
  13386. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  13387. /** Release associated resources */
  13388. dispose(): void;
  13389. }
  13390. }
  13391. declare module BABYLON {
  13392. /** @hidden */
  13393. export var clipPlaneFragmentDeclaration: {
  13394. name: string;
  13395. shader: string;
  13396. };
  13397. }
  13398. declare module BABYLON {
  13399. /** @hidden */
  13400. export var imageProcessingDeclaration: {
  13401. name: string;
  13402. shader: string;
  13403. };
  13404. }
  13405. declare module BABYLON {
  13406. /** @hidden */
  13407. export var imageProcessingFunctions: {
  13408. name: string;
  13409. shader: string;
  13410. };
  13411. }
  13412. declare module BABYLON {
  13413. /** @hidden */
  13414. export var clipPlaneFragment: {
  13415. name: string;
  13416. shader: string;
  13417. };
  13418. }
  13419. declare module BABYLON {
  13420. /** @hidden */
  13421. export var particlesPixelShader: {
  13422. name: string;
  13423. shader: string;
  13424. };
  13425. }
  13426. declare module BABYLON {
  13427. /** @hidden */
  13428. export var clipPlaneVertexDeclaration: {
  13429. name: string;
  13430. shader: string;
  13431. };
  13432. }
  13433. declare module BABYLON {
  13434. /** @hidden */
  13435. export var clipPlaneVertex: {
  13436. name: string;
  13437. shader: string;
  13438. };
  13439. }
  13440. declare module BABYLON {
  13441. /** @hidden */
  13442. export var particlesVertexShader: {
  13443. name: string;
  13444. shader: string;
  13445. };
  13446. }
  13447. declare module BABYLON {
  13448. /**
  13449. * This represents a particle system in Babylon.
  13450. * 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.
  13451. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  13452. * @example https://doc.babylonjs.com/babylon101/particles
  13453. */
  13454. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  13455. /**
  13456. * Billboard mode will only apply to Y axis
  13457. */
  13458. static readonly BILLBOARDMODE_Y: number;
  13459. /**
  13460. * Billboard mode will apply to all axes
  13461. */
  13462. static readonly BILLBOARDMODE_ALL: number;
  13463. /**
  13464. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  13465. */
  13466. static readonly BILLBOARDMODE_STRETCHED: number;
  13467. /**
  13468. * This function can be defined to provide custom update for active particles.
  13469. * This function will be called instead of regular update (age, position, color, etc.).
  13470. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  13471. */
  13472. updateFunction: (particles: Particle[]) => void;
  13473. private _emitterWorldMatrix;
  13474. /**
  13475. * This function can be defined to specify initial direction for every new particle.
  13476. * It by default use the emitterType defined function
  13477. */
  13478. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  13479. /**
  13480. * This function can be defined to specify initial position for every new particle.
  13481. * It by default use the emitterType defined function
  13482. */
  13483. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  13484. /**
  13485. * @hidden
  13486. */
  13487. _inheritedVelocityOffset: Vector3;
  13488. /**
  13489. * An event triggered when the system is disposed
  13490. */
  13491. onDisposeObservable: Observable<ParticleSystem>;
  13492. private _onDisposeObserver;
  13493. /**
  13494. * Sets a callback that will be triggered when the system is disposed
  13495. */
  13496. onDispose: () => void;
  13497. private _particles;
  13498. private _epsilon;
  13499. private _capacity;
  13500. private _stockParticles;
  13501. private _newPartsExcess;
  13502. private _vertexData;
  13503. private _vertexBuffer;
  13504. private _vertexBuffers;
  13505. private _spriteBuffer;
  13506. private _indexBuffer;
  13507. private _effect;
  13508. private _customEffect;
  13509. private _cachedDefines;
  13510. private _scaledColorStep;
  13511. private _colorDiff;
  13512. private _scaledDirection;
  13513. private _scaledGravity;
  13514. private _currentRenderId;
  13515. private _alive;
  13516. private _useInstancing;
  13517. private _started;
  13518. private _stopped;
  13519. private _actualFrame;
  13520. private _scaledUpdateSpeed;
  13521. private _vertexBufferSize;
  13522. /** @hidden */
  13523. _currentEmitRateGradient: Nullable<FactorGradient>;
  13524. /** @hidden */
  13525. _currentEmitRate1: number;
  13526. /** @hidden */
  13527. _currentEmitRate2: number;
  13528. /** @hidden */
  13529. _currentStartSizeGradient: Nullable<FactorGradient>;
  13530. /** @hidden */
  13531. _currentStartSize1: number;
  13532. /** @hidden */
  13533. _currentStartSize2: number;
  13534. private readonly _rawTextureWidth;
  13535. private _rampGradientsTexture;
  13536. private _useRampGradients;
  13537. /** Gets or sets a boolean indicating that ramp gradients must be used
  13538. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13539. */
  13540. useRampGradients: boolean;
  13541. /**
  13542. * 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.
  13543. * 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: [])
  13544. */
  13545. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  13546. private _subEmitters;
  13547. /**
  13548. * @hidden
  13549. * If the particle systems emitter should be disposed when the particle system is disposed
  13550. */
  13551. _disposeEmitterOnDispose: boolean;
  13552. /**
  13553. * The current active Sub-systems, this property is used by the root particle system only.
  13554. */
  13555. activeSubSystems: Array<ParticleSystem>;
  13556. private _rootParticleSystem;
  13557. /**
  13558. * Gets the current list of active particles
  13559. */
  13560. readonly particles: Particle[];
  13561. /**
  13562. * Returns the string "ParticleSystem"
  13563. * @returns a string containing the class name
  13564. */
  13565. getClassName(): string;
  13566. /**
  13567. * Instantiates a particle system.
  13568. * 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.
  13569. * @param name The name of the particle system
  13570. * @param capacity The max number of particles alive at the same time
  13571. * @param scene The scene the particle system belongs to
  13572. * @param customEffect a custom effect used to change the way particles are rendered by default
  13573. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13574. * @param epsilon Offset used to render the particles
  13575. */
  13576. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13577. private _addFactorGradient;
  13578. private _removeFactorGradient;
  13579. /**
  13580. * Adds a new life time gradient
  13581. * @param gradient defines the gradient to use (between 0 and 1)
  13582. * @param factor defines the life time factor to affect to the specified gradient
  13583. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13584. * @returns the current particle system
  13585. */
  13586. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13587. /**
  13588. * Remove a specific life time gradient
  13589. * @param gradient defines the gradient to remove
  13590. * @returns the current particle system
  13591. */
  13592. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13593. /**
  13594. * Adds a new size gradient
  13595. * @param gradient defines the gradient to use (between 0 and 1)
  13596. * @param factor defines the size factor to affect to the specified gradient
  13597. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13598. * @returns the current particle system
  13599. */
  13600. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13601. /**
  13602. * Remove a specific size gradient
  13603. * @param gradient defines the gradient to remove
  13604. * @returns the current particle system
  13605. */
  13606. removeSizeGradient(gradient: number): IParticleSystem;
  13607. /**
  13608. * Adds a new color remap gradient
  13609. * @param gradient defines the gradient to use (between 0 and 1)
  13610. * @param min defines the color remap minimal range
  13611. * @param max defines the color remap maximal range
  13612. * @returns the current particle system
  13613. */
  13614. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13615. /**
  13616. * Remove a specific color remap gradient
  13617. * @param gradient defines the gradient to remove
  13618. * @returns the current particle system
  13619. */
  13620. removeColorRemapGradient(gradient: number): IParticleSystem;
  13621. /**
  13622. * Adds a new alpha remap gradient
  13623. * @param gradient defines the gradient to use (between 0 and 1)
  13624. * @param min defines the alpha remap minimal range
  13625. * @param max defines the alpha remap maximal range
  13626. * @returns the current particle system
  13627. */
  13628. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13629. /**
  13630. * Remove a specific alpha remap gradient
  13631. * @param gradient defines the gradient to remove
  13632. * @returns the current particle system
  13633. */
  13634. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13635. /**
  13636. * Adds a new angular speed gradient
  13637. * @param gradient defines the gradient to use (between 0 and 1)
  13638. * @param factor defines the angular speed to affect to the specified gradient
  13639. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13640. * @returns the current particle system
  13641. */
  13642. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13643. /**
  13644. * Remove a specific angular speed gradient
  13645. * @param gradient defines the gradient to remove
  13646. * @returns the current particle system
  13647. */
  13648. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13649. /**
  13650. * Adds a new velocity gradient
  13651. * @param gradient defines the gradient to use (between 0 and 1)
  13652. * @param factor defines the velocity to affect to the specified gradient
  13653. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13654. * @returns the current particle system
  13655. */
  13656. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13657. /**
  13658. * Remove a specific velocity gradient
  13659. * @param gradient defines the gradient to remove
  13660. * @returns the current particle system
  13661. */
  13662. removeVelocityGradient(gradient: number): IParticleSystem;
  13663. /**
  13664. * Adds a new limit velocity gradient
  13665. * @param gradient defines the gradient to use (between 0 and 1)
  13666. * @param factor defines the limit velocity value to affect to the specified gradient
  13667. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13668. * @returns the current particle system
  13669. */
  13670. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13671. /**
  13672. * Remove a specific limit velocity gradient
  13673. * @param gradient defines the gradient to remove
  13674. * @returns the current particle system
  13675. */
  13676. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13677. /**
  13678. * Adds a new drag gradient
  13679. * @param gradient defines the gradient to use (between 0 and 1)
  13680. * @param factor defines the drag value to affect to the specified gradient
  13681. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13682. * @returns the current particle system
  13683. */
  13684. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13685. /**
  13686. * Remove a specific drag gradient
  13687. * @param gradient defines the gradient to remove
  13688. * @returns the current particle system
  13689. */
  13690. removeDragGradient(gradient: number): IParticleSystem;
  13691. /**
  13692. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13693. * @param gradient defines the gradient to use (between 0 and 1)
  13694. * @param factor defines the emit rate value to affect to the specified gradient
  13695. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13696. * @returns the current particle system
  13697. */
  13698. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13699. /**
  13700. * Remove a specific emit rate gradient
  13701. * @param gradient defines the gradient to remove
  13702. * @returns the current particle system
  13703. */
  13704. removeEmitRateGradient(gradient: number): IParticleSystem;
  13705. /**
  13706. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13707. * @param gradient defines the gradient to use (between 0 and 1)
  13708. * @param factor defines the start size value to affect to the specified gradient
  13709. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13710. * @returns the current particle system
  13711. */
  13712. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13713. /**
  13714. * Remove a specific start size gradient
  13715. * @param gradient defines the gradient to remove
  13716. * @returns the current particle system
  13717. */
  13718. removeStartSizeGradient(gradient: number): IParticleSystem;
  13719. private _createRampGradientTexture;
  13720. /**
  13721. * Gets the current list of ramp gradients.
  13722. * You must use addRampGradient and removeRampGradient to udpate this list
  13723. * @returns the list of ramp gradients
  13724. */
  13725. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13726. /**
  13727. * Adds a new ramp gradient used to remap particle colors
  13728. * @param gradient defines the gradient to use (between 0 and 1)
  13729. * @param color defines the color to affect to the specified gradient
  13730. * @returns the current particle system
  13731. */
  13732. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13733. /**
  13734. * Remove a specific ramp gradient
  13735. * @param gradient defines the gradient to remove
  13736. * @returns the current particle system
  13737. */
  13738. removeRampGradient(gradient: number): ParticleSystem;
  13739. /**
  13740. * Adds a new color gradient
  13741. * @param gradient defines the gradient to use (between 0 and 1)
  13742. * @param color1 defines the color to affect to the specified gradient
  13743. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13744. * @returns this particle system
  13745. */
  13746. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13747. /**
  13748. * Remove a specific color gradient
  13749. * @param gradient defines the gradient to remove
  13750. * @returns this particle system
  13751. */
  13752. removeColorGradient(gradient: number): IParticleSystem;
  13753. private _fetchR;
  13754. protected _reset(): void;
  13755. private _resetEffect;
  13756. private _createVertexBuffers;
  13757. private _createIndexBuffer;
  13758. /**
  13759. * Gets the maximum number of particles active at the same time.
  13760. * @returns The max number of active particles.
  13761. */
  13762. getCapacity(): number;
  13763. /**
  13764. * Gets whether there are still active particles in the system.
  13765. * @returns True if it is alive, otherwise false.
  13766. */
  13767. isAlive(): boolean;
  13768. /**
  13769. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13770. * @returns True if it has been started, otherwise false.
  13771. */
  13772. isStarted(): boolean;
  13773. private _prepareSubEmitterInternalArray;
  13774. /**
  13775. * Starts the particle system and begins to emit
  13776. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13777. */
  13778. start(delay?: number): void;
  13779. /**
  13780. * Stops the particle system.
  13781. * @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.
  13782. */
  13783. stop(stopSubEmitters?: boolean): void;
  13784. /**
  13785. * Remove all active particles
  13786. */
  13787. reset(): void;
  13788. /**
  13789. * @hidden (for internal use only)
  13790. */
  13791. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13792. /**
  13793. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13794. * Its lifetime will start back at 0.
  13795. */
  13796. recycleParticle: (particle: Particle) => void;
  13797. private _stopSubEmitters;
  13798. private _createParticle;
  13799. private _removeFromRoot;
  13800. private _emitFromParticle;
  13801. private _update;
  13802. /** @hidden */
  13803. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13804. /** @hidden */
  13805. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13806. /** @hidden */
  13807. private _getEffect;
  13808. /**
  13809. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13810. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13811. */
  13812. animate(preWarmOnly?: boolean): void;
  13813. private _appendParticleVertices;
  13814. /**
  13815. * Rebuilds the particle system.
  13816. */
  13817. rebuild(): void;
  13818. /**
  13819. * Is this system ready to be used/rendered
  13820. * @return true if the system is ready
  13821. */
  13822. isReady(): boolean;
  13823. private _render;
  13824. /**
  13825. * Renders the particle system in its current state.
  13826. * @returns the current number of particles
  13827. */
  13828. render(): number;
  13829. /**
  13830. * Disposes the particle system and free the associated resources
  13831. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13832. */
  13833. dispose(disposeTexture?: boolean): void;
  13834. /**
  13835. * Clones the particle system.
  13836. * @param name The name of the cloned object
  13837. * @param newEmitter The new emitter to use
  13838. * @returns the cloned particle system
  13839. */
  13840. clone(name: string, newEmitter: any): ParticleSystem;
  13841. /**
  13842. * Serializes the particle system to a JSON object.
  13843. * @returns the JSON object
  13844. */
  13845. serialize(): any;
  13846. /** @hidden */
  13847. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  13848. /** @hidden */
  13849. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  13850. /**
  13851. * Parses a JSON object to create a particle system.
  13852. * @param parsedParticleSystem The JSON object to parse
  13853. * @param scene The scene to create the particle system in
  13854. * @param rootUrl The root url to use to load external dependencies like texture
  13855. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13856. * @returns the Parsed particle system
  13857. */
  13858. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13859. }
  13860. }
  13861. declare module BABYLON {
  13862. /**
  13863. * A particle represents one of the element emitted by a particle system.
  13864. * This is mainly define by its coordinates, direction, velocity and age.
  13865. */
  13866. export class Particle {
  13867. /**
  13868. * The particle system the particle belongs to.
  13869. */
  13870. particleSystem: ParticleSystem;
  13871. private static _Count;
  13872. /**
  13873. * Unique ID of the particle
  13874. */
  13875. id: number;
  13876. /**
  13877. * The world position of the particle in the scene.
  13878. */
  13879. position: Vector3;
  13880. /**
  13881. * The world direction of the particle in the scene.
  13882. */
  13883. direction: Vector3;
  13884. /**
  13885. * The color of the particle.
  13886. */
  13887. color: Color4;
  13888. /**
  13889. * The color change of the particle per step.
  13890. */
  13891. colorStep: Color4;
  13892. /**
  13893. * Defines how long will the life of the particle be.
  13894. */
  13895. lifeTime: number;
  13896. /**
  13897. * The current age of the particle.
  13898. */
  13899. age: number;
  13900. /**
  13901. * The current size of the particle.
  13902. */
  13903. size: number;
  13904. /**
  13905. * The current scale of the particle.
  13906. */
  13907. scale: Vector2;
  13908. /**
  13909. * The current angle of the particle.
  13910. */
  13911. angle: number;
  13912. /**
  13913. * Defines how fast is the angle changing.
  13914. */
  13915. angularSpeed: number;
  13916. /**
  13917. * Defines the cell index used by the particle to be rendered from a sprite.
  13918. */
  13919. cellIndex: number;
  13920. /**
  13921. * The information required to support color remapping
  13922. */
  13923. remapData: Vector4;
  13924. /** @hidden */
  13925. _randomCellOffset?: number;
  13926. /** @hidden */
  13927. _initialDirection: Nullable<Vector3>;
  13928. /** @hidden */
  13929. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13930. /** @hidden */
  13931. _initialStartSpriteCellID: number;
  13932. /** @hidden */
  13933. _initialEndSpriteCellID: number;
  13934. /** @hidden */
  13935. _currentColorGradient: Nullable<ColorGradient>;
  13936. /** @hidden */
  13937. _currentColor1: Color4;
  13938. /** @hidden */
  13939. _currentColor2: Color4;
  13940. /** @hidden */
  13941. _currentSizeGradient: Nullable<FactorGradient>;
  13942. /** @hidden */
  13943. _currentSize1: number;
  13944. /** @hidden */
  13945. _currentSize2: number;
  13946. /** @hidden */
  13947. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13948. /** @hidden */
  13949. _currentAngularSpeed1: number;
  13950. /** @hidden */
  13951. _currentAngularSpeed2: number;
  13952. /** @hidden */
  13953. _currentVelocityGradient: Nullable<FactorGradient>;
  13954. /** @hidden */
  13955. _currentVelocity1: number;
  13956. /** @hidden */
  13957. _currentVelocity2: number;
  13958. /** @hidden */
  13959. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13960. /** @hidden */
  13961. _currentLimitVelocity1: number;
  13962. /** @hidden */
  13963. _currentLimitVelocity2: number;
  13964. /** @hidden */
  13965. _currentDragGradient: Nullable<FactorGradient>;
  13966. /** @hidden */
  13967. _currentDrag1: number;
  13968. /** @hidden */
  13969. _currentDrag2: number;
  13970. /** @hidden */
  13971. _randomNoiseCoordinates1: Vector3;
  13972. /** @hidden */
  13973. _randomNoiseCoordinates2: Vector3;
  13974. /**
  13975. * Creates a new instance Particle
  13976. * @param particleSystem the particle system the particle belongs to
  13977. */
  13978. constructor(
  13979. /**
  13980. * The particle system the particle belongs to.
  13981. */
  13982. particleSystem: ParticleSystem);
  13983. private updateCellInfoFromSystem;
  13984. /**
  13985. * Defines how the sprite cell index is updated for the particle
  13986. */
  13987. updateCellIndex(): void;
  13988. /** @hidden */
  13989. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13990. /** @hidden */
  13991. _inheritParticleInfoToSubEmitters(): void;
  13992. /** @hidden */
  13993. _reset(): void;
  13994. /**
  13995. * Copy the properties of particle to another one.
  13996. * @param other the particle to copy the information to.
  13997. */
  13998. copyTo(other: Particle): void;
  13999. }
  14000. }
  14001. declare module BABYLON {
  14002. /**
  14003. * Particle emitter represents a volume emitting particles.
  14004. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  14005. */
  14006. export interface IParticleEmitterType {
  14007. /**
  14008. * Called by the particle System when the direction is computed for the created particle.
  14009. * @param worldMatrix is the world matrix of the particle system
  14010. * @param directionToUpdate is the direction vector to update with the result
  14011. * @param particle is the particle we are computed the direction for
  14012. */
  14013. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14014. /**
  14015. * Called by the particle System when the position is computed for the created particle.
  14016. * @param worldMatrix is the world matrix of the particle system
  14017. * @param positionToUpdate is the position vector to update with the result
  14018. * @param particle is the particle we are computed the position for
  14019. */
  14020. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14021. /**
  14022. * Clones the current emitter and returns a copy of it
  14023. * @returns the new emitter
  14024. */
  14025. clone(): IParticleEmitterType;
  14026. /**
  14027. * Called by the GPUParticleSystem to setup the update shader
  14028. * @param effect defines the update shader
  14029. */
  14030. applyToShader(effect: Effect): void;
  14031. /**
  14032. * Returns a string to use to update the GPU particles update shader
  14033. * @returns the effect defines string
  14034. */
  14035. getEffectDefines(): string;
  14036. /**
  14037. * Returns a string representing the class name
  14038. * @returns a string containing the class name
  14039. */
  14040. getClassName(): string;
  14041. /**
  14042. * Serializes the particle system to a JSON object.
  14043. * @returns the JSON object
  14044. */
  14045. serialize(): any;
  14046. /**
  14047. * Parse properties from a JSON object
  14048. * @param serializationObject defines the JSON object
  14049. */
  14050. parse(serializationObject: any): void;
  14051. }
  14052. }
  14053. declare module BABYLON {
  14054. /**
  14055. * Particle emitter emitting particles from the inside of a box.
  14056. * It emits the particles randomly between 2 given directions.
  14057. */
  14058. export class BoxParticleEmitter implements IParticleEmitterType {
  14059. /**
  14060. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14061. */
  14062. direction1: Vector3;
  14063. /**
  14064. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14065. */
  14066. direction2: Vector3;
  14067. /**
  14068. * 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.
  14069. */
  14070. minEmitBox: Vector3;
  14071. /**
  14072. * 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.
  14073. */
  14074. maxEmitBox: Vector3;
  14075. /**
  14076. * Creates a new instance BoxParticleEmitter
  14077. */
  14078. constructor();
  14079. /**
  14080. * Called by the particle System when the direction is computed for the created particle.
  14081. * @param worldMatrix is the world matrix of the particle system
  14082. * @param directionToUpdate is the direction vector to update with the result
  14083. * @param particle is the particle we are computed the direction for
  14084. */
  14085. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14086. /**
  14087. * Called by the particle System when the position is computed for the created particle.
  14088. * @param worldMatrix is the world matrix of the particle system
  14089. * @param positionToUpdate is the position vector to update with the result
  14090. * @param particle is the particle we are computed the position for
  14091. */
  14092. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14093. /**
  14094. * Clones the current emitter and returns a copy of it
  14095. * @returns the new emitter
  14096. */
  14097. clone(): BoxParticleEmitter;
  14098. /**
  14099. * Called by the GPUParticleSystem to setup the update shader
  14100. * @param effect defines the update shader
  14101. */
  14102. applyToShader(effect: Effect): void;
  14103. /**
  14104. * Returns a string to use to update the GPU particles update shader
  14105. * @returns a string containng the defines string
  14106. */
  14107. getEffectDefines(): string;
  14108. /**
  14109. * Returns the string "BoxParticleEmitter"
  14110. * @returns a string containing the class name
  14111. */
  14112. getClassName(): string;
  14113. /**
  14114. * Serializes the particle system to a JSON object.
  14115. * @returns the JSON object
  14116. */
  14117. serialize(): any;
  14118. /**
  14119. * Parse properties from a JSON object
  14120. * @param serializationObject defines the JSON object
  14121. */
  14122. parse(serializationObject: any): void;
  14123. }
  14124. }
  14125. declare module BABYLON {
  14126. /**
  14127. * Particle emitter emitting particles from the inside of a cone.
  14128. * It emits the particles alongside the cone volume from the base to the particle.
  14129. * The emission direction might be randomized.
  14130. */
  14131. export class ConeParticleEmitter implements IParticleEmitterType {
  14132. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  14133. directionRandomizer: number;
  14134. private _radius;
  14135. private _angle;
  14136. private _height;
  14137. /**
  14138. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  14139. */
  14140. radiusRange: number;
  14141. /**
  14142. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  14143. */
  14144. heightRange: number;
  14145. /**
  14146. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  14147. */
  14148. emitFromSpawnPointOnly: boolean;
  14149. /**
  14150. * Gets or sets the radius of the emission cone
  14151. */
  14152. radius: number;
  14153. /**
  14154. * Gets or sets the angle of the emission cone
  14155. */
  14156. angle: number;
  14157. private _buildHeight;
  14158. /**
  14159. * Creates a new instance ConeParticleEmitter
  14160. * @param radius the radius of the emission cone (1 by default)
  14161. * @param angle the cone base angle (PI by default)
  14162. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  14163. */
  14164. constructor(radius?: number, angle?: number,
  14165. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  14166. directionRandomizer?: number);
  14167. /**
  14168. * Called by the particle System when the direction is computed for the created particle.
  14169. * @param worldMatrix is the world matrix of the particle system
  14170. * @param directionToUpdate is the direction vector to update with the result
  14171. * @param particle is the particle we are computed the direction for
  14172. */
  14173. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14174. /**
  14175. * Called by the particle System when the position is computed for the created particle.
  14176. * @param worldMatrix is the world matrix of the particle system
  14177. * @param positionToUpdate is the position vector to update with the result
  14178. * @param particle is the particle we are computed the position for
  14179. */
  14180. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14181. /**
  14182. * Clones the current emitter and returns a copy of it
  14183. * @returns the new emitter
  14184. */
  14185. clone(): ConeParticleEmitter;
  14186. /**
  14187. * Called by the GPUParticleSystem to setup the update shader
  14188. * @param effect defines the update shader
  14189. */
  14190. applyToShader(effect: Effect): void;
  14191. /**
  14192. * Returns a string to use to update the GPU particles update shader
  14193. * @returns a string containng the defines string
  14194. */
  14195. getEffectDefines(): string;
  14196. /**
  14197. * Returns the string "ConeParticleEmitter"
  14198. * @returns a string containing the class name
  14199. */
  14200. getClassName(): string;
  14201. /**
  14202. * Serializes the particle system to a JSON object.
  14203. * @returns the JSON object
  14204. */
  14205. serialize(): any;
  14206. /**
  14207. * Parse properties from a JSON object
  14208. * @param serializationObject defines the JSON object
  14209. */
  14210. parse(serializationObject: any): void;
  14211. }
  14212. }
  14213. declare module BABYLON {
  14214. /**
  14215. * Particle emitter emitting particles from the inside of a cylinder.
  14216. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  14217. */
  14218. export class CylinderParticleEmitter implements IParticleEmitterType {
  14219. /**
  14220. * The radius of the emission cylinder.
  14221. */
  14222. radius: number;
  14223. /**
  14224. * The height of the emission cylinder.
  14225. */
  14226. height: number;
  14227. /**
  14228. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14229. */
  14230. radiusRange: number;
  14231. /**
  14232. * How much to randomize the particle direction [0-1].
  14233. */
  14234. directionRandomizer: number;
  14235. /**
  14236. * Creates a new instance CylinderParticleEmitter
  14237. * @param radius the radius of the emission cylinder (1 by default)
  14238. * @param height the height of the emission cylinder (1 by default)
  14239. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14240. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14241. */
  14242. constructor(
  14243. /**
  14244. * The radius of the emission cylinder.
  14245. */
  14246. radius?: number,
  14247. /**
  14248. * The height of the emission cylinder.
  14249. */
  14250. height?: number,
  14251. /**
  14252. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14253. */
  14254. radiusRange?: number,
  14255. /**
  14256. * How much to randomize the particle direction [0-1].
  14257. */
  14258. directionRandomizer?: number);
  14259. /**
  14260. * Called by the particle System when the direction is computed for the created particle.
  14261. * @param worldMatrix is the world matrix of the particle system
  14262. * @param directionToUpdate is the direction vector to update with the result
  14263. * @param particle is the particle we are computed the direction for
  14264. */
  14265. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14266. /**
  14267. * Called by the particle System when the position is computed for the created particle.
  14268. * @param worldMatrix is the world matrix of the particle system
  14269. * @param positionToUpdate is the position vector to update with the result
  14270. * @param particle is the particle we are computed the position for
  14271. */
  14272. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14273. /**
  14274. * Clones the current emitter and returns a copy of it
  14275. * @returns the new emitter
  14276. */
  14277. clone(): CylinderParticleEmitter;
  14278. /**
  14279. * Called by the GPUParticleSystem to setup the update shader
  14280. * @param effect defines the update shader
  14281. */
  14282. applyToShader(effect: Effect): void;
  14283. /**
  14284. * Returns a string to use to update the GPU particles update shader
  14285. * @returns a string containng the defines string
  14286. */
  14287. getEffectDefines(): string;
  14288. /**
  14289. * Returns the string "CylinderParticleEmitter"
  14290. * @returns a string containing the class name
  14291. */
  14292. getClassName(): string;
  14293. /**
  14294. * Serializes the particle system to a JSON object.
  14295. * @returns the JSON object
  14296. */
  14297. serialize(): any;
  14298. /**
  14299. * Parse properties from a JSON object
  14300. * @param serializationObject defines the JSON object
  14301. */
  14302. parse(serializationObject: any): void;
  14303. }
  14304. /**
  14305. * Particle emitter emitting particles from the inside of a cylinder.
  14306. * It emits the particles randomly between two vectors.
  14307. */
  14308. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  14309. /**
  14310. * The min limit of the emission direction.
  14311. */
  14312. direction1: Vector3;
  14313. /**
  14314. * The max limit of the emission direction.
  14315. */
  14316. direction2: Vector3;
  14317. /**
  14318. * Creates a new instance CylinderDirectedParticleEmitter
  14319. * @param radius the radius of the emission cylinder (1 by default)
  14320. * @param height the height of the emission cylinder (1 by default)
  14321. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14322. * @param direction1 the min limit of the emission direction (up vector by default)
  14323. * @param direction2 the max limit of the emission direction (up vector by default)
  14324. */
  14325. constructor(radius?: number, height?: number, radiusRange?: number,
  14326. /**
  14327. * The min limit of the emission direction.
  14328. */
  14329. direction1?: Vector3,
  14330. /**
  14331. * The max limit of the emission direction.
  14332. */
  14333. direction2?: Vector3);
  14334. /**
  14335. * Called by the particle System when the direction is computed for the created particle.
  14336. * @param worldMatrix is the world matrix of the particle system
  14337. * @param directionToUpdate is the direction vector to update with the result
  14338. * @param particle is the particle we are computed the direction for
  14339. */
  14340. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14341. /**
  14342. * Clones the current emitter and returns a copy of it
  14343. * @returns the new emitter
  14344. */
  14345. clone(): CylinderDirectedParticleEmitter;
  14346. /**
  14347. * Called by the GPUParticleSystem to setup the update shader
  14348. * @param effect defines the update shader
  14349. */
  14350. applyToShader(effect: Effect): void;
  14351. /**
  14352. * Returns a string to use to update the GPU particles update shader
  14353. * @returns a string containng the defines string
  14354. */
  14355. getEffectDefines(): string;
  14356. /**
  14357. * Returns the string "CylinderDirectedParticleEmitter"
  14358. * @returns a string containing the class name
  14359. */
  14360. getClassName(): string;
  14361. /**
  14362. * Serializes the particle system to a JSON object.
  14363. * @returns the JSON object
  14364. */
  14365. serialize(): any;
  14366. /**
  14367. * Parse properties from a JSON object
  14368. * @param serializationObject defines the JSON object
  14369. */
  14370. parse(serializationObject: any): void;
  14371. }
  14372. }
  14373. declare module BABYLON {
  14374. /**
  14375. * Particle emitter emitting particles from the inside of a hemisphere.
  14376. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  14377. */
  14378. export class HemisphericParticleEmitter implements IParticleEmitterType {
  14379. /**
  14380. * The radius of the emission hemisphere.
  14381. */
  14382. radius: number;
  14383. /**
  14384. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14385. */
  14386. radiusRange: number;
  14387. /**
  14388. * How much to randomize the particle direction [0-1].
  14389. */
  14390. directionRandomizer: number;
  14391. /**
  14392. * Creates a new instance HemisphericParticleEmitter
  14393. * @param radius the radius of the emission hemisphere (1 by default)
  14394. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14395. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14396. */
  14397. constructor(
  14398. /**
  14399. * The radius of the emission hemisphere.
  14400. */
  14401. radius?: number,
  14402. /**
  14403. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14404. */
  14405. radiusRange?: number,
  14406. /**
  14407. * How much to randomize the particle direction [0-1].
  14408. */
  14409. directionRandomizer?: number);
  14410. /**
  14411. * Called by the particle System when the direction is computed for the created particle.
  14412. * @param worldMatrix is the world matrix of the particle system
  14413. * @param directionToUpdate is the direction vector to update with the result
  14414. * @param particle is the particle we are computed the direction for
  14415. */
  14416. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14417. /**
  14418. * Called by the particle System when the position is computed for the created particle.
  14419. * @param worldMatrix is the world matrix of the particle system
  14420. * @param positionToUpdate is the position vector to update with the result
  14421. * @param particle is the particle we are computed the position for
  14422. */
  14423. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14424. /**
  14425. * Clones the current emitter and returns a copy of it
  14426. * @returns the new emitter
  14427. */
  14428. clone(): HemisphericParticleEmitter;
  14429. /**
  14430. * Called by the GPUParticleSystem to setup the update shader
  14431. * @param effect defines the update shader
  14432. */
  14433. applyToShader(effect: Effect): void;
  14434. /**
  14435. * Returns a string to use to update the GPU particles update shader
  14436. * @returns a string containng the defines string
  14437. */
  14438. getEffectDefines(): string;
  14439. /**
  14440. * Returns the string "HemisphericParticleEmitter"
  14441. * @returns a string containing the class name
  14442. */
  14443. getClassName(): string;
  14444. /**
  14445. * Serializes the particle system to a JSON object.
  14446. * @returns the JSON object
  14447. */
  14448. serialize(): any;
  14449. /**
  14450. * Parse properties from a JSON object
  14451. * @param serializationObject defines the JSON object
  14452. */
  14453. parse(serializationObject: any): void;
  14454. }
  14455. }
  14456. declare module BABYLON {
  14457. /**
  14458. * Particle emitter emitting particles from a point.
  14459. * It emits the particles randomly between 2 given directions.
  14460. */
  14461. export class PointParticleEmitter implements IParticleEmitterType {
  14462. /**
  14463. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14464. */
  14465. direction1: Vector3;
  14466. /**
  14467. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14468. */
  14469. direction2: Vector3;
  14470. /**
  14471. * Creates a new instance PointParticleEmitter
  14472. */
  14473. constructor();
  14474. /**
  14475. * Called by the particle System when the direction is computed for the created particle.
  14476. * @param worldMatrix is the world matrix of the particle system
  14477. * @param directionToUpdate is the direction vector to update with the result
  14478. * @param particle is the particle we are computed the direction for
  14479. */
  14480. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14481. /**
  14482. * Called by the particle System when the position is computed for the created particle.
  14483. * @param worldMatrix is the world matrix of the particle system
  14484. * @param positionToUpdate is the position vector to update with the result
  14485. * @param particle is the particle we are computed the position for
  14486. */
  14487. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14488. /**
  14489. * Clones the current emitter and returns a copy of it
  14490. * @returns the new emitter
  14491. */
  14492. clone(): PointParticleEmitter;
  14493. /**
  14494. * Called by the GPUParticleSystem to setup the update shader
  14495. * @param effect defines the update shader
  14496. */
  14497. applyToShader(effect: Effect): void;
  14498. /**
  14499. * Returns a string to use to update the GPU particles update shader
  14500. * @returns a string containng the defines string
  14501. */
  14502. getEffectDefines(): string;
  14503. /**
  14504. * Returns the string "PointParticleEmitter"
  14505. * @returns a string containing the class name
  14506. */
  14507. getClassName(): string;
  14508. /**
  14509. * Serializes the particle system to a JSON object.
  14510. * @returns the JSON object
  14511. */
  14512. serialize(): any;
  14513. /**
  14514. * Parse properties from a JSON object
  14515. * @param serializationObject defines the JSON object
  14516. */
  14517. parse(serializationObject: any): void;
  14518. }
  14519. }
  14520. declare module BABYLON {
  14521. /**
  14522. * Particle emitter emitting particles from the inside of a sphere.
  14523. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14524. */
  14525. export class SphereParticleEmitter implements IParticleEmitterType {
  14526. /**
  14527. * The radius of the emission sphere.
  14528. */
  14529. radius: number;
  14530. /**
  14531. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14532. */
  14533. radiusRange: number;
  14534. /**
  14535. * How much to randomize the particle direction [0-1].
  14536. */
  14537. directionRandomizer: number;
  14538. /**
  14539. * Creates a new instance SphereParticleEmitter
  14540. * @param radius the radius of the emission sphere (1 by default)
  14541. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14542. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14543. */
  14544. constructor(
  14545. /**
  14546. * The radius of the emission sphere.
  14547. */
  14548. radius?: number,
  14549. /**
  14550. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14551. */
  14552. radiusRange?: number,
  14553. /**
  14554. * How much to randomize the particle direction [0-1].
  14555. */
  14556. directionRandomizer?: number);
  14557. /**
  14558. * Called by the particle System when the direction is computed for the created particle.
  14559. * @param worldMatrix is the world matrix of the particle system
  14560. * @param directionToUpdate is the direction vector to update with the result
  14561. * @param particle is the particle we are computed the direction for
  14562. */
  14563. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14564. /**
  14565. * Called by the particle System when the position is computed for the created particle.
  14566. * @param worldMatrix is the world matrix of the particle system
  14567. * @param positionToUpdate is the position vector to update with the result
  14568. * @param particle is the particle we are computed the position for
  14569. */
  14570. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14571. /**
  14572. * Clones the current emitter and returns a copy of it
  14573. * @returns the new emitter
  14574. */
  14575. clone(): SphereParticleEmitter;
  14576. /**
  14577. * Called by the GPUParticleSystem to setup the update shader
  14578. * @param effect defines the update shader
  14579. */
  14580. applyToShader(effect: Effect): void;
  14581. /**
  14582. * Returns a string to use to update the GPU particles update shader
  14583. * @returns a string containng the defines string
  14584. */
  14585. getEffectDefines(): string;
  14586. /**
  14587. * Returns the string "SphereParticleEmitter"
  14588. * @returns a string containing the class name
  14589. */
  14590. getClassName(): string;
  14591. /**
  14592. * Serializes the particle system to a JSON object.
  14593. * @returns the JSON object
  14594. */
  14595. serialize(): any;
  14596. /**
  14597. * Parse properties from a JSON object
  14598. * @param serializationObject defines the JSON object
  14599. */
  14600. parse(serializationObject: any): void;
  14601. }
  14602. /**
  14603. * Particle emitter emitting particles from the inside of a sphere.
  14604. * It emits the particles randomly between two vectors.
  14605. */
  14606. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14607. /**
  14608. * The min limit of the emission direction.
  14609. */
  14610. direction1: Vector3;
  14611. /**
  14612. * The max limit of the emission direction.
  14613. */
  14614. direction2: Vector3;
  14615. /**
  14616. * Creates a new instance SphereDirectedParticleEmitter
  14617. * @param radius the radius of the emission sphere (1 by default)
  14618. * @param direction1 the min limit of the emission direction (up vector by default)
  14619. * @param direction2 the max limit of the emission direction (up vector by default)
  14620. */
  14621. constructor(radius?: number,
  14622. /**
  14623. * The min limit of the emission direction.
  14624. */
  14625. direction1?: Vector3,
  14626. /**
  14627. * The max limit of the emission direction.
  14628. */
  14629. direction2?: Vector3);
  14630. /**
  14631. * Called by the particle System when the direction is computed for the created particle.
  14632. * @param worldMatrix is the world matrix of the particle system
  14633. * @param directionToUpdate is the direction vector to update with the result
  14634. * @param particle is the particle we are computed the direction for
  14635. */
  14636. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14637. /**
  14638. * Clones the current emitter and returns a copy of it
  14639. * @returns the new emitter
  14640. */
  14641. clone(): SphereDirectedParticleEmitter;
  14642. /**
  14643. * Called by the GPUParticleSystem to setup the update shader
  14644. * @param effect defines the update shader
  14645. */
  14646. applyToShader(effect: Effect): void;
  14647. /**
  14648. * Returns a string to use to update the GPU particles update shader
  14649. * @returns a string containng the defines string
  14650. */
  14651. getEffectDefines(): string;
  14652. /**
  14653. * Returns the string "SphereDirectedParticleEmitter"
  14654. * @returns a string containing the class name
  14655. */
  14656. getClassName(): string;
  14657. /**
  14658. * Serializes the particle system to a JSON object.
  14659. * @returns the JSON object
  14660. */
  14661. serialize(): any;
  14662. /**
  14663. * Parse properties from a JSON object
  14664. * @param serializationObject defines the JSON object
  14665. */
  14666. parse(serializationObject: any): void;
  14667. }
  14668. }
  14669. declare module BABYLON {
  14670. /**
  14671. * Interface representing a particle system in Babylon.js.
  14672. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14673. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14674. */
  14675. export interface IParticleSystem {
  14676. /**
  14677. * List of animations used by the particle system.
  14678. */
  14679. animations: Animation[];
  14680. /**
  14681. * The id of the Particle system.
  14682. */
  14683. id: string;
  14684. /**
  14685. * The name of the Particle system.
  14686. */
  14687. name: string;
  14688. /**
  14689. * The emitter represents the Mesh or position we are attaching the particle system to.
  14690. */
  14691. emitter: Nullable<AbstractMesh | Vector3>;
  14692. /**
  14693. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14694. */
  14695. isBillboardBased: boolean;
  14696. /**
  14697. * The rendering group used by the Particle system to chose when to render.
  14698. */
  14699. renderingGroupId: number;
  14700. /**
  14701. * The layer mask we are rendering the particles through.
  14702. */
  14703. layerMask: number;
  14704. /**
  14705. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14706. */
  14707. updateSpeed: number;
  14708. /**
  14709. * The amount of time the particle system is running (depends of the overall update speed).
  14710. */
  14711. targetStopDuration: number;
  14712. /**
  14713. * The texture used to render each particle. (this can be a spritesheet)
  14714. */
  14715. particleTexture: Nullable<Texture>;
  14716. /**
  14717. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14718. */
  14719. blendMode: number;
  14720. /**
  14721. * Minimum life time of emitting particles.
  14722. */
  14723. minLifeTime: number;
  14724. /**
  14725. * Maximum life time of emitting particles.
  14726. */
  14727. maxLifeTime: number;
  14728. /**
  14729. * Minimum Size of emitting particles.
  14730. */
  14731. minSize: number;
  14732. /**
  14733. * Maximum Size of emitting particles.
  14734. */
  14735. maxSize: number;
  14736. /**
  14737. * Minimum scale of emitting particles on X axis.
  14738. */
  14739. minScaleX: number;
  14740. /**
  14741. * Maximum scale of emitting particles on X axis.
  14742. */
  14743. maxScaleX: number;
  14744. /**
  14745. * Minimum scale of emitting particles on Y axis.
  14746. */
  14747. minScaleY: number;
  14748. /**
  14749. * Maximum scale of emitting particles on Y axis.
  14750. */
  14751. maxScaleY: number;
  14752. /**
  14753. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14754. */
  14755. color1: Color4;
  14756. /**
  14757. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14758. */
  14759. color2: Color4;
  14760. /**
  14761. * Color the particle will have at the end of its lifetime.
  14762. */
  14763. colorDead: Color4;
  14764. /**
  14765. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14766. */
  14767. emitRate: number;
  14768. /**
  14769. * You can use gravity if you want to give an orientation to your particles.
  14770. */
  14771. gravity: Vector3;
  14772. /**
  14773. * Minimum power of emitting particles.
  14774. */
  14775. minEmitPower: number;
  14776. /**
  14777. * Maximum power of emitting particles.
  14778. */
  14779. maxEmitPower: number;
  14780. /**
  14781. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14782. */
  14783. minAngularSpeed: number;
  14784. /**
  14785. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14786. */
  14787. maxAngularSpeed: number;
  14788. /**
  14789. * Gets or sets the minimal initial rotation in radians.
  14790. */
  14791. minInitialRotation: number;
  14792. /**
  14793. * Gets or sets the maximal initial rotation in radians.
  14794. */
  14795. maxInitialRotation: number;
  14796. /**
  14797. * The particle emitter type defines the emitter used by the particle system.
  14798. * It can be for example box, sphere, or cone...
  14799. */
  14800. particleEmitterType: Nullable<IParticleEmitterType>;
  14801. /**
  14802. * Defines the delay in milliseconds before starting the system (0 by default)
  14803. */
  14804. startDelay: number;
  14805. /**
  14806. * 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
  14807. */
  14808. preWarmCycles: number;
  14809. /**
  14810. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14811. */
  14812. preWarmStepOffset: number;
  14813. /**
  14814. * 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)
  14815. */
  14816. spriteCellChangeSpeed: number;
  14817. /**
  14818. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14819. */
  14820. startSpriteCellID: number;
  14821. /**
  14822. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14823. */
  14824. endSpriteCellID: number;
  14825. /**
  14826. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14827. */
  14828. spriteCellWidth: number;
  14829. /**
  14830. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14831. */
  14832. spriteCellHeight: number;
  14833. /**
  14834. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14835. */
  14836. spriteRandomStartCell: boolean;
  14837. /**
  14838. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14839. */
  14840. isAnimationSheetEnabled: boolean;
  14841. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14842. translationPivot: Vector2;
  14843. /**
  14844. * Gets or sets a texture used to add random noise to particle positions
  14845. */
  14846. noiseTexture: Nullable<BaseTexture>;
  14847. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14848. noiseStrength: Vector3;
  14849. /**
  14850. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14851. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14852. */
  14853. billboardMode: number;
  14854. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14855. limitVelocityDamping: number;
  14856. /**
  14857. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14858. */
  14859. beginAnimationOnStart: boolean;
  14860. /**
  14861. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14862. */
  14863. beginAnimationFrom: number;
  14864. /**
  14865. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14866. */
  14867. beginAnimationTo: number;
  14868. /**
  14869. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14870. */
  14871. beginAnimationLoop: boolean;
  14872. /**
  14873. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14874. */
  14875. disposeOnStop: boolean;
  14876. /**
  14877. * Gets the maximum number of particles active at the same time.
  14878. * @returns The max number of active particles.
  14879. */
  14880. getCapacity(): number;
  14881. /**
  14882. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14883. * @returns True if it has been started, otherwise false.
  14884. */
  14885. isStarted(): boolean;
  14886. /**
  14887. * Animates the particle system for this frame.
  14888. */
  14889. animate(): void;
  14890. /**
  14891. * Renders the particle system in its current state.
  14892. * @returns the current number of particles
  14893. */
  14894. render(): number;
  14895. /**
  14896. * Dispose the particle system and frees its associated resources.
  14897. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14898. */
  14899. dispose(disposeTexture?: boolean): void;
  14900. /**
  14901. * Clones the particle system.
  14902. * @param name The name of the cloned object
  14903. * @param newEmitter The new emitter to use
  14904. * @returns the cloned particle system
  14905. */
  14906. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14907. /**
  14908. * Serializes the particle system to a JSON object.
  14909. * @returns the JSON object
  14910. */
  14911. serialize(): any;
  14912. /**
  14913. * Rebuild the particle system
  14914. */
  14915. rebuild(): void;
  14916. /**
  14917. * Starts the particle system and begins to emit
  14918. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14919. */
  14920. start(delay?: number): void;
  14921. /**
  14922. * Stops the particle system.
  14923. */
  14924. stop(): void;
  14925. /**
  14926. * Remove all active particles
  14927. */
  14928. reset(): void;
  14929. /**
  14930. * Is this system ready to be used/rendered
  14931. * @return true if the system is ready
  14932. */
  14933. isReady(): boolean;
  14934. /**
  14935. * Adds a new color gradient
  14936. * @param gradient defines the gradient to use (between 0 and 1)
  14937. * @param color1 defines the color to affect to the specified gradient
  14938. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14939. * @returns the current particle system
  14940. */
  14941. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14942. /**
  14943. * Remove a specific color gradient
  14944. * @param gradient defines the gradient to remove
  14945. * @returns the current particle system
  14946. */
  14947. removeColorGradient(gradient: number): IParticleSystem;
  14948. /**
  14949. * Adds a new size gradient
  14950. * @param gradient defines the gradient to use (between 0 and 1)
  14951. * @param factor defines the size factor to affect to the specified gradient
  14952. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14953. * @returns the current particle system
  14954. */
  14955. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14956. /**
  14957. * Remove a specific size gradient
  14958. * @param gradient defines the gradient to remove
  14959. * @returns the current particle system
  14960. */
  14961. removeSizeGradient(gradient: number): IParticleSystem;
  14962. /**
  14963. * Gets the current list of color gradients.
  14964. * You must use addColorGradient and removeColorGradient to udpate this list
  14965. * @returns the list of color gradients
  14966. */
  14967. getColorGradients(): Nullable<Array<ColorGradient>>;
  14968. /**
  14969. * Gets the current list of size gradients.
  14970. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14971. * @returns the list of size gradients
  14972. */
  14973. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14974. /**
  14975. * Gets the current list of angular speed gradients.
  14976. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14977. * @returns the list of angular speed gradients
  14978. */
  14979. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14980. /**
  14981. * Adds a new angular speed gradient
  14982. * @param gradient defines the gradient to use (between 0 and 1)
  14983. * @param factor defines the angular speed to affect to the specified gradient
  14984. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14985. * @returns the current particle system
  14986. */
  14987. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14988. /**
  14989. * Remove a specific angular speed gradient
  14990. * @param gradient defines the gradient to remove
  14991. * @returns the current particle system
  14992. */
  14993. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14994. /**
  14995. * Gets the current list of velocity gradients.
  14996. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14997. * @returns the list of velocity gradients
  14998. */
  14999. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15000. /**
  15001. * Adds a new velocity gradient
  15002. * @param gradient defines the gradient to use (between 0 and 1)
  15003. * @param factor defines the velocity to affect to the specified gradient
  15004. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15005. * @returns the current particle system
  15006. */
  15007. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15008. /**
  15009. * Remove a specific velocity gradient
  15010. * @param gradient defines the gradient to remove
  15011. * @returns the current particle system
  15012. */
  15013. removeVelocityGradient(gradient: number): IParticleSystem;
  15014. /**
  15015. * Gets the current list of limit velocity gradients.
  15016. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  15017. * @returns the list of limit velocity gradients
  15018. */
  15019. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15020. /**
  15021. * Adds a new limit velocity gradient
  15022. * @param gradient defines the gradient to use (between 0 and 1)
  15023. * @param factor defines the limit velocity to affect to the specified gradient
  15024. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15025. * @returns the current particle system
  15026. */
  15027. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15028. /**
  15029. * Remove a specific limit velocity gradient
  15030. * @param gradient defines the gradient to remove
  15031. * @returns the current particle system
  15032. */
  15033. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15034. /**
  15035. * Adds a new drag gradient
  15036. * @param gradient defines the gradient to use (between 0 and 1)
  15037. * @param factor defines the drag to affect to the specified gradient
  15038. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15039. * @returns the current particle system
  15040. */
  15041. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15042. /**
  15043. * Remove a specific drag gradient
  15044. * @param gradient defines the gradient to remove
  15045. * @returns the current particle system
  15046. */
  15047. removeDragGradient(gradient: number): IParticleSystem;
  15048. /**
  15049. * Gets the current list of drag gradients.
  15050. * You must use addDragGradient and removeDragGradient to udpate this list
  15051. * @returns the list of drag gradients
  15052. */
  15053. getDragGradients(): Nullable<Array<FactorGradient>>;
  15054. /**
  15055. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15056. * @param gradient defines the gradient to use (between 0 and 1)
  15057. * @param factor defines the emit rate to affect to the specified gradient
  15058. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15059. * @returns the current particle system
  15060. */
  15061. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15062. /**
  15063. * Remove a specific emit rate gradient
  15064. * @param gradient defines the gradient to remove
  15065. * @returns the current particle system
  15066. */
  15067. removeEmitRateGradient(gradient: number): IParticleSystem;
  15068. /**
  15069. * Gets the current list of emit rate gradients.
  15070. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15071. * @returns the list of emit rate gradients
  15072. */
  15073. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15074. /**
  15075. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15076. * @param gradient defines the gradient to use (between 0 and 1)
  15077. * @param factor defines the start size to affect to the specified gradient
  15078. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15079. * @returns the current particle system
  15080. */
  15081. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15082. /**
  15083. * Remove a specific start size gradient
  15084. * @param gradient defines the gradient to remove
  15085. * @returns the current particle system
  15086. */
  15087. removeStartSizeGradient(gradient: number): IParticleSystem;
  15088. /**
  15089. * Gets the current list of start size gradients.
  15090. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15091. * @returns the list of start size gradients
  15092. */
  15093. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15094. /**
  15095. * Adds a new life time gradient
  15096. * @param gradient defines the gradient to use (between 0 and 1)
  15097. * @param factor defines the life time factor to affect to the specified gradient
  15098. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15099. * @returns the current particle system
  15100. */
  15101. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15102. /**
  15103. * Remove a specific life time gradient
  15104. * @param gradient defines the gradient to remove
  15105. * @returns the current particle system
  15106. */
  15107. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15108. /**
  15109. * Gets the current list of life time gradients.
  15110. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  15111. * @returns the list of life time gradients
  15112. */
  15113. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15114. /**
  15115. * Gets the current list of color gradients.
  15116. * You must use addColorGradient and removeColorGradient to udpate this list
  15117. * @returns the list of color gradients
  15118. */
  15119. getColorGradients(): Nullable<Array<ColorGradient>>;
  15120. /**
  15121. * Adds a new ramp gradient used to remap particle colors
  15122. * @param gradient defines the gradient to use (between 0 and 1)
  15123. * @param color defines the color to affect to the specified gradient
  15124. * @returns the current particle system
  15125. */
  15126. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  15127. /**
  15128. * Gets the current list of ramp gradients.
  15129. * You must use addRampGradient and removeRampGradient to udpate this list
  15130. * @returns the list of ramp gradients
  15131. */
  15132. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15133. /** Gets or sets a boolean indicating that ramp gradients must be used
  15134. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15135. */
  15136. useRampGradients: boolean;
  15137. /**
  15138. * Adds a new color remap gradient
  15139. * @param gradient defines the gradient to use (between 0 and 1)
  15140. * @param min defines the color remap minimal range
  15141. * @param max defines the color remap maximal range
  15142. * @returns the current particle system
  15143. */
  15144. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15145. /**
  15146. * Gets the current list of color remap gradients.
  15147. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15148. * @returns the list of color remap gradients
  15149. */
  15150. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15151. /**
  15152. * Adds a new alpha remap gradient
  15153. * @param gradient defines the gradient to use (between 0 and 1)
  15154. * @param min defines the alpha remap minimal range
  15155. * @param max defines the alpha remap maximal range
  15156. * @returns the current particle system
  15157. */
  15158. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15159. /**
  15160. * Gets the current list of alpha remap gradients.
  15161. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15162. * @returns the list of alpha remap gradients
  15163. */
  15164. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15165. /**
  15166. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15167. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15168. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15169. * @returns the emitter
  15170. */
  15171. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15172. /**
  15173. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15174. * @param radius The radius of the hemisphere to emit from
  15175. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15176. * @returns the emitter
  15177. */
  15178. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  15179. /**
  15180. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15181. * @param radius The radius of the sphere to emit from
  15182. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15183. * @returns the emitter
  15184. */
  15185. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  15186. /**
  15187. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15188. * @param radius The radius of the sphere to emit from
  15189. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15190. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15191. * @returns the emitter
  15192. */
  15193. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15194. /**
  15195. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15196. * @param radius The radius of the emission cylinder
  15197. * @param height The height of the emission cylinder
  15198. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15199. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15200. * @returns the emitter
  15201. */
  15202. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15203. /**
  15204. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15205. * @param radius The radius of the cylinder to emit from
  15206. * @param height The height of the emission cylinder
  15207. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15208. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15209. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15210. * @returns the emitter
  15211. */
  15212. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15213. /**
  15214. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15215. * @param radius The radius of the cone to emit from
  15216. * @param angle The base angle of the cone
  15217. * @returns the emitter
  15218. */
  15219. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15220. /**
  15221. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15222. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15223. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15224. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15225. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15226. * @returns the emitter
  15227. */
  15228. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15229. /**
  15230. * Get hosting scene
  15231. * @returns the scene
  15232. */
  15233. getScene(): Scene;
  15234. }
  15235. }
  15236. declare module BABYLON {
  15237. /**
  15238. * Creates an instance based on a source mesh.
  15239. */
  15240. export class InstancedMesh extends AbstractMesh {
  15241. private _sourceMesh;
  15242. private _currentLOD;
  15243. /** @hidden */
  15244. _indexInSourceMeshInstanceArray: number;
  15245. constructor(name: string, source: Mesh);
  15246. /**
  15247. * Returns the string "InstancedMesh".
  15248. */
  15249. getClassName(): string;
  15250. /**
  15251. * If the source mesh receives shadows
  15252. */
  15253. readonly receiveShadows: boolean;
  15254. /**
  15255. * The material of the source mesh
  15256. */
  15257. readonly material: Nullable<Material>;
  15258. /**
  15259. * Visibility of the source mesh
  15260. */
  15261. readonly visibility: number;
  15262. /**
  15263. * Skeleton of the source mesh
  15264. */
  15265. readonly skeleton: Nullable<Skeleton>;
  15266. /**
  15267. * Rendering ground id of the source mesh
  15268. */
  15269. renderingGroupId: number;
  15270. /**
  15271. * Returns the total number of vertices (integer).
  15272. */
  15273. getTotalVertices(): number;
  15274. /**
  15275. * Returns a positive integer : the total number of indices in this mesh geometry.
  15276. * @returns the numner of indices or zero if the mesh has no geometry.
  15277. */
  15278. getTotalIndices(): number;
  15279. /**
  15280. * The source mesh of the instance
  15281. */
  15282. readonly sourceMesh: Mesh;
  15283. /**
  15284. * Is this node ready to be used/rendered
  15285. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15286. * @return {boolean} is it ready
  15287. */
  15288. isReady(completeCheck?: boolean): boolean;
  15289. /**
  15290. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15291. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15292. * @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.
  15293. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15294. */
  15295. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15296. /**
  15297. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15298. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15299. * The `data` are either a numeric array either a Float32Array.
  15300. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15301. * 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).
  15302. * Note that a new underlying VertexBuffer object is created each call.
  15303. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15304. *
  15305. * Possible `kind` values :
  15306. * - VertexBuffer.PositionKind
  15307. * - VertexBuffer.UVKind
  15308. * - VertexBuffer.UV2Kind
  15309. * - VertexBuffer.UV3Kind
  15310. * - VertexBuffer.UV4Kind
  15311. * - VertexBuffer.UV5Kind
  15312. * - VertexBuffer.UV6Kind
  15313. * - VertexBuffer.ColorKind
  15314. * - VertexBuffer.MatricesIndicesKind
  15315. * - VertexBuffer.MatricesIndicesExtraKind
  15316. * - VertexBuffer.MatricesWeightsKind
  15317. * - VertexBuffer.MatricesWeightsExtraKind
  15318. *
  15319. * Returns the Mesh.
  15320. */
  15321. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  15322. /**
  15323. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15324. * If the mesh has no geometry, it is simply returned as it is.
  15325. * The `data` are either a numeric array either a Float32Array.
  15326. * No new underlying VertexBuffer object is created.
  15327. * 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.
  15328. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15329. *
  15330. * Possible `kind` values :
  15331. * - VertexBuffer.PositionKind
  15332. * - VertexBuffer.UVKind
  15333. * - VertexBuffer.UV2Kind
  15334. * - VertexBuffer.UV3Kind
  15335. * - VertexBuffer.UV4Kind
  15336. * - VertexBuffer.UV5Kind
  15337. * - VertexBuffer.UV6Kind
  15338. * - VertexBuffer.ColorKind
  15339. * - VertexBuffer.MatricesIndicesKind
  15340. * - VertexBuffer.MatricesIndicesExtraKind
  15341. * - VertexBuffer.MatricesWeightsKind
  15342. * - VertexBuffer.MatricesWeightsExtraKind
  15343. *
  15344. * Returns the Mesh.
  15345. */
  15346. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15347. /**
  15348. * Sets the mesh indices.
  15349. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15350. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15351. * This method creates a new index buffer each call.
  15352. * Returns the Mesh.
  15353. */
  15354. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15355. /**
  15356. * Boolean : True if the mesh owns the requested kind of data.
  15357. */
  15358. isVerticesDataPresent(kind: string): boolean;
  15359. /**
  15360. * Returns an array of indices (IndicesArray).
  15361. */
  15362. getIndices(): Nullable<IndicesArray>;
  15363. readonly _positions: Nullable<Vector3[]>;
  15364. /**
  15365. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15366. * This means the mesh underlying bounding box and sphere are recomputed.
  15367. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15368. * @returns the current mesh
  15369. */
  15370. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15371. /** @hidden */
  15372. _preActivate(): InstancedMesh;
  15373. /** @hidden */
  15374. _activate(renderId: number): InstancedMesh;
  15375. /**
  15376. * Returns the current associated LOD AbstractMesh.
  15377. */
  15378. getLOD(camera: Camera): AbstractMesh;
  15379. /** @hidden */
  15380. _syncSubMeshes(): InstancedMesh;
  15381. /** @hidden */
  15382. _generatePointsArray(): boolean;
  15383. /**
  15384. * Creates a new InstancedMesh from the current mesh.
  15385. * - name (string) : the cloned mesh name
  15386. * - newParent (optional Node) : the optional Node to parent the clone to.
  15387. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15388. *
  15389. * Returns the clone.
  15390. */
  15391. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  15392. /**
  15393. * Disposes the InstancedMesh.
  15394. * Returns nothing.
  15395. */
  15396. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15397. }
  15398. }
  15399. declare module BABYLON {
  15400. /**
  15401. * Defines the options associated with the creation of a shader material.
  15402. */
  15403. export interface IShaderMaterialOptions {
  15404. /**
  15405. * Does the material work in alpha blend mode
  15406. */
  15407. needAlphaBlending: boolean;
  15408. /**
  15409. * Does the material work in alpha test mode
  15410. */
  15411. needAlphaTesting: boolean;
  15412. /**
  15413. * The list of attribute names used in the shader
  15414. */
  15415. attributes: string[];
  15416. /**
  15417. * The list of unifrom names used in the shader
  15418. */
  15419. uniforms: string[];
  15420. /**
  15421. * The list of UBO names used in the shader
  15422. */
  15423. uniformBuffers: string[];
  15424. /**
  15425. * The list of sampler names used in the shader
  15426. */
  15427. samplers: string[];
  15428. /**
  15429. * The list of defines used in the shader
  15430. */
  15431. defines: string[];
  15432. }
  15433. /**
  15434. * 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.
  15435. *
  15436. * This returned material effects how the mesh will look based on the code in the shaders.
  15437. *
  15438. * @see http://doc.babylonjs.com/how_to/shader_material
  15439. */
  15440. export class ShaderMaterial extends Material {
  15441. private _shaderPath;
  15442. private _options;
  15443. private _textures;
  15444. private _textureArrays;
  15445. private _floats;
  15446. private _ints;
  15447. private _floatsArrays;
  15448. private _colors3;
  15449. private _colors3Arrays;
  15450. private _colors4;
  15451. private _vectors2;
  15452. private _vectors3;
  15453. private _vectors4;
  15454. private _matrices;
  15455. private _matrices3x3;
  15456. private _matrices2x2;
  15457. private _vectors2Arrays;
  15458. private _vectors3Arrays;
  15459. private _cachedWorldViewMatrix;
  15460. private _renderId;
  15461. /**
  15462. * Instantiate a new shader material.
  15463. * 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.
  15464. * This returned material effects how the mesh will look based on the code in the shaders.
  15465. * @see http://doc.babylonjs.com/how_to/shader_material
  15466. * @param name Define the name of the material in the scene
  15467. * @param scene Define the scene the material belongs to
  15468. * @param shaderPath Defines the route to the shader code in one of three ways:
  15469. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15470. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  15471. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15472. * @param options Define the options used to create the shader
  15473. */
  15474. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15475. /**
  15476. * Gets the current class name of the material e.g. "ShaderMaterial"
  15477. * Mainly use in serialization.
  15478. * @returns the class name
  15479. */
  15480. getClassName(): string;
  15481. /**
  15482. * Specifies if the material will require alpha blending
  15483. * @returns a boolean specifying if alpha blending is needed
  15484. */
  15485. needAlphaBlending(): boolean;
  15486. /**
  15487. * Specifies if this material should be rendered in alpha test mode
  15488. * @returns a boolean specifying if an alpha test is needed.
  15489. */
  15490. needAlphaTesting(): boolean;
  15491. private _checkUniform;
  15492. /**
  15493. * Set a texture in the shader.
  15494. * @param name Define the name of the uniform samplers as defined in the shader
  15495. * @param texture Define the texture to bind to this sampler
  15496. * @return the material itself allowing "fluent" like uniform updates
  15497. */
  15498. setTexture(name: string, texture: Texture): ShaderMaterial;
  15499. /**
  15500. * Set a texture array in the shader.
  15501. * @param name Define the name of the uniform sampler array as defined in the shader
  15502. * @param textures Define the list of textures to bind to this sampler
  15503. * @return the material itself allowing "fluent" like uniform updates
  15504. */
  15505. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15506. /**
  15507. * Set a float in the shader.
  15508. * @param name Define the name of the uniform as defined in the shader
  15509. * @param value Define the value to give to the uniform
  15510. * @return the material itself allowing "fluent" like uniform updates
  15511. */
  15512. setFloat(name: string, value: number): ShaderMaterial;
  15513. /**
  15514. * Set a int in the shader.
  15515. * @param name Define the name of the uniform as defined in the shader
  15516. * @param value Define the value to give to the uniform
  15517. * @return the material itself allowing "fluent" like uniform updates
  15518. */
  15519. setInt(name: string, value: number): ShaderMaterial;
  15520. /**
  15521. * Set an array of floats in the shader.
  15522. * @param name Define the name of the uniform as defined in the shader
  15523. * @param value Define the value to give to the uniform
  15524. * @return the material itself allowing "fluent" like uniform updates
  15525. */
  15526. setFloats(name: string, value: number[]): ShaderMaterial;
  15527. /**
  15528. * Set a vec3 in the shader from a Color3.
  15529. * @param name Define the name of the uniform as defined in the shader
  15530. * @param value Define the value to give to the uniform
  15531. * @return the material itself allowing "fluent" like uniform updates
  15532. */
  15533. setColor3(name: string, value: Color3): ShaderMaterial;
  15534. /**
  15535. * Set a vec3 array in the shader from a Color3 array.
  15536. * @param name Define the name of the uniform as defined in the shader
  15537. * @param value Define the value to give to the uniform
  15538. * @return the material itself allowing "fluent" like uniform updates
  15539. */
  15540. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15541. /**
  15542. * Set a vec4 in the shader from a Color4.
  15543. * @param name Define the name of the uniform as defined in the shader
  15544. * @param value Define the value to give to the uniform
  15545. * @return the material itself allowing "fluent" like uniform updates
  15546. */
  15547. setColor4(name: string, value: Color4): ShaderMaterial;
  15548. /**
  15549. * Set a vec2 in the shader from a Vector2.
  15550. * @param name Define the name of the uniform as defined in the shader
  15551. * @param value Define the value to give to the uniform
  15552. * @return the material itself allowing "fluent" like uniform updates
  15553. */
  15554. setVector2(name: string, value: Vector2): ShaderMaterial;
  15555. /**
  15556. * Set a vec3 in the shader from a Vector3.
  15557. * @param name Define the name of the uniform as defined in the shader
  15558. * @param value Define the value to give to the uniform
  15559. * @return the material itself allowing "fluent" like uniform updates
  15560. */
  15561. setVector3(name: string, value: Vector3): ShaderMaterial;
  15562. /**
  15563. * Set a vec4 in the shader from a Vector4.
  15564. * @param name Define the name of the uniform as defined in the shader
  15565. * @param value Define the value to give to the uniform
  15566. * @return the material itself allowing "fluent" like uniform updates
  15567. */
  15568. setVector4(name: string, value: Vector4): ShaderMaterial;
  15569. /**
  15570. * Set a mat4 in the shader from a Matrix.
  15571. * @param name Define the name of the uniform as defined in the shader
  15572. * @param value Define the value to give to the uniform
  15573. * @return the material itself allowing "fluent" like uniform updates
  15574. */
  15575. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15576. /**
  15577. * Set a mat3 in the shader from a Float32Array.
  15578. * @param name Define the name of the uniform as defined in the shader
  15579. * @param value Define the value to give to the uniform
  15580. * @return the material itself allowing "fluent" like uniform updates
  15581. */
  15582. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15583. /**
  15584. * Set a mat2 in the shader from a Float32Array.
  15585. * @param name Define the name of the uniform as defined in the shader
  15586. * @param value Define the value to give to the uniform
  15587. * @return the material itself allowing "fluent" like uniform updates
  15588. */
  15589. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15590. /**
  15591. * Set a vec2 array in the shader from a number array.
  15592. * @param name Define the name of the uniform as defined in the shader
  15593. * @param value Define the value to give to the uniform
  15594. * @return the material itself allowing "fluent" like uniform updates
  15595. */
  15596. setArray2(name: string, value: number[]): ShaderMaterial;
  15597. /**
  15598. * Set a vec3 array in the shader from a number array.
  15599. * @param name Define the name of the uniform as defined in the shader
  15600. * @param value Define the value to give to the uniform
  15601. * @return the material itself allowing "fluent" like uniform updates
  15602. */
  15603. setArray3(name: string, value: number[]): ShaderMaterial;
  15604. private _checkCache;
  15605. /**
  15606. * Checks if the material is ready to render the requested mesh
  15607. * @param mesh Define the mesh to render
  15608. * @param useInstances Define whether or not the material is used with instances
  15609. * @returns true if ready, otherwise false
  15610. */
  15611. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15612. /**
  15613. * Binds the world matrix to the material
  15614. * @param world defines the world transformation matrix
  15615. */
  15616. bindOnlyWorldMatrix(world: Matrix): void;
  15617. /**
  15618. * Binds the material to the mesh
  15619. * @param world defines the world transformation matrix
  15620. * @param mesh defines the mesh to bind the material to
  15621. */
  15622. bind(world: Matrix, mesh?: Mesh): void;
  15623. /**
  15624. * Gets the active textures from the material
  15625. * @returns an array of textures
  15626. */
  15627. getActiveTextures(): BaseTexture[];
  15628. /**
  15629. * Specifies if the material uses a texture
  15630. * @param texture defines the texture to check against the material
  15631. * @returns a boolean specifying if the material uses the texture
  15632. */
  15633. hasTexture(texture: BaseTexture): boolean;
  15634. /**
  15635. * Makes a duplicate of the material, and gives it a new name
  15636. * @param name defines the new name for the duplicated material
  15637. * @returns the cloned material
  15638. */
  15639. clone(name: string): ShaderMaterial;
  15640. /**
  15641. * Disposes the material
  15642. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15643. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15644. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15645. */
  15646. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15647. /**
  15648. * Serializes this material in a JSON representation
  15649. * @returns the serialized material object
  15650. */
  15651. serialize(): any;
  15652. /**
  15653. * Creates a shader material from parsed shader material data
  15654. * @param source defines the JSON represnetation of the material
  15655. * @param scene defines the hosting scene
  15656. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15657. * @returns a new material
  15658. */
  15659. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15660. }
  15661. }
  15662. declare module BABYLON {
  15663. /** @hidden */
  15664. export var colorPixelShader: {
  15665. name: string;
  15666. shader: string;
  15667. };
  15668. }
  15669. declare module BABYLON {
  15670. /** @hidden */
  15671. export var colorVertexShader: {
  15672. name: string;
  15673. shader: string;
  15674. };
  15675. }
  15676. declare module BABYLON {
  15677. /**
  15678. * Line mesh
  15679. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15680. */
  15681. export class LinesMesh extends Mesh {
  15682. /**
  15683. * If vertex color should be applied to the mesh
  15684. */
  15685. useVertexColor?: boolean | undefined;
  15686. /**
  15687. * If vertex alpha should be applied to the mesh
  15688. */
  15689. useVertexAlpha?: boolean | undefined;
  15690. /**
  15691. * Color of the line (Default: White)
  15692. */
  15693. color: Color3;
  15694. /**
  15695. * Alpha of the line (Default: 1)
  15696. */
  15697. alpha: number;
  15698. /**
  15699. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15700. * This margin is expressed in world space coordinates, so its value may vary.
  15701. * Default value is 0.1
  15702. */
  15703. intersectionThreshold: number;
  15704. private _colorShader;
  15705. /**
  15706. * Creates a new LinesMesh
  15707. * @param name defines the name
  15708. * @param scene defines the hosting scene
  15709. * @param parent defines the parent mesh if any
  15710. * @param source defines the optional source LinesMesh used to clone data from
  15711. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15712. * When false, achieved by calling a clone(), also passing False.
  15713. * This will make creation of children, recursive.
  15714. * @param useVertexColor defines if this LinesMesh supports vertex color
  15715. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15716. */
  15717. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  15718. /**
  15719. * If vertex color should be applied to the mesh
  15720. */
  15721. useVertexColor?: boolean | undefined,
  15722. /**
  15723. * If vertex alpha should be applied to the mesh
  15724. */
  15725. useVertexAlpha?: boolean | undefined);
  15726. /**
  15727. * Returns the string "LineMesh"
  15728. */
  15729. getClassName(): string;
  15730. /**
  15731. * @hidden
  15732. */
  15733. /**
  15734. * @hidden
  15735. */
  15736. material: Material;
  15737. /**
  15738. * @hidden
  15739. */
  15740. readonly checkCollisions: boolean;
  15741. /** @hidden */
  15742. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  15743. /** @hidden */
  15744. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  15745. /**
  15746. * Disposes of the line mesh
  15747. * @param doNotRecurse If children should be disposed
  15748. */
  15749. dispose(doNotRecurse?: boolean): void;
  15750. /**
  15751. * Returns a new LineMesh object cloned from the current one.
  15752. */
  15753. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  15754. /**
  15755. * Creates a new InstancedLinesMesh object from the mesh model.
  15756. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15757. * @param name defines the name of the new instance
  15758. * @returns a new InstancedLinesMesh
  15759. */
  15760. createInstance(name: string): InstancedLinesMesh;
  15761. }
  15762. /**
  15763. * Creates an instance based on a source LinesMesh
  15764. */
  15765. export class InstancedLinesMesh extends InstancedMesh {
  15766. /**
  15767. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15768. * This margin is expressed in world space coordinates, so its value may vary.
  15769. * Initilized with the intersectionThreshold value of the source LinesMesh
  15770. */
  15771. intersectionThreshold: number;
  15772. constructor(name: string, source: LinesMesh);
  15773. /**
  15774. * Returns the string "InstancedLinesMesh".
  15775. */
  15776. getClassName(): string;
  15777. }
  15778. }
  15779. declare module BABYLON {
  15780. /** @hidden */
  15781. export var linePixelShader: {
  15782. name: string;
  15783. shader: string;
  15784. };
  15785. }
  15786. declare module BABYLON {
  15787. /** @hidden */
  15788. export var lineVertexShader: {
  15789. name: string;
  15790. shader: string;
  15791. };
  15792. }
  15793. declare module BABYLON {
  15794. interface AbstractMesh {
  15795. /**
  15796. * Disables the mesh edge rendering mode
  15797. * @returns the currentAbstractMesh
  15798. */
  15799. disableEdgesRendering(): AbstractMesh;
  15800. /**
  15801. * Enables the edge rendering mode on the mesh.
  15802. * This mode makes the mesh edges visible
  15803. * @param epsilon defines the maximal distance between two angles to detect a face
  15804. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15805. * @returns the currentAbstractMesh
  15806. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15807. */
  15808. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15809. /**
  15810. * Gets the edgesRenderer associated with the mesh
  15811. */
  15812. edgesRenderer: Nullable<EdgesRenderer>;
  15813. }
  15814. interface LinesMesh {
  15815. /**
  15816. * Enables the edge rendering mode on the mesh.
  15817. * This mode makes the mesh edges visible
  15818. * @param epsilon defines the maximal distance between two angles to detect a face
  15819. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15820. * @returns the currentAbstractMesh
  15821. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15822. */
  15823. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15824. }
  15825. interface InstancedLinesMesh {
  15826. /**
  15827. * Enables the edge rendering mode on the mesh.
  15828. * This mode makes the mesh edges visible
  15829. * @param epsilon defines the maximal distance between two angles to detect a face
  15830. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15831. * @returns the current InstancedLinesMesh
  15832. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15833. */
  15834. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15835. }
  15836. /**
  15837. * Defines the minimum contract an Edges renderer should follow.
  15838. */
  15839. export interface IEdgesRenderer extends IDisposable {
  15840. /**
  15841. * Gets or sets a boolean indicating if the edgesRenderer is active
  15842. */
  15843. isEnabled: boolean;
  15844. /**
  15845. * Renders the edges of the attached mesh,
  15846. */
  15847. render(): void;
  15848. /**
  15849. * Checks wether or not the edges renderer is ready to render.
  15850. * @return true if ready, otherwise false.
  15851. */
  15852. isReady(): boolean;
  15853. }
  15854. /**
  15855. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15856. */
  15857. export class EdgesRenderer implements IEdgesRenderer {
  15858. /**
  15859. * Define the size of the edges with an orthographic camera
  15860. */
  15861. edgesWidthScalerForOrthographic: number;
  15862. /**
  15863. * Define the size of the edges with a perspective camera
  15864. */
  15865. edgesWidthScalerForPerspective: number;
  15866. protected _source: AbstractMesh;
  15867. protected _linesPositions: number[];
  15868. protected _linesNormals: number[];
  15869. protected _linesIndices: number[];
  15870. protected _epsilon: number;
  15871. protected _indicesCount: number;
  15872. protected _lineShader: ShaderMaterial;
  15873. protected _ib: WebGLBuffer;
  15874. protected _buffers: {
  15875. [key: string]: Nullable<VertexBuffer>;
  15876. };
  15877. protected _checkVerticesInsteadOfIndices: boolean;
  15878. private _meshRebuildObserver;
  15879. private _meshDisposeObserver;
  15880. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15881. isEnabled: boolean;
  15882. /**
  15883. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15884. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15885. * @param source Mesh used to create edges
  15886. * @param epsilon sum of angles in adjacency to check for edge
  15887. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15888. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15889. */
  15890. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15891. protected _prepareRessources(): void;
  15892. /** @hidden */
  15893. _rebuild(): void;
  15894. /**
  15895. * Releases the required resources for the edges renderer
  15896. */
  15897. dispose(): void;
  15898. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15899. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15900. /**
  15901. * Checks if the pair of p0 and p1 is en edge
  15902. * @param faceIndex
  15903. * @param edge
  15904. * @param faceNormals
  15905. * @param p0
  15906. * @param p1
  15907. * @private
  15908. */
  15909. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15910. /**
  15911. * push line into the position, normal and index buffer
  15912. * @protected
  15913. */
  15914. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15915. /**
  15916. * Generates lines edges from adjacencjes
  15917. * @private
  15918. */
  15919. _generateEdgesLines(): void;
  15920. /**
  15921. * Checks wether or not the edges renderer is ready to render.
  15922. * @return true if ready, otherwise false.
  15923. */
  15924. isReady(): boolean;
  15925. /**
  15926. * Renders the edges of the attached mesh,
  15927. */
  15928. render(): void;
  15929. }
  15930. /**
  15931. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15932. */
  15933. export class LineEdgesRenderer extends EdgesRenderer {
  15934. /**
  15935. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15936. * @param source LineMesh used to generate edges
  15937. * @param epsilon not important (specified angle for edge detection)
  15938. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15939. */
  15940. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15941. /**
  15942. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15943. */
  15944. _generateEdgesLines(): void;
  15945. }
  15946. }
  15947. declare module BABYLON {
  15948. /**
  15949. * This represents the object necessary to create a rendering group.
  15950. * This is exclusively used and created by the rendering manager.
  15951. * To modify the behavior, you use the available helpers in your scene or meshes.
  15952. * @hidden
  15953. */
  15954. export class RenderingGroup {
  15955. index: number;
  15956. private _scene;
  15957. private _opaqueSubMeshes;
  15958. private _transparentSubMeshes;
  15959. private _alphaTestSubMeshes;
  15960. private _depthOnlySubMeshes;
  15961. private _particleSystems;
  15962. private _spriteManagers;
  15963. private _opaqueSortCompareFn;
  15964. private _alphaTestSortCompareFn;
  15965. private _transparentSortCompareFn;
  15966. private _renderOpaque;
  15967. private _renderAlphaTest;
  15968. private _renderTransparent;
  15969. private _edgesRenderers;
  15970. onBeforeTransparentRendering: () => void;
  15971. /**
  15972. * Set the opaque sort comparison function.
  15973. * If null the sub meshes will be render in the order they were created
  15974. */
  15975. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  15976. /**
  15977. * Set the alpha test sort comparison function.
  15978. * If null the sub meshes will be render in the order they were created
  15979. */
  15980. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  15981. /**
  15982. * Set the transparent sort comparison function.
  15983. * If null the sub meshes will be render in the order they were created
  15984. */
  15985. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  15986. /**
  15987. * Creates a new rendering group.
  15988. * @param index The rendering group index
  15989. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  15990. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  15991. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  15992. */
  15993. 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>);
  15994. /**
  15995. * Render all the sub meshes contained in the group.
  15996. * @param customRenderFunction Used to override the default render behaviour of the group.
  15997. * @returns true if rendered some submeshes.
  15998. */
  15999. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16000. /**
  16001. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16002. * @param subMeshes The submeshes to render
  16003. */
  16004. private renderOpaqueSorted;
  16005. /**
  16006. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16007. * @param subMeshes The submeshes to render
  16008. */
  16009. private renderAlphaTestSorted;
  16010. /**
  16011. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16012. * @param subMeshes The submeshes to render
  16013. */
  16014. private renderTransparentSorted;
  16015. /**
  16016. * Renders the submeshes in a specified order.
  16017. * @param subMeshes The submeshes to sort before render
  16018. * @param sortCompareFn The comparison function use to sort
  16019. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16020. * @param transparent Specifies to activate blending if true
  16021. */
  16022. private static renderSorted;
  16023. /**
  16024. * Renders the submeshes in the order they were dispatched (no sort applied).
  16025. * @param subMeshes The submeshes to render
  16026. */
  16027. private static renderUnsorted;
  16028. /**
  16029. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16030. * are rendered back to front if in the same alpha index.
  16031. *
  16032. * @param a The first submesh
  16033. * @param b The second submesh
  16034. * @returns The result of the comparison
  16035. */
  16036. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16037. /**
  16038. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16039. * are rendered back to front.
  16040. *
  16041. * @param a The first submesh
  16042. * @param b The second submesh
  16043. * @returns The result of the comparison
  16044. */
  16045. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16046. /**
  16047. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16048. * are rendered front to back (prevent overdraw).
  16049. *
  16050. * @param a The first submesh
  16051. * @param b The second submesh
  16052. * @returns The result of the comparison
  16053. */
  16054. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16055. /**
  16056. * Resets the different lists of submeshes to prepare a new frame.
  16057. */
  16058. prepare(): void;
  16059. dispose(): void;
  16060. /**
  16061. * Inserts the submesh in its correct queue depending on its material.
  16062. * @param subMesh The submesh to dispatch
  16063. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16064. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16065. */
  16066. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16067. dispatchSprites(spriteManager: ISpriteManager): void;
  16068. dispatchParticles(particleSystem: IParticleSystem): void;
  16069. private _renderParticles;
  16070. private _renderSprites;
  16071. }
  16072. }
  16073. declare module BABYLON {
  16074. /**
  16075. * Interface describing the different options available in the rendering manager
  16076. * regarding Auto Clear between groups.
  16077. */
  16078. export interface IRenderingManagerAutoClearSetup {
  16079. /**
  16080. * Defines whether or not autoclear is enable.
  16081. */
  16082. autoClear: boolean;
  16083. /**
  16084. * Defines whether or not to autoclear the depth buffer.
  16085. */
  16086. depth: boolean;
  16087. /**
  16088. * Defines whether or not to autoclear the stencil buffer.
  16089. */
  16090. stencil: boolean;
  16091. }
  16092. /**
  16093. * This class is used by the onRenderingGroupObservable
  16094. */
  16095. export class RenderingGroupInfo {
  16096. /**
  16097. * The Scene that being rendered
  16098. */
  16099. scene: Scene;
  16100. /**
  16101. * The camera currently used for the rendering pass
  16102. */
  16103. camera: Nullable<Camera>;
  16104. /**
  16105. * The ID of the renderingGroup being processed
  16106. */
  16107. renderingGroupId: number;
  16108. }
  16109. /**
  16110. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16111. * It is enable to manage the different groups as well as the different necessary sort functions.
  16112. * This should not be used directly aside of the few static configurations
  16113. */
  16114. export class RenderingManager {
  16115. /**
  16116. * The max id used for rendering groups (not included)
  16117. */
  16118. static MAX_RENDERINGGROUPS: number;
  16119. /**
  16120. * The min id used for rendering groups (included)
  16121. */
  16122. static MIN_RENDERINGGROUPS: number;
  16123. /**
  16124. * Used to globally prevent autoclearing scenes.
  16125. */
  16126. static AUTOCLEAR: boolean;
  16127. /**
  16128. * @hidden
  16129. */
  16130. _useSceneAutoClearSetup: boolean;
  16131. private _scene;
  16132. private _renderingGroups;
  16133. private _depthStencilBufferAlreadyCleaned;
  16134. private _autoClearDepthStencil;
  16135. private _customOpaqueSortCompareFn;
  16136. private _customAlphaTestSortCompareFn;
  16137. private _customTransparentSortCompareFn;
  16138. private _renderingGroupInfo;
  16139. /**
  16140. * Instantiates a new rendering group for a particular scene
  16141. * @param scene Defines the scene the groups belongs to
  16142. */
  16143. constructor(scene: Scene);
  16144. private _clearDepthStencilBuffer;
  16145. /**
  16146. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16147. * @hidden
  16148. */
  16149. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16150. /**
  16151. * Resets the different information of the group to prepare a new frame
  16152. * @hidden
  16153. */
  16154. reset(): void;
  16155. /**
  16156. * Dispose and release the group and its associated resources.
  16157. * @hidden
  16158. */
  16159. dispose(): void;
  16160. /**
  16161. * Clear the info related to rendering groups preventing retention points during dispose.
  16162. */
  16163. freeRenderingGroups(): void;
  16164. private _prepareRenderingGroup;
  16165. /**
  16166. * Add a sprite manager to the rendering manager in order to render it this frame.
  16167. * @param spriteManager Define the sprite manager to render
  16168. */
  16169. dispatchSprites(spriteManager: ISpriteManager): void;
  16170. /**
  16171. * Add a particle system to the rendering manager in order to render it this frame.
  16172. * @param particleSystem Define the particle system to render
  16173. */
  16174. dispatchParticles(particleSystem: IParticleSystem): void;
  16175. /**
  16176. * Add a submesh to the manager in order to render it this frame
  16177. * @param subMesh The submesh to dispatch
  16178. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16179. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16180. */
  16181. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16182. /**
  16183. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16184. * This allowed control for front to back rendering or reversly depending of the special needs.
  16185. *
  16186. * @param renderingGroupId The rendering group id corresponding to its index
  16187. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16188. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16189. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16190. */
  16191. 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;
  16192. /**
  16193. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16194. *
  16195. * @param renderingGroupId The rendering group id corresponding to its index
  16196. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16197. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16198. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16199. */
  16200. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16201. /**
  16202. * Gets the current auto clear configuration for one rendering group of the rendering
  16203. * manager.
  16204. * @param index the rendering group index to get the information for
  16205. * @returns The auto clear setup for the requested rendering group
  16206. */
  16207. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16208. }
  16209. }
  16210. declare module BABYLON {
  16211. /**
  16212. * This Helps creating a texture that will be created from a camera in your scene.
  16213. * It is basically a dynamic texture that could be used to create special effects for instance.
  16214. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  16215. */
  16216. export class RenderTargetTexture extends Texture {
  16217. isCube: boolean;
  16218. /**
  16219. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  16220. */
  16221. static readonly REFRESHRATE_RENDER_ONCE: number;
  16222. /**
  16223. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  16224. */
  16225. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  16226. /**
  16227. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  16228. * the central point of your effect and can save a lot of performances.
  16229. */
  16230. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  16231. /**
  16232. * Use this predicate to dynamically define the list of mesh you want to render.
  16233. * If set, the renderList property will be overwritten.
  16234. */
  16235. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  16236. private _renderList;
  16237. /**
  16238. * Use this list to define the list of mesh you want to render.
  16239. */
  16240. renderList: Nullable<Array<AbstractMesh>>;
  16241. private _hookArray;
  16242. /**
  16243. * Define if particles should be rendered in your texture.
  16244. */
  16245. renderParticles: boolean;
  16246. /**
  16247. * Define if sprites should be rendered in your texture.
  16248. */
  16249. renderSprites: boolean;
  16250. /**
  16251. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  16252. */
  16253. coordinatesMode: number;
  16254. /**
  16255. * Define the camera used to render the texture.
  16256. */
  16257. activeCamera: Nullable<Camera>;
  16258. /**
  16259. * Override the render function of the texture with your own one.
  16260. */
  16261. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  16262. /**
  16263. * Define if camera post processes should be use while rendering the texture.
  16264. */
  16265. useCameraPostProcesses: boolean;
  16266. /**
  16267. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  16268. */
  16269. ignoreCameraViewport: boolean;
  16270. private _postProcessManager;
  16271. private _postProcesses;
  16272. private _resizeObserver;
  16273. /**
  16274. * An event triggered when the texture is unbind.
  16275. */
  16276. onBeforeBindObservable: Observable<RenderTargetTexture>;
  16277. /**
  16278. * An event triggered when the texture is unbind.
  16279. */
  16280. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  16281. private _onAfterUnbindObserver;
  16282. /**
  16283. * Set a after unbind callback in the texture.
  16284. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  16285. */
  16286. onAfterUnbind: () => void;
  16287. /**
  16288. * An event triggered before rendering the texture
  16289. */
  16290. onBeforeRenderObservable: Observable<number>;
  16291. private _onBeforeRenderObserver;
  16292. /**
  16293. * Set a before render callback in the texture.
  16294. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  16295. */
  16296. onBeforeRender: (faceIndex: number) => void;
  16297. /**
  16298. * An event triggered after rendering the texture
  16299. */
  16300. onAfterRenderObservable: Observable<number>;
  16301. private _onAfterRenderObserver;
  16302. /**
  16303. * Set a after render callback in the texture.
  16304. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  16305. */
  16306. onAfterRender: (faceIndex: number) => void;
  16307. /**
  16308. * An event triggered after the texture clear
  16309. */
  16310. onClearObservable: Observable<Engine>;
  16311. private _onClearObserver;
  16312. /**
  16313. * Set a clear callback in the texture.
  16314. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  16315. */
  16316. onClear: (Engine: Engine) => void;
  16317. /**
  16318. * Define the clear color of the Render Target if it should be different from the scene.
  16319. */
  16320. clearColor: Color4;
  16321. protected _size: number | {
  16322. width: number;
  16323. height: number;
  16324. };
  16325. protected _initialSizeParameter: number | {
  16326. width: number;
  16327. height: number;
  16328. } | {
  16329. ratio: number;
  16330. };
  16331. protected _sizeRatio: Nullable<number>;
  16332. /** @hidden */
  16333. _generateMipMaps: boolean;
  16334. protected _renderingManager: RenderingManager;
  16335. /** @hidden */
  16336. _waitingRenderList: string[];
  16337. protected _doNotChangeAspectRatio: boolean;
  16338. protected _currentRefreshId: number;
  16339. protected _refreshRate: number;
  16340. protected _textureMatrix: Matrix;
  16341. protected _samples: number;
  16342. protected _renderTargetOptions: RenderTargetCreationOptions;
  16343. /**
  16344. * Gets render target creation options that were used.
  16345. */
  16346. readonly renderTargetOptions: RenderTargetCreationOptions;
  16347. protected _engine: Engine;
  16348. protected _onRatioRescale(): void;
  16349. /**
  16350. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  16351. * It must define where the camera used to render the texture is set
  16352. */
  16353. boundingBoxPosition: Vector3;
  16354. private _boundingBoxSize;
  16355. /**
  16356. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  16357. * When defined, the cubemap will switch to local mode
  16358. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  16359. * @example https://www.babylonjs-playground.com/#RNASML
  16360. */
  16361. boundingBoxSize: Vector3;
  16362. /**
  16363. * In case the RTT has been created with a depth texture, get the associated
  16364. * depth texture.
  16365. * Otherwise, return null.
  16366. */
  16367. depthStencilTexture: Nullable<InternalTexture>;
  16368. /**
  16369. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  16370. * or used a shadow, depth texture...
  16371. * @param name The friendly name of the texture
  16372. * @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)
  16373. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  16374. * @param generateMipMaps True if mip maps need to be generated after render.
  16375. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  16376. * @param type The type of the buffer in the RTT (int, half float, float...)
  16377. * @param isCube True if a cube texture needs to be created
  16378. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  16379. * @param generateDepthBuffer True to generate a depth buffer
  16380. * @param generateStencilBuffer True to generate a stencil buffer
  16381. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  16382. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  16383. * @param delayAllocation if the texture allocation should be delayed (default: false)
  16384. */
  16385. constructor(name: string, size: number | {
  16386. width: number;
  16387. height: number;
  16388. } | {
  16389. ratio: number;
  16390. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  16391. /**
  16392. * Creates a depth stencil texture.
  16393. * This is only available in WebGL 2 or with the depth texture extension available.
  16394. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  16395. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  16396. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  16397. */
  16398. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  16399. private _processSizeParameter;
  16400. /**
  16401. * Define the number of samples to use in case of MSAA.
  16402. * It defaults to one meaning no MSAA has been enabled.
  16403. */
  16404. samples: number;
  16405. /**
  16406. * Resets the refresh counter of the texture and start bak from scratch.
  16407. * Could be useful to regenerate the texture if it is setup to render only once.
  16408. */
  16409. resetRefreshCounter(): void;
  16410. /**
  16411. * Define the refresh rate of the texture or the rendering frequency.
  16412. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16413. */
  16414. refreshRate: number;
  16415. /**
  16416. * Adds a post process to the render target rendering passes.
  16417. * @param postProcess define the post process to add
  16418. */
  16419. addPostProcess(postProcess: PostProcess): void;
  16420. /**
  16421. * Clear all the post processes attached to the render target
  16422. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  16423. */
  16424. clearPostProcesses(dispose?: boolean): void;
  16425. /**
  16426. * Remove one of the post process from the list of attached post processes to the texture
  16427. * @param postProcess define the post process to remove from the list
  16428. */
  16429. removePostProcess(postProcess: PostProcess): void;
  16430. /** @hidden */
  16431. _shouldRender(): boolean;
  16432. /**
  16433. * Gets the actual render size of the texture.
  16434. * @returns the width of the render size
  16435. */
  16436. getRenderSize(): number;
  16437. /**
  16438. * Gets the actual render width of the texture.
  16439. * @returns the width of the render size
  16440. */
  16441. getRenderWidth(): number;
  16442. /**
  16443. * Gets the actual render height of the texture.
  16444. * @returns the height of the render size
  16445. */
  16446. getRenderHeight(): number;
  16447. /**
  16448. * Get if the texture can be rescaled or not.
  16449. */
  16450. readonly canRescale: boolean;
  16451. /**
  16452. * Resize the texture using a ratio.
  16453. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  16454. */
  16455. scale(ratio: number): void;
  16456. /**
  16457. * Get the texture reflection matrix used to rotate/transform the reflection.
  16458. * @returns the reflection matrix
  16459. */
  16460. getReflectionTextureMatrix(): Matrix;
  16461. /**
  16462. * Resize the texture to a new desired size.
  16463. * Be carrefull as it will recreate all the data in the new texture.
  16464. * @param size Define the new size. It can be:
  16465. * - a number for squared texture,
  16466. * - an object containing { width: number, height: number }
  16467. * - or an object containing a ratio { ratio: number }
  16468. */
  16469. resize(size: number | {
  16470. width: number;
  16471. height: number;
  16472. } | {
  16473. ratio: number;
  16474. }): void;
  16475. /**
  16476. * Renders all the objects from the render list into the texture.
  16477. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  16478. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  16479. */
  16480. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  16481. private _bestReflectionRenderTargetDimension;
  16482. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  16483. private renderToTarget;
  16484. /**
  16485. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16486. * This allowed control for front to back rendering or reversly depending of the special needs.
  16487. *
  16488. * @param renderingGroupId The rendering group id corresponding to its index
  16489. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16490. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16491. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16492. */
  16493. 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;
  16494. /**
  16495. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16496. *
  16497. * @param renderingGroupId The rendering group id corresponding to its index
  16498. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16499. */
  16500. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  16501. /**
  16502. * Clones the texture.
  16503. * @returns the cloned texture
  16504. */
  16505. clone(): RenderTargetTexture;
  16506. /**
  16507. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16508. * @returns The JSON representation of the texture
  16509. */
  16510. serialize(): any;
  16511. /**
  16512. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  16513. */
  16514. disposeFramebufferObjects(): void;
  16515. /**
  16516. * Dispose the texture and release its associated resources.
  16517. */
  16518. dispose(): void;
  16519. /** @hidden */
  16520. _rebuild(): void;
  16521. /**
  16522. * Clear the info related to rendering groups preventing retention point in material dispose.
  16523. */
  16524. freeRenderingGroups(): void;
  16525. }
  16526. }
  16527. declare module BABYLON {
  16528. /**
  16529. * Base class for the main features of a material in Babylon.js
  16530. */
  16531. export class Material implements IAnimatable {
  16532. /**
  16533. * Returns the triangle fill mode
  16534. */
  16535. static readonly TriangleFillMode: number;
  16536. /**
  16537. * Returns the wireframe mode
  16538. */
  16539. static readonly WireFrameFillMode: number;
  16540. /**
  16541. * Returns the point fill mode
  16542. */
  16543. static readonly PointFillMode: number;
  16544. /**
  16545. * Returns the point list draw mode
  16546. */
  16547. static readonly PointListDrawMode: number;
  16548. /**
  16549. * Returns the line list draw mode
  16550. */
  16551. static readonly LineListDrawMode: number;
  16552. /**
  16553. * Returns the line loop draw mode
  16554. */
  16555. static readonly LineLoopDrawMode: number;
  16556. /**
  16557. * Returns the line strip draw mode
  16558. */
  16559. static readonly LineStripDrawMode: number;
  16560. /**
  16561. * Returns the triangle strip draw mode
  16562. */
  16563. static readonly TriangleStripDrawMode: number;
  16564. /**
  16565. * Returns the triangle fan draw mode
  16566. */
  16567. static readonly TriangleFanDrawMode: number;
  16568. /**
  16569. * Stores the clock-wise side orientation
  16570. */
  16571. static readonly ClockWiseSideOrientation: number;
  16572. /**
  16573. * Stores the counter clock-wise side orientation
  16574. */
  16575. static readonly CounterClockWiseSideOrientation: number;
  16576. /**
  16577. * The dirty texture flag value
  16578. */
  16579. static readonly TextureDirtyFlag: number;
  16580. /**
  16581. * The dirty light flag value
  16582. */
  16583. static readonly LightDirtyFlag: number;
  16584. /**
  16585. * The dirty fresnel flag value
  16586. */
  16587. static readonly FresnelDirtyFlag: number;
  16588. /**
  16589. * The dirty attribute flag value
  16590. */
  16591. static readonly AttributesDirtyFlag: number;
  16592. /**
  16593. * The dirty misc flag value
  16594. */
  16595. static readonly MiscDirtyFlag: number;
  16596. /**
  16597. * The all dirty flag value
  16598. */
  16599. static readonly AllDirtyFlag: number;
  16600. /**
  16601. * The ID of the material
  16602. */
  16603. id: string;
  16604. /**
  16605. * Gets or sets the unique id of the material
  16606. */
  16607. uniqueId: number;
  16608. /**
  16609. * The name of the material
  16610. */
  16611. name: string;
  16612. /**
  16613. * Gets or sets user defined metadata
  16614. */
  16615. metadata: any;
  16616. /**
  16617. * For internal use only. Please do not use.
  16618. */
  16619. reservedDataStore: any;
  16620. /**
  16621. * Specifies if the ready state should be checked on each call
  16622. */
  16623. checkReadyOnEveryCall: boolean;
  16624. /**
  16625. * Specifies if the ready state should be checked once
  16626. */
  16627. checkReadyOnlyOnce: boolean;
  16628. /**
  16629. * The state of the material
  16630. */
  16631. state: string;
  16632. /**
  16633. * The alpha value of the material
  16634. */
  16635. protected _alpha: number;
  16636. /**
  16637. * Sets the alpha value of the material
  16638. */
  16639. /**
  16640. * Gets the alpha value of the material
  16641. */
  16642. alpha: number;
  16643. /**
  16644. * Specifies if back face culling is enabled
  16645. */
  16646. protected _backFaceCulling: boolean;
  16647. /**
  16648. * Sets the back-face culling state
  16649. */
  16650. /**
  16651. * Gets the back-face culling state
  16652. */
  16653. backFaceCulling: boolean;
  16654. /**
  16655. * Stores the value for side orientation
  16656. */
  16657. sideOrientation: number;
  16658. /**
  16659. * Callback triggered when the material is compiled
  16660. */
  16661. onCompiled: (effect: Effect) => void;
  16662. /**
  16663. * Callback triggered when an error occurs
  16664. */
  16665. onError: (effect: Effect, errors: string) => void;
  16666. /**
  16667. * Callback triggered to get the render target textures
  16668. */
  16669. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  16670. /**
  16671. * Gets a boolean indicating that current material needs to register RTT
  16672. */
  16673. readonly hasRenderTargetTextures: boolean;
  16674. /**
  16675. * Specifies if the material should be serialized
  16676. */
  16677. doNotSerialize: boolean;
  16678. /**
  16679. * @hidden
  16680. */
  16681. _storeEffectOnSubMeshes: boolean;
  16682. /**
  16683. * Stores the animations for the material
  16684. */
  16685. animations: Array<Animation>;
  16686. /**
  16687. * An event triggered when the material is disposed
  16688. */
  16689. onDisposeObservable: Observable<Material>;
  16690. /**
  16691. * An observer which watches for dispose events
  16692. */
  16693. private _onDisposeObserver;
  16694. private _onUnBindObservable;
  16695. /**
  16696. * Called during a dispose event
  16697. */
  16698. onDispose: () => void;
  16699. private _onBindObservable;
  16700. /**
  16701. * An event triggered when the material is bound
  16702. */
  16703. readonly onBindObservable: Observable<AbstractMesh>;
  16704. /**
  16705. * An observer which watches for bind events
  16706. */
  16707. private _onBindObserver;
  16708. /**
  16709. * Called during a bind event
  16710. */
  16711. onBind: (Mesh: AbstractMesh) => void;
  16712. /**
  16713. * An event triggered when the material is unbound
  16714. */
  16715. readonly onUnBindObservable: Observable<Material>;
  16716. /**
  16717. * Stores the value of the alpha mode
  16718. */
  16719. private _alphaMode;
  16720. /**
  16721. * Sets the value of the alpha mode.
  16722. *
  16723. * | Value | Type | Description |
  16724. * | --- | --- | --- |
  16725. * | 0 | ALPHA_DISABLE | |
  16726. * | 1 | ALPHA_ADD | |
  16727. * | 2 | ALPHA_COMBINE | |
  16728. * | 3 | ALPHA_SUBTRACT | |
  16729. * | 4 | ALPHA_MULTIPLY | |
  16730. * | 5 | ALPHA_MAXIMIZED | |
  16731. * | 6 | ALPHA_ONEONE | |
  16732. * | 7 | ALPHA_PREMULTIPLIED | |
  16733. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  16734. * | 9 | ALPHA_INTERPOLATE | |
  16735. * | 10 | ALPHA_SCREENMODE | |
  16736. *
  16737. */
  16738. /**
  16739. * Gets the value of the alpha mode
  16740. */
  16741. alphaMode: number;
  16742. /**
  16743. * Stores the state of the need depth pre-pass value
  16744. */
  16745. private _needDepthPrePass;
  16746. /**
  16747. * Sets the need depth pre-pass value
  16748. */
  16749. /**
  16750. * Gets the depth pre-pass value
  16751. */
  16752. needDepthPrePass: boolean;
  16753. /**
  16754. * Specifies if depth writing should be disabled
  16755. */
  16756. disableDepthWrite: boolean;
  16757. /**
  16758. * Specifies if depth writing should be forced
  16759. */
  16760. forceDepthWrite: boolean;
  16761. /**
  16762. * Specifies if there should be a separate pass for culling
  16763. */
  16764. separateCullingPass: boolean;
  16765. /**
  16766. * Stores the state specifing if fog should be enabled
  16767. */
  16768. private _fogEnabled;
  16769. /**
  16770. * Sets the state for enabling fog
  16771. */
  16772. /**
  16773. * Gets the value of the fog enabled state
  16774. */
  16775. fogEnabled: boolean;
  16776. /**
  16777. * Stores the size of points
  16778. */
  16779. pointSize: number;
  16780. /**
  16781. * Stores the z offset value
  16782. */
  16783. zOffset: number;
  16784. /**
  16785. * Gets a value specifying if wireframe mode is enabled
  16786. */
  16787. /**
  16788. * Sets the state of wireframe mode
  16789. */
  16790. wireframe: boolean;
  16791. /**
  16792. * Gets the value specifying if point clouds are enabled
  16793. */
  16794. /**
  16795. * Sets the state of point cloud mode
  16796. */
  16797. pointsCloud: boolean;
  16798. /**
  16799. * Gets the material fill mode
  16800. */
  16801. /**
  16802. * Sets the material fill mode
  16803. */
  16804. fillMode: number;
  16805. /**
  16806. * @hidden
  16807. * Stores the effects for the material
  16808. */
  16809. _effect: Nullable<Effect>;
  16810. /**
  16811. * @hidden
  16812. * Specifies if the material was previously ready
  16813. */
  16814. _wasPreviouslyReady: boolean;
  16815. /**
  16816. * Specifies if uniform buffers should be used
  16817. */
  16818. private _useUBO;
  16819. /**
  16820. * Stores a reference to the scene
  16821. */
  16822. private _scene;
  16823. /**
  16824. * Stores the fill mode state
  16825. */
  16826. private _fillMode;
  16827. /**
  16828. * Specifies if the depth write state should be cached
  16829. */
  16830. private _cachedDepthWriteState;
  16831. /**
  16832. * Stores the uniform buffer
  16833. */
  16834. protected _uniformBuffer: UniformBuffer;
  16835. /** @hidden */
  16836. _indexInSceneMaterialArray: number;
  16837. /** @hidden */
  16838. meshMap: Nullable<{
  16839. [id: string]: AbstractMesh | undefined;
  16840. }>;
  16841. /**
  16842. * Creates a material instance
  16843. * @param name defines the name of the material
  16844. * @param scene defines the scene to reference
  16845. * @param doNotAdd specifies if the material should be added to the scene
  16846. */
  16847. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  16848. /**
  16849. * Returns a string representation of the current material
  16850. * @param fullDetails defines a boolean indicating which levels of logging is desired
  16851. * @returns a string with material information
  16852. */
  16853. toString(fullDetails?: boolean): string;
  16854. /**
  16855. * Gets the class name of the material
  16856. * @returns a string with the class name of the material
  16857. */
  16858. getClassName(): string;
  16859. /**
  16860. * Specifies if updates for the material been locked
  16861. */
  16862. readonly isFrozen: boolean;
  16863. /**
  16864. * Locks updates for the material
  16865. */
  16866. freeze(): void;
  16867. /**
  16868. * Unlocks updates for the material
  16869. */
  16870. unfreeze(): void;
  16871. /**
  16872. * Specifies if the material is ready to be used
  16873. * @param mesh defines the mesh to check
  16874. * @param useInstances specifies if instances should be used
  16875. * @returns a boolean indicating if the material is ready to be used
  16876. */
  16877. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16878. /**
  16879. * Specifies that the submesh is ready to be used
  16880. * @param mesh defines the mesh to check
  16881. * @param subMesh defines which submesh to check
  16882. * @param useInstances specifies that instances should be used
  16883. * @returns a boolean indicating that the submesh is ready or not
  16884. */
  16885. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16886. /**
  16887. * Returns the material effect
  16888. * @returns the effect associated with the material
  16889. */
  16890. getEffect(): Nullable<Effect>;
  16891. /**
  16892. * Returns the current scene
  16893. * @returns a Scene
  16894. */
  16895. getScene(): Scene;
  16896. /**
  16897. * Specifies if the material will require alpha blending
  16898. * @returns a boolean specifying if alpha blending is needed
  16899. */
  16900. needAlphaBlending(): boolean;
  16901. /**
  16902. * Specifies if the mesh will require alpha blending
  16903. * @param mesh defines the mesh to check
  16904. * @returns a boolean specifying if alpha blending is needed for the mesh
  16905. */
  16906. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  16907. /**
  16908. * Specifies if this material should be rendered in alpha test mode
  16909. * @returns a boolean specifying if an alpha test is needed.
  16910. */
  16911. needAlphaTesting(): boolean;
  16912. /**
  16913. * Gets the texture used for the alpha test
  16914. * @returns the texture to use for alpha testing
  16915. */
  16916. getAlphaTestTexture(): Nullable<BaseTexture>;
  16917. /**
  16918. * Marks the material to indicate that it needs to be re-calculated
  16919. */
  16920. markDirty(): void;
  16921. /** @hidden */
  16922. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  16923. /**
  16924. * Binds the material to the mesh
  16925. * @param world defines the world transformation matrix
  16926. * @param mesh defines the mesh to bind the material to
  16927. */
  16928. bind(world: Matrix, mesh?: Mesh): void;
  16929. /**
  16930. * Binds the submesh to the material
  16931. * @param world defines the world transformation matrix
  16932. * @param mesh defines the mesh containing the submesh
  16933. * @param subMesh defines the submesh to bind the material to
  16934. */
  16935. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16936. /**
  16937. * Binds the world matrix to the material
  16938. * @param world defines the world transformation matrix
  16939. */
  16940. bindOnlyWorldMatrix(world: Matrix): void;
  16941. /**
  16942. * Binds the scene's uniform buffer to the effect.
  16943. * @param effect defines the effect to bind to the scene uniform buffer
  16944. * @param sceneUbo defines the uniform buffer storing scene data
  16945. */
  16946. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  16947. /**
  16948. * Binds the view matrix to the effect
  16949. * @param effect defines the effect to bind the view matrix to
  16950. */
  16951. bindView(effect: Effect): void;
  16952. /**
  16953. * Binds the view projection matrix to the effect
  16954. * @param effect defines the effect to bind the view projection matrix to
  16955. */
  16956. bindViewProjection(effect: Effect): void;
  16957. /**
  16958. * Specifies if material alpha testing should be turned on for the mesh
  16959. * @param mesh defines the mesh to check
  16960. */
  16961. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  16962. /**
  16963. * Processes to execute after binding the material to a mesh
  16964. * @param mesh defines the rendered mesh
  16965. */
  16966. protected _afterBind(mesh?: Mesh): void;
  16967. /**
  16968. * Unbinds the material from the mesh
  16969. */
  16970. unbind(): void;
  16971. /**
  16972. * Gets the active textures from the material
  16973. * @returns an array of textures
  16974. */
  16975. getActiveTextures(): BaseTexture[];
  16976. /**
  16977. * Specifies if the material uses a texture
  16978. * @param texture defines the texture to check against the material
  16979. * @returns a boolean specifying if the material uses the texture
  16980. */
  16981. hasTexture(texture: BaseTexture): boolean;
  16982. /**
  16983. * Makes a duplicate of the material, and gives it a new name
  16984. * @param name defines the new name for the duplicated material
  16985. * @returns the cloned material
  16986. */
  16987. clone(name: string): Nullable<Material>;
  16988. /**
  16989. * Gets the meshes bound to the material
  16990. * @returns an array of meshes bound to the material
  16991. */
  16992. getBindedMeshes(): AbstractMesh[];
  16993. /**
  16994. * Force shader compilation
  16995. * @param mesh defines the mesh associated with this material
  16996. * @param onCompiled defines a function to execute once the material is compiled
  16997. * @param options defines the options to configure the compilation
  16998. */
  16999. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  17000. clipPlane: boolean;
  17001. }>): void;
  17002. /**
  17003. * Force shader compilation
  17004. * @param mesh defines the mesh that will use this material
  17005. * @param options defines additional options for compiling the shaders
  17006. * @returns a promise that resolves when the compilation completes
  17007. */
  17008. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  17009. clipPlane: boolean;
  17010. }>): Promise<void>;
  17011. private static readonly _ImageProcessingDirtyCallBack;
  17012. private static readonly _TextureDirtyCallBack;
  17013. private static readonly _FresnelDirtyCallBack;
  17014. private static readonly _MiscDirtyCallBack;
  17015. private static readonly _LightsDirtyCallBack;
  17016. private static readonly _AttributeDirtyCallBack;
  17017. private static _FresnelAndMiscDirtyCallBack;
  17018. private static _TextureAndMiscDirtyCallBack;
  17019. private static readonly _DirtyCallbackArray;
  17020. private static readonly _RunDirtyCallBacks;
  17021. /**
  17022. * Marks a define in the material to indicate that it needs to be re-computed
  17023. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  17024. */
  17025. markAsDirty(flag: number): void;
  17026. /**
  17027. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  17028. * @param func defines a function which checks material defines against the submeshes
  17029. */
  17030. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  17031. /**
  17032. * Indicates that image processing needs to be re-calculated for all submeshes
  17033. */
  17034. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  17035. /**
  17036. * Indicates that textures need to be re-calculated for all submeshes
  17037. */
  17038. protected _markAllSubMeshesAsTexturesDirty(): void;
  17039. /**
  17040. * Indicates that fresnel needs to be re-calculated for all submeshes
  17041. */
  17042. protected _markAllSubMeshesAsFresnelDirty(): void;
  17043. /**
  17044. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  17045. */
  17046. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  17047. /**
  17048. * Indicates that lights need to be re-calculated for all submeshes
  17049. */
  17050. protected _markAllSubMeshesAsLightsDirty(): void;
  17051. /**
  17052. * Indicates that attributes need to be re-calculated for all submeshes
  17053. */
  17054. protected _markAllSubMeshesAsAttributesDirty(): void;
  17055. /**
  17056. * Indicates that misc needs to be re-calculated for all submeshes
  17057. */
  17058. protected _markAllSubMeshesAsMiscDirty(): void;
  17059. /**
  17060. * Indicates that textures and misc need to be re-calculated for all submeshes
  17061. */
  17062. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  17063. /**
  17064. * Disposes the material
  17065. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17066. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17067. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17068. */
  17069. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17070. /** @hidden */
  17071. private releaseVertexArrayObject;
  17072. /**
  17073. * Serializes this material
  17074. * @returns the serialized material object
  17075. */
  17076. serialize(): any;
  17077. /**
  17078. * Creates a material from parsed material data
  17079. * @param parsedMaterial defines parsed material data
  17080. * @param scene defines the hosting scene
  17081. * @param rootUrl defines the root URL to use to load textures
  17082. * @returns a new material
  17083. */
  17084. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  17085. }
  17086. }
  17087. declare module BABYLON {
  17088. /**
  17089. * Class used to represent data loading progression
  17090. */
  17091. export class SceneLoaderFlags {
  17092. private static _ForceFullSceneLoadingForIncremental;
  17093. private static _ShowLoadingScreen;
  17094. private static _CleanBoneMatrixWeights;
  17095. private static _loggingLevel;
  17096. /**
  17097. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  17098. */
  17099. static ForceFullSceneLoadingForIncremental: boolean;
  17100. /**
  17101. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  17102. */
  17103. static ShowLoadingScreen: boolean;
  17104. /**
  17105. * Defines the current logging level (while loading the scene)
  17106. * @ignorenaming
  17107. */
  17108. static loggingLevel: number;
  17109. /**
  17110. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  17111. */
  17112. static CleanBoneMatrixWeights: boolean;
  17113. }
  17114. }
  17115. declare module BABYLON {
  17116. /**
  17117. * Class used to override all child animations of a given target
  17118. */
  17119. export class AnimationPropertiesOverride {
  17120. /**
  17121. * Gets or sets a value indicating if animation blending must be used
  17122. */
  17123. enableBlending: boolean;
  17124. /**
  17125. * Gets or sets the blending speed to use when enableBlending is true
  17126. */
  17127. blendingSpeed: number;
  17128. /**
  17129. * Gets or sets the default loop mode to use
  17130. */
  17131. loopMode: number;
  17132. }
  17133. }
  17134. declare module BABYLON {
  17135. /**
  17136. * Defines a target to use with MorphTargetManager
  17137. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  17138. */
  17139. export class MorphTarget implements IAnimatable {
  17140. /** defines the name of the target */
  17141. name: string;
  17142. /**
  17143. * Gets or sets the list of animations
  17144. */
  17145. animations: Animation[];
  17146. private _scene;
  17147. private _positions;
  17148. private _normals;
  17149. private _tangents;
  17150. private _influence;
  17151. /**
  17152. * Observable raised when the influence changes
  17153. */
  17154. onInfluenceChanged: Observable<boolean>;
  17155. /** @hidden */
  17156. _onDataLayoutChanged: Observable<void>;
  17157. /**
  17158. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  17159. */
  17160. influence: number;
  17161. /**
  17162. * Gets or sets the id of the morph Target
  17163. */
  17164. id: string;
  17165. private _animationPropertiesOverride;
  17166. /**
  17167. * Gets or sets the animation properties override
  17168. */
  17169. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  17170. /**
  17171. * Creates a new MorphTarget
  17172. * @param name defines the name of the target
  17173. * @param influence defines the influence to use
  17174. * @param scene defines the scene the morphtarget belongs to
  17175. */
  17176. constructor(
  17177. /** defines the name of the target */
  17178. name: string, influence?: number, scene?: Nullable<Scene>);
  17179. /**
  17180. * Gets a boolean defining if the target contains position data
  17181. */
  17182. readonly hasPositions: boolean;
  17183. /**
  17184. * Gets a boolean defining if the target contains normal data
  17185. */
  17186. readonly hasNormals: boolean;
  17187. /**
  17188. * Gets a boolean defining if the target contains tangent data
  17189. */
  17190. readonly hasTangents: boolean;
  17191. /**
  17192. * Affects position data to this target
  17193. * @param data defines the position data to use
  17194. */
  17195. setPositions(data: Nullable<FloatArray>): void;
  17196. /**
  17197. * Gets the position data stored in this target
  17198. * @returns a FloatArray containing the position data (or null if not present)
  17199. */
  17200. getPositions(): Nullable<FloatArray>;
  17201. /**
  17202. * Affects normal data to this target
  17203. * @param data defines the normal data to use
  17204. */
  17205. setNormals(data: Nullable<FloatArray>): void;
  17206. /**
  17207. * Gets the normal data stored in this target
  17208. * @returns a FloatArray containing the normal data (or null if not present)
  17209. */
  17210. getNormals(): Nullable<FloatArray>;
  17211. /**
  17212. * Affects tangent data to this target
  17213. * @param data defines the tangent data to use
  17214. */
  17215. setTangents(data: Nullable<FloatArray>): void;
  17216. /**
  17217. * Gets the tangent data stored in this target
  17218. * @returns a FloatArray containing the tangent data (or null if not present)
  17219. */
  17220. getTangents(): Nullable<FloatArray>;
  17221. /**
  17222. * Serializes the current target into a Serialization object
  17223. * @returns the serialized object
  17224. */
  17225. serialize(): any;
  17226. /**
  17227. * Returns the string "MorphTarget"
  17228. * @returns "MorphTarget"
  17229. */
  17230. getClassName(): string;
  17231. /**
  17232. * Creates a new target from serialized data
  17233. * @param serializationObject defines the serialized data to use
  17234. * @returns a new MorphTarget
  17235. */
  17236. static Parse(serializationObject: any): MorphTarget;
  17237. /**
  17238. * Creates a MorphTarget from mesh data
  17239. * @param mesh defines the source mesh
  17240. * @param name defines the name to use for the new target
  17241. * @param influence defines the influence to attach to the target
  17242. * @returns a new MorphTarget
  17243. */
  17244. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  17245. }
  17246. }
  17247. declare module BABYLON {
  17248. /**
  17249. * This class is used to deform meshes using morphing between different targets
  17250. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  17251. */
  17252. export class MorphTargetManager {
  17253. private _targets;
  17254. private _targetInfluenceChangedObservers;
  17255. private _targetDataLayoutChangedObservers;
  17256. private _activeTargets;
  17257. private _scene;
  17258. private _influences;
  17259. private _supportsNormals;
  17260. private _supportsTangents;
  17261. private _vertexCount;
  17262. private _uniqueId;
  17263. private _tempInfluences;
  17264. /**
  17265. * Creates a new MorphTargetManager
  17266. * @param scene defines the current scene
  17267. */
  17268. constructor(scene?: Nullable<Scene>);
  17269. /**
  17270. * Gets the unique ID of this manager
  17271. */
  17272. readonly uniqueId: number;
  17273. /**
  17274. * Gets the number of vertices handled by this manager
  17275. */
  17276. readonly vertexCount: number;
  17277. /**
  17278. * Gets a boolean indicating if this manager supports morphing of normals
  17279. */
  17280. readonly supportsNormals: boolean;
  17281. /**
  17282. * Gets a boolean indicating if this manager supports morphing of tangents
  17283. */
  17284. readonly supportsTangents: boolean;
  17285. /**
  17286. * Gets the number of targets stored in this manager
  17287. */
  17288. readonly numTargets: number;
  17289. /**
  17290. * Gets the number of influencers (ie. the number of targets with influences > 0)
  17291. */
  17292. readonly numInfluencers: number;
  17293. /**
  17294. * Gets the list of influences (one per target)
  17295. */
  17296. readonly influences: Float32Array;
  17297. /**
  17298. * Gets the active target at specified index. An active target is a target with an influence > 0
  17299. * @param index defines the index to check
  17300. * @returns the requested target
  17301. */
  17302. getActiveTarget(index: number): MorphTarget;
  17303. /**
  17304. * Gets the target at specified index
  17305. * @param index defines the index to check
  17306. * @returns the requested target
  17307. */
  17308. getTarget(index: number): MorphTarget;
  17309. /**
  17310. * Add a new target to this manager
  17311. * @param target defines the target to add
  17312. */
  17313. addTarget(target: MorphTarget): void;
  17314. /**
  17315. * Removes a target from the manager
  17316. * @param target defines the target to remove
  17317. */
  17318. removeTarget(target: MorphTarget): void;
  17319. /**
  17320. * Serializes the current manager into a Serialization object
  17321. * @returns the serialized object
  17322. */
  17323. serialize(): any;
  17324. private _syncActiveTargets;
  17325. /**
  17326. * Syncrhonize the targets with all the meshes using this morph target manager
  17327. */
  17328. synchronize(): void;
  17329. /**
  17330. * Creates a new MorphTargetManager from serialized data
  17331. * @param serializationObject defines the serialized data
  17332. * @param scene defines the hosting scene
  17333. * @returns the new MorphTargetManager
  17334. */
  17335. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  17336. }
  17337. }
  17338. declare module BABYLON {
  17339. /**
  17340. * Interface for Physics-Joint data
  17341. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17342. */
  17343. export interface PhysicsJointData {
  17344. /**
  17345. * The main pivot of the joint
  17346. */
  17347. mainPivot?: Vector3;
  17348. /**
  17349. * The connected pivot of the joint
  17350. */
  17351. connectedPivot?: Vector3;
  17352. /**
  17353. * The main axis of the joint
  17354. */
  17355. mainAxis?: Vector3;
  17356. /**
  17357. * The connected axis of the joint
  17358. */
  17359. connectedAxis?: Vector3;
  17360. /**
  17361. * The collision of the joint
  17362. */
  17363. collision?: boolean;
  17364. /**
  17365. * Native Oimo/Cannon/Energy data
  17366. */
  17367. nativeParams?: any;
  17368. }
  17369. /**
  17370. * This is a holder class for the physics joint created by the physics plugin
  17371. * It holds a set of functions to control the underlying joint
  17372. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17373. */
  17374. export class PhysicsJoint {
  17375. /**
  17376. * The type of the physics joint
  17377. */
  17378. type: number;
  17379. /**
  17380. * The data for the physics joint
  17381. */
  17382. jointData: PhysicsJointData;
  17383. private _physicsJoint;
  17384. protected _physicsPlugin: IPhysicsEnginePlugin;
  17385. /**
  17386. * Initializes the physics joint
  17387. * @param type The type of the physics joint
  17388. * @param jointData The data for the physics joint
  17389. */
  17390. constructor(
  17391. /**
  17392. * The type of the physics joint
  17393. */
  17394. type: number,
  17395. /**
  17396. * The data for the physics joint
  17397. */
  17398. jointData: PhysicsJointData);
  17399. /**
  17400. * Gets the physics joint
  17401. */
  17402. /**
  17403. * Sets the physics joint
  17404. */
  17405. physicsJoint: any;
  17406. /**
  17407. * Sets the physics plugin
  17408. */
  17409. physicsPlugin: IPhysicsEnginePlugin;
  17410. /**
  17411. * Execute a function that is physics-plugin specific.
  17412. * @param {Function} func the function that will be executed.
  17413. * It accepts two parameters: the physics world and the physics joint
  17414. */
  17415. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  17416. /**
  17417. * Distance-Joint type
  17418. */
  17419. static DistanceJoint: number;
  17420. /**
  17421. * Hinge-Joint type
  17422. */
  17423. static HingeJoint: number;
  17424. /**
  17425. * Ball-and-Socket joint type
  17426. */
  17427. static BallAndSocketJoint: number;
  17428. /**
  17429. * Wheel-Joint type
  17430. */
  17431. static WheelJoint: number;
  17432. /**
  17433. * Slider-Joint type
  17434. */
  17435. static SliderJoint: number;
  17436. /**
  17437. * Prismatic-Joint type
  17438. */
  17439. static PrismaticJoint: number;
  17440. /**
  17441. * Universal-Joint type
  17442. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  17443. */
  17444. static UniversalJoint: number;
  17445. /**
  17446. * Hinge-Joint 2 type
  17447. */
  17448. static Hinge2Joint: number;
  17449. /**
  17450. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  17451. */
  17452. static PointToPointJoint: number;
  17453. /**
  17454. * Spring-Joint type
  17455. */
  17456. static SpringJoint: number;
  17457. /**
  17458. * Lock-Joint type
  17459. */
  17460. static LockJoint: number;
  17461. }
  17462. /**
  17463. * A class representing a physics distance joint
  17464. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17465. */
  17466. export class DistanceJoint extends PhysicsJoint {
  17467. /**
  17468. *
  17469. * @param jointData The data for the Distance-Joint
  17470. */
  17471. constructor(jointData: DistanceJointData);
  17472. /**
  17473. * Update the predefined distance.
  17474. * @param maxDistance The maximum preferred distance
  17475. * @param minDistance The minimum preferred distance
  17476. */
  17477. updateDistance(maxDistance: number, minDistance?: number): void;
  17478. }
  17479. /**
  17480. * Represents a Motor-Enabled Joint
  17481. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17482. */
  17483. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  17484. /**
  17485. * Initializes the Motor-Enabled Joint
  17486. * @param type The type of the joint
  17487. * @param jointData The physica joint data for the joint
  17488. */
  17489. constructor(type: number, jointData: PhysicsJointData);
  17490. /**
  17491. * Set the motor values.
  17492. * Attention, this function is plugin specific. Engines won't react 100% the same.
  17493. * @param force the force to apply
  17494. * @param maxForce max force for this motor.
  17495. */
  17496. setMotor(force?: number, maxForce?: number): void;
  17497. /**
  17498. * Set the motor's limits.
  17499. * Attention, this function is plugin specific. Engines won't react 100% the same.
  17500. * @param upperLimit The upper limit of the motor
  17501. * @param lowerLimit The lower limit of the motor
  17502. */
  17503. setLimit(upperLimit: number, lowerLimit?: number): void;
  17504. }
  17505. /**
  17506. * This class represents a single physics Hinge-Joint
  17507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17508. */
  17509. export class HingeJoint extends MotorEnabledJoint {
  17510. /**
  17511. * Initializes the Hinge-Joint
  17512. * @param jointData The joint data for the Hinge-Joint
  17513. */
  17514. constructor(jointData: PhysicsJointData);
  17515. /**
  17516. * Set the motor values.
  17517. * Attention, this function is plugin specific. Engines won't react 100% the same.
  17518. * @param {number} force the force to apply
  17519. * @param {number} maxForce max force for this motor.
  17520. */
  17521. setMotor(force?: number, maxForce?: number): void;
  17522. /**
  17523. * Set the motor's limits.
  17524. * Attention, this function is plugin specific. Engines won't react 100% the same.
  17525. * @param upperLimit The upper limit of the motor
  17526. * @param lowerLimit The lower limit of the motor
  17527. */
  17528. setLimit(upperLimit: number, lowerLimit?: number): void;
  17529. }
  17530. /**
  17531. * This class represents a dual hinge physics joint (same as wheel joint)
  17532. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17533. */
  17534. export class Hinge2Joint extends MotorEnabledJoint {
  17535. /**
  17536. * Initializes the Hinge2-Joint
  17537. * @param jointData The joint data for the Hinge2-Joint
  17538. */
  17539. constructor(jointData: PhysicsJointData);
  17540. /**
  17541. * Set the motor values.
  17542. * Attention, this function is plugin specific. Engines won't react 100% the same.
  17543. * @param {number} force the force to apply
  17544. * @param {number} maxForce max force for this motor.
  17545. * @param {motorIndex} the motor's index, 0 or 1.
  17546. */
  17547. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  17548. /**
  17549. * Set the motor limits.
  17550. * Attention, this function is plugin specific. Engines won't react 100% the same.
  17551. * @param {number} upperLimit the upper limit
  17552. * @param {number} lowerLimit lower limit
  17553. * @param {motorIndex} the motor's index, 0 or 1.
  17554. */
  17555. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  17556. }
  17557. /**
  17558. * Interface for a motor enabled joint
  17559. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17560. */
  17561. export interface IMotorEnabledJoint {
  17562. /**
  17563. * Physics joint
  17564. */
  17565. physicsJoint: any;
  17566. /**
  17567. * Sets the motor of the motor-enabled joint
  17568. * @param force The force of the motor
  17569. * @param maxForce The maximum force of the motor
  17570. * @param motorIndex The index of the motor
  17571. */
  17572. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  17573. /**
  17574. * Sets the limit of the motor
  17575. * @param upperLimit The upper limit of the motor
  17576. * @param lowerLimit The lower limit of the motor
  17577. * @param motorIndex The index of the motor
  17578. */
  17579. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  17580. }
  17581. /**
  17582. * Joint data for a Distance-Joint
  17583. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17584. */
  17585. export interface DistanceJointData extends PhysicsJointData {
  17586. /**
  17587. * Max distance the 2 joint objects can be apart
  17588. */
  17589. maxDistance: number;
  17590. }
  17591. /**
  17592. * Joint data from a spring joint
  17593. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17594. */
  17595. export interface SpringJointData extends PhysicsJointData {
  17596. /**
  17597. * Length of the spring
  17598. */
  17599. length: number;
  17600. /**
  17601. * Stiffness of the spring
  17602. */
  17603. stiffness: number;
  17604. /**
  17605. * Damping of the spring
  17606. */
  17607. damping: number;
  17608. /** this callback will be called when applying the force to the impostors. */
  17609. forceApplicationCallback: () => void;
  17610. }
  17611. }
  17612. declare module BABYLON {
  17613. /**
  17614. * Interface used to describe a physics joint
  17615. */
  17616. export interface PhysicsImpostorJoint {
  17617. /** Defines the main impostor to which the joint is linked */
  17618. mainImpostor: PhysicsImpostor;
  17619. /** Defines the impostor that is connected to the main impostor using this joint */
  17620. connectedImpostor: PhysicsImpostor;
  17621. /** Defines the joint itself */
  17622. joint: PhysicsJoint;
  17623. }
  17624. /** @hidden */
  17625. export interface IPhysicsEnginePlugin {
  17626. world: any;
  17627. name: string;
  17628. setGravity(gravity: Vector3): void;
  17629. setTimeStep(timeStep: number): void;
  17630. getTimeStep(): number;
  17631. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  17632. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  17633. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  17634. generatePhysicsBody(impostor: PhysicsImpostor): void;
  17635. removePhysicsBody(impostor: PhysicsImpostor): void;
  17636. generateJoint(joint: PhysicsImpostorJoint): void;
  17637. removeJoint(joint: PhysicsImpostorJoint): void;
  17638. isSupported(): boolean;
  17639. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  17640. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  17641. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  17642. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  17643. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  17644. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  17645. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  17646. getBodyMass(impostor: PhysicsImpostor): number;
  17647. getBodyFriction(impostor: PhysicsImpostor): number;
  17648. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  17649. getBodyRestitution(impostor: PhysicsImpostor): number;
  17650. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  17651. sleepBody(impostor: PhysicsImpostor): void;
  17652. wakeUpBody(impostor: PhysicsImpostor): void;
  17653. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  17654. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  17655. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  17656. getRadius(impostor: PhysicsImpostor): number;
  17657. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  17658. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  17659. dispose(): void;
  17660. }
  17661. /**
  17662. * Interface used to define a physics engine
  17663. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  17664. */
  17665. export interface IPhysicsEngine {
  17666. /**
  17667. * Gets the gravity vector used by the simulation
  17668. */
  17669. gravity: Vector3;
  17670. /**
  17671. * Sets the gravity vector used by the simulation
  17672. * @param gravity defines the gravity vector to use
  17673. */
  17674. setGravity(gravity: Vector3): void;
  17675. /**
  17676. * Set the time step of the physics engine.
  17677. * Default is 1/60.
  17678. * To slow it down, enter 1/600 for example.
  17679. * To speed it up, 1/30
  17680. * @param newTimeStep the new timestep to apply to this world.
  17681. */
  17682. setTimeStep(newTimeStep: number): void;
  17683. /**
  17684. * Get the time step of the physics engine.
  17685. * @returns the current time step
  17686. */
  17687. getTimeStep(): number;
  17688. /**
  17689. * Release all resources
  17690. */
  17691. dispose(): void;
  17692. /**
  17693. * Gets the name of the current physics plugin
  17694. * @returns the name of the plugin
  17695. */
  17696. getPhysicsPluginName(): string;
  17697. /**
  17698. * Adding a new impostor for the impostor tracking.
  17699. * This will be done by the impostor itself.
  17700. * @param impostor the impostor to add
  17701. */
  17702. addImpostor(impostor: PhysicsImpostor): void;
  17703. /**
  17704. * Remove an impostor from the engine.
  17705. * This impostor and its mesh will not longer be updated by the physics engine.
  17706. * @param impostor the impostor to remove
  17707. */
  17708. removeImpostor(impostor: PhysicsImpostor): void;
  17709. /**
  17710. * Add a joint to the physics engine
  17711. * @param mainImpostor defines the main impostor to which the joint is added.
  17712. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  17713. * @param joint defines the joint that will connect both impostors.
  17714. */
  17715. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  17716. /**
  17717. * Removes a joint from the simulation
  17718. * @param mainImpostor defines the impostor used with the joint
  17719. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  17720. * @param joint defines the joint to remove
  17721. */
  17722. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  17723. /**
  17724. * Gets the current plugin used to run the simulation
  17725. * @returns current plugin
  17726. */
  17727. getPhysicsPlugin(): IPhysicsEnginePlugin;
  17728. /**
  17729. * Gets the list of physic impostors
  17730. * @returns an array of PhysicsImpostor
  17731. */
  17732. getImpostors(): Array<PhysicsImpostor>;
  17733. /**
  17734. * Gets the impostor for a physics enabled object
  17735. * @param object defines the object impersonated by the impostor
  17736. * @returns the PhysicsImpostor or null if not found
  17737. */
  17738. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  17739. /**
  17740. * Gets the impostor for a physics body object
  17741. * @param body defines physics body used by the impostor
  17742. * @returns the PhysicsImpostor or null if not found
  17743. */
  17744. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  17745. /**
  17746. * Called by the scene. No need to call it.
  17747. * @param delta defines the timespam between frames
  17748. */
  17749. _step(delta: number): void;
  17750. }
  17751. }
  17752. declare module BABYLON {
  17753. /**
  17754. * The interface for the physics imposter parameters
  17755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17756. */
  17757. export interface PhysicsImpostorParameters {
  17758. /**
  17759. * The mass of the physics imposter
  17760. */
  17761. mass: number;
  17762. /**
  17763. * The friction of the physics imposter
  17764. */
  17765. friction?: number;
  17766. /**
  17767. * The coefficient of restitution of the physics imposter
  17768. */
  17769. restitution?: number;
  17770. /**
  17771. * The native options of the physics imposter
  17772. */
  17773. nativeOptions?: any;
  17774. /**
  17775. * Specifies if the parent should be ignored
  17776. */
  17777. ignoreParent?: boolean;
  17778. /**
  17779. * Specifies if bi-directional transformations should be disabled
  17780. */
  17781. disableBidirectionalTransformation?: boolean;
  17782. }
  17783. /**
  17784. * Interface for a physics-enabled object
  17785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17786. */
  17787. export interface IPhysicsEnabledObject {
  17788. /**
  17789. * The position of the physics-enabled object
  17790. */
  17791. position: Vector3;
  17792. /**
  17793. * The rotation of the physics-enabled object
  17794. */
  17795. rotationQuaternion: Nullable<Quaternion>;
  17796. /**
  17797. * The scale of the physics-enabled object
  17798. */
  17799. scaling: Vector3;
  17800. /**
  17801. * The rotation of the physics-enabled object
  17802. */
  17803. rotation?: Vector3;
  17804. /**
  17805. * The parent of the physics-enabled object
  17806. */
  17807. parent?: any;
  17808. /**
  17809. * The bounding info of the physics-enabled object
  17810. * @returns The bounding info of the physics-enabled object
  17811. */
  17812. getBoundingInfo(): BoundingInfo;
  17813. /**
  17814. * Computes the world matrix
  17815. * @param force Specifies if the world matrix should be computed by force
  17816. * @returns A world matrix
  17817. */
  17818. computeWorldMatrix(force: boolean): Matrix;
  17819. /**
  17820. * Gets the world matrix
  17821. * @returns A world matrix
  17822. */
  17823. getWorldMatrix?(): Matrix;
  17824. /**
  17825. * Gets the child meshes
  17826. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  17827. * @returns An array of abstract meshes
  17828. */
  17829. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  17830. /**
  17831. * Gets the vertex data
  17832. * @param kind The type of vertex data
  17833. * @returns A nullable array of numbers, or a float32 array
  17834. */
  17835. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  17836. /**
  17837. * Gets the indices from the mesh
  17838. * @returns A nullable array of index arrays
  17839. */
  17840. getIndices?(): Nullable<IndicesArray>;
  17841. /**
  17842. * Gets the scene from the mesh
  17843. * @returns the indices array or null
  17844. */
  17845. getScene?(): Scene;
  17846. /**
  17847. * Gets the absolute position from the mesh
  17848. * @returns the absolute position
  17849. */
  17850. getAbsolutePosition(): Vector3;
  17851. /**
  17852. * Gets the absolute pivot point from the mesh
  17853. * @returns the absolute pivot point
  17854. */
  17855. getAbsolutePivotPoint(): Vector3;
  17856. /**
  17857. * Rotates the mesh
  17858. * @param axis The axis of rotation
  17859. * @param amount The amount of rotation
  17860. * @param space The space of the rotation
  17861. * @returns The rotation transform node
  17862. */
  17863. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  17864. /**
  17865. * Translates the mesh
  17866. * @param axis The axis of translation
  17867. * @param distance The distance of translation
  17868. * @param space The space of the translation
  17869. * @returns The transform node
  17870. */
  17871. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  17872. /**
  17873. * Sets the absolute position of the mesh
  17874. * @param absolutePosition The absolute position of the mesh
  17875. * @returns The transform node
  17876. */
  17877. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  17878. /**
  17879. * Gets the class name of the mesh
  17880. * @returns The class name
  17881. */
  17882. getClassName(): string;
  17883. }
  17884. /**
  17885. * Represents a physics imposter
  17886. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17887. */
  17888. export class PhysicsImpostor {
  17889. /**
  17890. * The physics-enabled object used as the physics imposter
  17891. */
  17892. object: IPhysicsEnabledObject;
  17893. /**
  17894. * The type of the physics imposter
  17895. */
  17896. type: number;
  17897. private _options;
  17898. private _scene?;
  17899. /**
  17900. * The default object size of the imposter
  17901. */
  17902. static DEFAULT_OBJECT_SIZE: Vector3;
  17903. /**
  17904. * The identity quaternion of the imposter
  17905. */
  17906. static IDENTITY_QUATERNION: Quaternion;
  17907. /** @hidden */
  17908. _pluginData: any;
  17909. private _physicsEngine;
  17910. private _physicsBody;
  17911. private _bodyUpdateRequired;
  17912. private _onBeforePhysicsStepCallbacks;
  17913. private _onAfterPhysicsStepCallbacks;
  17914. /** @hidden */
  17915. _onPhysicsCollideCallbacks: Array<{
  17916. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  17917. otherImpostors: Array<PhysicsImpostor>;
  17918. }>;
  17919. private _deltaPosition;
  17920. private _deltaRotation;
  17921. private _deltaRotationConjugated;
  17922. private _parent;
  17923. private _isDisposed;
  17924. private static _tmpVecs;
  17925. private static _tmpQuat;
  17926. /**
  17927. * Specifies if the physics imposter is disposed
  17928. */
  17929. readonly isDisposed: boolean;
  17930. /**
  17931. * Gets the mass of the physics imposter
  17932. */
  17933. mass: number;
  17934. /**
  17935. * Gets the coefficient of friction
  17936. */
  17937. /**
  17938. * Sets the coefficient of friction
  17939. */
  17940. friction: number;
  17941. /**
  17942. * Gets the coefficient of restitution
  17943. */
  17944. /**
  17945. * Sets the coefficient of restitution
  17946. */
  17947. restitution: number;
  17948. /**
  17949. * The unique id of the physics imposter
  17950. * set by the physics engine when adding this impostor to the array
  17951. */
  17952. uniqueId: number;
  17953. private _joints;
  17954. /**
  17955. * Initializes the physics imposter
  17956. * @param object The physics-enabled object used as the physics imposter
  17957. * @param type The type of the physics imposter
  17958. * @param _options The options for the physics imposter
  17959. * @param _scene The Babylon scene
  17960. */
  17961. constructor(
  17962. /**
  17963. * The physics-enabled object used as the physics imposter
  17964. */
  17965. object: IPhysicsEnabledObject,
  17966. /**
  17967. * The type of the physics imposter
  17968. */
  17969. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  17970. /**
  17971. * This function will completly initialize this impostor.
  17972. * It will create a new body - but only if this mesh has no parent.
  17973. * If it has, this impostor will not be used other than to define the impostor
  17974. * of the child mesh.
  17975. * @hidden
  17976. */
  17977. _init(): void;
  17978. private _getPhysicsParent;
  17979. /**
  17980. * Should a new body be generated.
  17981. * @returns boolean specifying if body initialization is required
  17982. */
  17983. isBodyInitRequired(): boolean;
  17984. /**
  17985. * Sets the updated scaling
  17986. * @param updated Specifies if the scaling is updated
  17987. */
  17988. setScalingUpdated(): void;
  17989. /**
  17990. * Force a regeneration of this or the parent's impostor's body.
  17991. * Use under cautious - This will remove all joints already implemented.
  17992. */
  17993. forceUpdate(): void;
  17994. /**
  17995. * Gets the body that holds this impostor. Either its own, or its parent.
  17996. */
  17997. /**
  17998. * Set the physics body. Used mainly by the physics engine/plugin
  17999. */
  18000. physicsBody: any;
  18001. /**
  18002. * Get the parent of the physics imposter
  18003. * @returns Physics imposter or null
  18004. */
  18005. /**
  18006. * Sets the parent of the physics imposter
  18007. */
  18008. parent: Nullable<PhysicsImpostor>;
  18009. /**
  18010. * Resets the update flags
  18011. */
  18012. resetUpdateFlags(): void;
  18013. /**
  18014. * Gets the object extend size
  18015. * @returns the object extend size
  18016. */
  18017. getObjectExtendSize(): Vector3;
  18018. /**
  18019. * Gets the object center
  18020. * @returns The object center
  18021. */
  18022. getObjectCenter(): Vector3;
  18023. /**
  18024. * Get a specific parametes from the options parameter
  18025. * @param paramName The object parameter name
  18026. * @returns The object parameter
  18027. */
  18028. getParam(paramName: string): any;
  18029. /**
  18030. * Sets a specific parameter in the options given to the physics plugin
  18031. * @param paramName The parameter name
  18032. * @param value The value of the parameter
  18033. */
  18034. setParam(paramName: string, value: number): void;
  18035. /**
  18036. * Specifically change the body's mass option. Won't recreate the physics body object
  18037. * @param mass The mass of the physics imposter
  18038. */
  18039. setMass(mass: number): void;
  18040. /**
  18041. * Gets the linear velocity
  18042. * @returns linear velocity or null
  18043. */
  18044. getLinearVelocity(): Nullable<Vector3>;
  18045. /**
  18046. * Sets the linear velocity
  18047. * @param velocity linear velocity or null
  18048. */
  18049. setLinearVelocity(velocity: Nullable<Vector3>): void;
  18050. /**
  18051. * Gets the angular velocity
  18052. * @returns angular velocity or null
  18053. */
  18054. getAngularVelocity(): Nullable<Vector3>;
  18055. /**
  18056. * Sets the angular velocity
  18057. * @param velocity The velocity or null
  18058. */
  18059. setAngularVelocity(velocity: Nullable<Vector3>): void;
  18060. /**
  18061. * Execute a function with the physics plugin native code
  18062. * Provide a function the will have two variables - the world object and the physics body object
  18063. * @param func The function to execute with the physics plugin native code
  18064. */
  18065. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  18066. /**
  18067. * Register a function that will be executed before the physics world is stepping forward
  18068. * @param func The function to execute before the physics world is stepped forward
  18069. */
  18070. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18071. /**
  18072. * Unregister a function that will be executed before the physics world is stepping forward
  18073. * @param func The function to execute before the physics world is stepped forward
  18074. */
  18075. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18076. /**
  18077. * Register a function that will be executed after the physics step
  18078. * @param func The function to execute after physics step
  18079. */
  18080. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18081. /**
  18082. * Unregisters a function that will be executed after the physics step
  18083. * @param func The function to execute after physics step
  18084. */
  18085. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18086. /**
  18087. * register a function that will be executed when this impostor collides against a different body
  18088. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  18089. * @param func Callback that is executed on collision
  18090. */
  18091. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  18092. /**
  18093. * Unregisters the physics imposter on contact
  18094. * @param collideAgainst The physics object to collide against
  18095. * @param func Callback to execute on collision
  18096. */
  18097. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  18098. private _tmpQuat;
  18099. private _tmpQuat2;
  18100. /**
  18101. * Get the parent rotation
  18102. * @returns The parent rotation
  18103. */
  18104. getParentsRotation(): Quaternion;
  18105. /**
  18106. * this function is executed by the physics engine.
  18107. */
  18108. beforeStep: () => void;
  18109. /**
  18110. * this function is executed by the physics engine
  18111. */
  18112. afterStep: () => void;
  18113. /**
  18114. * Legacy collision detection event support
  18115. */
  18116. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  18117. /**
  18118. * event and body object due to cannon's event-based architecture.
  18119. */
  18120. onCollide: (e: {
  18121. body: any;
  18122. }) => void;
  18123. /**
  18124. * Apply a force
  18125. * @param force The force to apply
  18126. * @param contactPoint The contact point for the force
  18127. * @returns The physics imposter
  18128. */
  18129. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  18130. /**
  18131. * Apply an impulse
  18132. * @param force The impulse force
  18133. * @param contactPoint The contact point for the impulse force
  18134. * @returns The physics imposter
  18135. */
  18136. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  18137. /**
  18138. * A help function to create a joint
  18139. * @param otherImpostor A physics imposter used to create a joint
  18140. * @param jointType The type of joint
  18141. * @param jointData The data for the joint
  18142. * @returns The physics imposter
  18143. */
  18144. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  18145. /**
  18146. * Add a joint to this impostor with a different impostor
  18147. * @param otherImpostor A physics imposter used to add a joint
  18148. * @param joint The joint to add
  18149. * @returns The physics imposter
  18150. */
  18151. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  18152. /**
  18153. * Will keep this body still, in a sleep mode.
  18154. * @returns the physics imposter
  18155. */
  18156. sleep(): PhysicsImpostor;
  18157. /**
  18158. * Wake the body up.
  18159. * @returns The physics imposter
  18160. */
  18161. wakeUp(): PhysicsImpostor;
  18162. /**
  18163. * Clones the physics imposter
  18164. * @param newObject The physics imposter clones to this physics-enabled object
  18165. * @returns A nullable physics imposter
  18166. */
  18167. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18168. /**
  18169. * Disposes the physics imposter
  18170. */
  18171. dispose(): void;
  18172. /**
  18173. * Sets the delta position
  18174. * @param position The delta position amount
  18175. */
  18176. setDeltaPosition(position: Vector3): void;
  18177. /**
  18178. * Sets the delta rotation
  18179. * @param rotation The delta rotation amount
  18180. */
  18181. setDeltaRotation(rotation: Quaternion): void;
  18182. /**
  18183. * Gets the box size of the physics imposter and stores the result in the input parameter
  18184. * @param result Stores the box size
  18185. * @returns The physics imposter
  18186. */
  18187. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  18188. /**
  18189. * Gets the radius of the physics imposter
  18190. * @returns Radius of the physics imposter
  18191. */
  18192. getRadius(): number;
  18193. /**
  18194. * Sync a bone with this impostor
  18195. * @param bone The bone to sync to the impostor.
  18196. * @param boneMesh The mesh that the bone is influencing.
  18197. * @param jointPivot The pivot of the joint / bone in local space.
  18198. * @param distToJoint Optional distance from the impostor to the joint.
  18199. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  18200. */
  18201. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  18202. /**
  18203. * Sync impostor to a bone
  18204. * @param bone The bone that the impostor will be synced to.
  18205. * @param boneMesh The mesh that the bone is influencing.
  18206. * @param jointPivot The pivot of the joint / bone in local space.
  18207. * @param distToJoint Optional distance from the impostor to the joint.
  18208. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  18209. * @param boneAxis Optional vector3 axis the bone is aligned with
  18210. */
  18211. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  18212. /**
  18213. * No-Imposter type
  18214. */
  18215. static NoImpostor: number;
  18216. /**
  18217. * Sphere-Imposter type
  18218. */
  18219. static SphereImpostor: number;
  18220. /**
  18221. * Box-Imposter type
  18222. */
  18223. static BoxImpostor: number;
  18224. /**
  18225. * Plane-Imposter type
  18226. */
  18227. static PlaneImpostor: number;
  18228. /**
  18229. * Mesh-imposter type
  18230. */
  18231. static MeshImpostor: number;
  18232. /**
  18233. * Cylinder-Imposter type
  18234. */
  18235. static CylinderImpostor: number;
  18236. /**
  18237. * Particle-Imposter type
  18238. */
  18239. static ParticleImpostor: number;
  18240. /**
  18241. * Heightmap-Imposter type
  18242. */
  18243. static HeightmapImpostor: number;
  18244. }
  18245. }
  18246. declare module BABYLON {
  18247. /**
  18248. * Mesh representing the gorund
  18249. */
  18250. export class GroundMesh extends Mesh {
  18251. /** If octree should be generated */
  18252. generateOctree: boolean;
  18253. private _heightQuads;
  18254. /** @hidden */
  18255. _subdivisionsX: number;
  18256. /** @hidden */
  18257. _subdivisionsY: number;
  18258. /** @hidden */
  18259. _width: number;
  18260. /** @hidden */
  18261. _height: number;
  18262. /** @hidden */
  18263. _minX: number;
  18264. /** @hidden */
  18265. _maxX: number;
  18266. /** @hidden */
  18267. _minZ: number;
  18268. /** @hidden */
  18269. _maxZ: number;
  18270. constructor(name: string, scene: Scene);
  18271. /**
  18272. * "GroundMesh"
  18273. * @returns "GroundMesh"
  18274. */
  18275. getClassName(): string;
  18276. /**
  18277. * The minimum of x and y subdivisions
  18278. */
  18279. readonly subdivisions: number;
  18280. /**
  18281. * X subdivisions
  18282. */
  18283. readonly subdivisionsX: number;
  18284. /**
  18285. * Y subdivisions
  18286. */
  18287. readonly subdivisionsY: number;
  18288. /**
  18289. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  18290. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  18291. * @param chunksCount the number of subdivisions for x and y
  18292. * @param octreeBlocksSize (Default: 32)
  18293. */
  18294. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  18295. /**
  18296. * Returns a height (y) value in the Worl system :
  18297. * the ground altitude at the coordinates (x, z) expressed in the World system.
  18298. * @param x x coordinate
  18299. * @param z z coordinate
  18300. * @returns the ground y position if (x, z) are outside the ground surface.
  18301. */
  18302. getHeightAtCoordinates(x: number, z: number): number;
  18303. /**
  18304. * Returns a normalized vector (Vector3) orthogonal to the ground
  18305. * at the ground coordinates (x, z) expressed in the World system.
  18306. * @param x x coordinate
  18307. * @param z z coordinate
  18308. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  18309. */
  18310. getNormalAtCoordinates(x: number, z: number): Vector3;
  18311. /**
  18312. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  18313. * at the ground coordinates (x, z) expressed in the World system.
  18314. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  18315. * @param x x coordinate
  18316. * @param z z coordinate
  18317. * @param ref vector to store the result
  18318. * @returns the GroundMesh.
  18319. */
  18320. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  18321. /**
  18322. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  18323. * if the ground has been updated.
  18324. * This can be used in the render loop.
  18325. * @returns the GroundMesh.
  18326. */
  18327. updateCoordinateHeights(): GroundMesh;
  18328. private _getFacetAt;
  18329. private _initHeightQuads;
  18330. private _computeHeightQuads;
  18331. /**
  18332. * Serializes this ground mesh
  18333. * @param serializationObject object to write serialization to
  18334. */
  18335. serialize(serializationObject: any): void;
  18336. /**
  18337. * Parses a serialized ground mesh
  18338. * @param parsedMesh the serialized mesh
  18339. * @param scene the scene to create the ground mesh in
  18340. * @returns the created ground mesh
  18341. */
  18342. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  18343. }
  18344. }
  18345. declare module BABYLON {
  18346. /**
  18347. * Class used to represent a specific level of detail of a mesh
  18348. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  18349. */
  18350. export class MeshLODLevel {
  18351. /** Defines the distance where this level should star being displayed */
  18352. distance: number;
  18353. /** Defines the mesh to use to render this level */
  18354. mesh: Nullable<Mesh>;
  18355. /**
  18356. * Creates a new LOD level
  18357. * @param distance defines the distance where this level should star being displayed
  18358. * @param mesh defines the mesh to use to render this level
  18359. */
  18360. constructor(
  18361. /** Defines the distance where this level should star being displayed */
  18362. distance: number,
  18363. /** Defines the mesh to use to render this level */
  18364. mesh: Nullable<Mesh>);
  18365. }
  18366. /**
  18367. * @hidden
  18368. **/
  18369. export class _CreationDataStorage {
  18370. closePath?: boolean;
  18371. closeArray?: boolean;
  18372. idx: number[];
  18373. dashSize: number;
  18374. gapSize: number;
  18375. path3D: Path3D;
  18376. pathArray: Vector3[][];
  18377. arc: number;
  18378. radius: number;
  18379. cap: number;
  18380. tessellation: number;
  18381. }
  18382. /**
  18383. * @hidden
  18384. **/
  18385. class _InstanceDataStorage {
  18386. visibleInstances: any;
  18387. renderIdForInstances: number[];
  18388. batchCache: _InstancesBatch;
  18389. instancesBufferSize: number;
  18390. instancesBuffer: Nullable<Buffer>;
  18391. instancesData: Float32Array;
  18392. overridenInstanceCount: number;
  18393. }
  18394. /**
  18395. * @hidden
  18396. **/
  18397. export class _InstancesBatch {
  18398. mustReturn: boolean;
  18399. visibleInstances: Nullable<InstancedMesh[]>[];
  18400. renderSelf: boolean[];
  18401. }
  18402. /**
  18403. * Class used to represent renderable models
  18404. */
  18405. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  18406. /**
  18407. * Mesh side orientation : usually the external or front surface
  18408. */
  18409. static readonly FRONTSIDE: number;
  18410. /**
  18411. * Mesh side orientation : usually the internal or back surface
  18412. */
  18413. static readonly BACKSIDE: number;
  18414. /**
  18415. * Mesh side orientation : both internal and external or front and back surfaces
  18416. */
  18417. static readonly DOUBLESIDE: number;
  18418. /**
  18419. * Mesh side orientation : by default, `FRONTSIDE`
  18420. */
  18421. static readonly DEFAULTSIDE: number;
  18422. /**
  18423. * Mesh cap setting : no cap
  18424. */
  18425. static readonly NO_CAP: number;
  18426. /**
  18427. * Mesh cap setting : one cap at the beginning of the mesh
  18428. */
  18429. static readonly CAP_START: number;
  18430. /**
  18431. * Mesh cap setting : one cap at the end of the mesh
  18432. */
  18433. static readonly CAP_END: number;
  18434. /**
  18435. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  18436. */
  18437. static readonly CAP_ALL: number;
  18438. /**
  18439. * Gets the default side orientation.
  18440. * @param orientation the orientation to value to attempt to get
  18441. * @returns the default orientation
  18442. * @hidden
  18443. */
  18444. static _GetDefaultSideOrientation(orientation?: number): number;
  18445. private _onBeforeRenderObservable;
  18446. private _onBeforeBindObservable;
  18447. private _onAfterRenderObservable;
  18448. private _onBeforeDrawObservable;
  18449. /**
  18450. * An event triggered before rendering the mesh
  18451. */
  18452. readonly onBeforeRenderObservable: Observable<Mesh>;
  18453. /**
  18454. * An event triggered before binding the mesh
  18455. */
  18456. readonly onBeforeBindObservable: Observable<Mesh>;
  18457. /**
  18458. * An event triggered after rendering the mesh
  18459. */
  18460. readonly onAfterRenderObservable: Observable<Mesh>;
  18461. /**
  18462. * An event triggered before drawing the mesh
  18463. */
  18464. readonly onBeforeDrawObservable: Observable<Mesh>;
  18465. private _onBeforeDrawObserver;
  18466. /**
  18467. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  18468. */
  18469. onBeforeDraw: () => void;
  18470. /**
  18471. * Gets the delay loading state of the mesh (when delay loading is turned on)
  18472. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  18473. */
  18474. delayLoadState: number;
  18475. /**
  18476. * Gets the list of instances created from this mesh
  18477. * it is not supposed to be modified manually.
  18478. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  18479. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  18480. */
  18481. instances: InstancedMesh[];
  18482. /**
  18483. * Gets the file containing delay loading data for this mesh
  18484. */
  18485. delayLoadingFile: string;
  18486. /** @hidden */
  18487. _binaryInfo: any;
  18488. private _LODLevels;
  18489. /**
  18490. * User defined function used to change how LOD level selection is done
  18491. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  18492. */
  18493. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  18494. private _morphTargetManager;
  18495. /**
  18496. * Gets or sets the morph target manager
  18497. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18498. */
  18499. morphTargetManager: Nullable<MorphTargetManager>;
  18500. /** @hidden */
  18501. _creationDataStorage: Nullable<_CreationDataStorage>;
  18502. /** @hidden */
  18503. _geometry: Nullable<Geometry>;
  18504. /** @hidden */
  18505. _delayInfo: Array<string>;
  18506. /** @hidden */
  18507. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  18508. /** @hidden */
  18509. _instanceDataStorage: _InstanceDataStorage;
  18510. private _effectiveMaterial;
  18511. /** @hidden */
  18512. _shouldGenerateFlatShading: boolean;
  18513. private _preActivateId;
  18514. /** @hidden */
  18515. _originalBuilderSideOrientation: number;
  18516. /**
  18517. * Use this property to change the original side orientation defined at construction time
  18518. */
  18519. overrideMaterialSideOrientation: Nullable<number>;
  18520. private _areNormalsFrozen;
  18521. private _sourcePositions;
  18522. private _sourceNormals;
  18523. private _source;
  18524. private meshMap;
  18525. /**
  18526. * Gets the source mesh (the one used to clone this one from)
  18527. */
  18528. readonly source: Nullable<Mesh>;
  18529. /**
  18530. * Gets or sets a boolean indicating that this mesh does not use index buffer
  18531. */
  18532. isUnIndexed: boolean;
  18533. /**
  18534. * @constructor
  18535. * @param name The value used by scene.getMeshByName() to do a lookup.
  18536. * @param scene The scene to add this mesh to.
  18537. * @param parent The parent of this mesh, if it has one
  18538. * @param source An optional Mesh from which geometry is shared, cloned.
  18539. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  18540. * When false, achieved by calling a clone(), also passing False.
  18541. * This will make creation of children, recursive.
  18542. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  18543. */
  18544. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  18545. /**
  18546. * Gets the class name
  18547. * @returns the string "Mesh".
  18548. */
  18549. getClassName(): string;
  18550. /** @hidden */
  18551. readonly _isMesh: boolean;
  18552. /**
  18553. * Returns a description of this mesh
  18554. * @param fullDetails define if full details about this mesh must be used
  18555. * @returns a descriptive string representing this mesh
  18556. */
  18557. toString(fullDetails?: boolean): string;
  18558. /** @hidden */
  18559. _unBindEffect(): void;
  18560. /**
  18561. * Gets a boolean indicating if this mesh has LOD
  18562. */
  18563. readonly hasLODLevels: boolean;
  18564. /**
  18565. * Gets the list of MeshLODLevel associated with the current mesh
  18566. * @returns an array of MeshLODLevel
  18567. */
  18568. getLODLevels(): MeshLODLevel[];
  18569. private _sortLODLevels;
  18570. /**
  18571. * Add a mesh as LOD level triggered at the given distance.
  18572. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  18573. * @param distance The distance from the center of the object to show this level
  18574. * @param mesh The mesh to be added as LOD level (can be null)
  18575. * @return This mesh (for chaining)
  18576. */
  18577. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  18578. /**
  18579. * Returns the LOD level mesh at the passed distance or null if not found.
  18580. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  18581. * @param distance The distance from the center of the object to show this level
  18582. * @returns a Mesh or `null`
  18583. */
  18584. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  18585. /**
  18586. * Remove a mesh from the LOD array
  18587. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  18588. * @param mesh defines the mesh to be removed
  18589. * @return This mesh (for chaining)
  18590. */
  18591. removeLODLevel(mesh: Mesh): Mesh;
  18592. /**
  18593. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  18594. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  18595. * @param camera defines the camera to use to compute distance
  18596. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  18597. * @return This mesh (for chaining)
  18598. */
  18599. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  18600. /**
  18601. * Gets the mesh internal Geometry object
  18602. */
  18603. readonly geometry: Nullable<Geometry>;
  18604. /**
  18605. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  18606. * @returns the total number of vertices
  18607. */
  18608. getTotalVertices(): number;
  18609. /**
  18610. * Returns the content of an associated vertex buffer
  18611. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  18612. * - VertexBuffer.PositionKind
  18613. * - VertexBuffer.UVKind
  18614. * - VertexBuffer.UV2Kind
  18615. * - VertexBuffer.UV3Kind
  18616. * - VertexBuffer.UV4Kind
  18617. * - VertexBuffer.UV5Kind
  18618. * - VertexBuffer.UV6Kind
  18619. * - VertexBuffer.ColorKind
  18620. * - VertexBuffer.MatricesIndicesKind
  18621. * - VertexBuffer.MatricesIndicesExtraKind
  18622. * - VertexBuffer.MatricesWeightsKind
  18623. * - VertexBuffer.MatricesWeightsExtraKind
  18624. * @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
  18625. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  18626. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  18627. */
  18628. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  18629. /**
  18630. * Returns the mesh VertexBuffer object from the requested `kind`
  18631. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  18632. * - VertexBuffer.PositionKind
  18633. * - VertexBuffer.UVKind
  18634. * - VertexBuffer.UV2Kind
  18635. * - VertexBuffer.UV3Kind
  18636. * - VertexBuffer.UV4Kind
  18637. * - VertexBuffer.UV5Kind
  18638. * - VertexBuffer.UV6Kind
  18639. * - VertexBuffer.ColorKind
  18640. * - VertexBuffer.MatricesIndicesKind
  18641. * - VertexBuffer.MatricesIndicesExtraKind
  18642. * - VertexBuffer.MatricesWeightsKind
  18643. * - VertexBuffer.MatricesWeightsExtraKind
  18644. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  18645. */
  18646. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  18647. /**
  18648. * Tests if a specific vertex buffer is associated with this mesh
  18649. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  18650. * - VertexBuffer.PositionKind
  18651. * - VertexBuffer.UVKind
  18652. * - VertexBuffer.UV2Kind
  18653. * - VertexBuffer.UV3Kind
  18654. * - VertexBuffer.UV4Kind
  18655. * - VertexBuffer.UV5Kind
  18656. * - VertexBuffer.UV6Kind
  18657. * - VertexBuffer.ColorKind
  18658. * - VertexBuffer.MatricesIndicesKind
  18659. * - VertexBuffer.MatricesIndicesExtraKind
  18660. * - VertexBuffer.MatricesWeightsKind
  18661. * - VertexBuffer.MatricesWeightsExtraKind
  18662. * @returns a boolean
  18663. */
  18664. isVerticesDataPresent(kind: string): boolean;
  18665. /**
  18666. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  18667. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  18668. * - VertexBuffer.PositionKind
  18669. * - VertexBuffer.UVKind
  18670. * - VertexBuffer.UV2Kind
  18671. * - VertexBuffer.UV3Kind
  18672. * - VertexBuffer.UV4Kind
  18673. * - VertexBuffer.UV5Kind
  18674. * - VertexBuffer.UV6Kind
  18675. * - VertexBuffer.ColorKind
  18676. * - VertexBuffer.MatricesIndicesKind
  18677. * - VertexBuffer.MatricesIndicesExtraKind
  18678. * - VertexBuffer.MatricesWeightsKind
  18679. * - VertexBuffer.MatricesWeightsExtraKind
  18680. * @returns a boolean
  18681. */
  18682. isVertexBufferUpdatable(kind: string): boolean;
  18683. /**
  18684. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  18685. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  18686. * - VertexBuffer.PositionKind
  18687. * - VertexBuffer.UVKind
  18688. * - VertexBuffer.UV2Kind
  18689. * - VertexBuffer.UV3Kind
  18690. * - VertexBuffer.UV4Kind
  18691. * - VertexBuffer.UV5Kind
  18692. * - VertexBuffer.UV6Kind
  18693. * - VertexBuffer.ColorKind
  18694. * - VertexBuffer.MatricesIndicesKind
  18695. * - VertexBuffer.MatricesIndicesExtraKind
  18696. * - VertexBuffer.MatricesWeightsKind
  18697. * - VertexBuffer.MatricesWeightsExtraKind
  18698. * @returns an array of strings
  18699. */
  18700. getVerticesDataKinds(): string[];
  18701. /**
  18702. * Returns a positive integer : the total number of indices in this mesh geometry.
  18703. * @returns the numner of indices or zero if the mesh has no geometry.
  18704. */
  18705. getTotalIndices(): number;
  18706. /**
  18707. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18708. * @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.
  18709. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  18710. * @returns the indices array or an empty array if the mesh has no geometry
  18711. */
  18712. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  18713. readonly isBlocked: boolean;
  18714. /**
  18715. * Determine if the current mesh is ready to be rendered
  18716. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18717. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  18718. * @returns true if all associated assets are ready (material, textures, shaders)
  18719. */
  18720. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  18721. /**
  18722. * 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.
  18723. */
  18724. readonly areNormalsFrozen: boolean;
  18725. /**
  18726. * 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.
  18727. * @returns the current mesh
  18728. */
  18729. freezeNormals(): Mesh;
  18730. /**
  18731. * 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
  18732. * @returns the current mesh
  18733. */
  18734. unfreezeNormals(): Mesh;
  18735. /**
  18736. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  18737. */
  18738. overridenInstanceCount: number;
  18739. /** @hidden */
  18740. _preActivate(): Mesh;
  18741. /** @hidden */
  18742. _preActivateForIntermediateRendering(renderId: number): Mesh;
  18743. /** @hidden */
  18744. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  18745. /**
  18746. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18747. * This means the mesh underlying bounding box and sphere are recomputed.
  18748. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18749. * @returns the current mesh
  18750. */
  18751. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  18752. /** @hidden */
  18753. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  18754. /**
  18755. * This function will subdivide the mesh into multiple submeshes
  18756. * @param count defines the expected number of submeshes
  18757. */
  18758. subdivide(count: number): void;
  18759. /**
  18760. * Copy a FloatArray into a specific associated vertex buffer
  18761. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  18762. * - VertexBuffer.PositionKind
  18763. * - VertexBuffer.UVKind
  18764. * - VertexBuffer.UV2Kind
  18765. * - VertexBuffer.UV3Kind
  18766. * - VertexBuffer.UV4Kind
  18767. * - VertexBuffer.UV5Kind
  18768. * - VertexBuffer.UV6Kind
  18769. * - VertexBuffer.ColorKind
  18770. * - VertexBuffer.MatricesIndicesKind
  18771. * - VertexBuffer.MatricesIndicesExtraKind
  18772. * - VertexBuffer.MatricesWeightsKind
  18773. * - VertexBuffer.MatricesWeightsExtraKind
  18774. * @param data defines the data source
  18775. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  18776. * @param stride defines the data stride size (can be null)
  18777. * @returns the current mesh
  18778. */
  18779. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  18780. /**
  18781. * Flags an associated vertex buffer as updatable
  18782. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  18783. * - VertexBuffer.PositionKind
  18784. * - VertexBuffer.UVKind
  18785. * - VertexBuffer.UV2Kind
  18786. * - VertexBuffer.UV3Kind
  18787. * - VertexBuffer.UV4Kind
  18788. * - VertexBuffer.UV5Kind
  18789. * - VertexBuffer.UV6Kind
  18790. * - VertexBuffer.ColorKind
  18791. * - VertexBuffer.MatricesIndicesKind
  18792. * - VertexBuffer.MatricesIndicesExtraKind
  18793. * - VertexBuffer.MatricesWeightsKind
  18794. * - VertexBuffer.MatricesWeightsExtraKind
  18795. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  18796. */
  18797. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  18798. /**
  18799. * Sets the mesh global Vertex Buffer
  18800. * @param buffer defines the buffer to use
  18801. * @returns the current mesh
  18802. */
  18803. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  18804. /**
  18805. * Update a specific associated vertex buffer
  18806. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  18807. * - VertexBuffer.PositionKind
  18808. * - VertexBuffer.UVKind
  18809. * - VertexBuffer.UV2Kind
  18810. * - VertexBuffer.UV3Kind
  18811. * - VertexBuffer.UV4Kind
  18812. * - VertexBuffer.UV5Kind
  18813. * - VertexBuffer.UV6Kind
  18814. * - VertexBuffer.ColorKind
  18815. * - VertexBuffer.MatricesIndicesKind
  18816. * - VertexBuffer.MatricesIndicesExtraKind
  18817. * - VertexBuffer.MatricesWeightsKind
  18818. * - VertexBuffer.MatricesWeightsExtraKind
  18819. * @param data defines the data source
  18820. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  18821. * @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)
  18822. * @returns the current mesh
  18823. */
  18824. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18825. /**
  18826. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  18827. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  18828. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  18829. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  18830. * @returns the current mesh
  18831. */
  18832. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  18833. /**
  18834. * Creates a un-shared specific occurence of the geometry for the mesh.
  18835. * @returns the current mesh
  18836. */
  18837. makeGeometryUnique(): Mesh;
  18838. /**
  18839. * Set the index buffer of this mesh
  18840. * @param indices defines the source data
  18841. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  18842. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  18843. * @returns the current mesh
  18844. */
  18845. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  18846. /**
  18847. * Update the current index buffer
  18848. * @param indices defines the source data
  18849. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  18850. * @returns the current mesh
  18851. */
  18852. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  18853. /**
  18854. * Invert the geometry to move from a right handed system to a left handed one.
  18855. * @returns the current mesh
  18856. */
  18857. toLeftHanded(): Mesh;
  18858. /** @hidden */
  18859. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  18860. /** @hidden */
  18861. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  18862. /**
  18863. * Registers for this mesh a javascript function called just before the rendering process
  18864. * @param func defines the function to call before rendering this mesh
  18865. * @returns the current mesh
  18866. */
  18867. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  18868. /**
  18869. * Disposes a previously registered javascript function called before the rendering
  18870. * @param func defines the function to remove
  18871. * @returns the current mesh
  18872. */
  18873. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  18874. /**
  18875. * Registers for this mesh a javascript function called just after the rendering is complete
  18876. * @param func defines the function to call after rendering this mesh
  18877. * @returns the current mesh
  18878. */
  18879. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  18880. /**
  18881. * Disposes a previously registered javascript function called after the rendering.
  18882. * @param func defines the function to remove
  18883. * @returns the current mesh
  18884. */
  18885. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  18886. /** @hidden */
  18887. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  18888. /** @hidden */
  18889. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  18890. /** @hidden */
  18891. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  18892. /**
  18893. * 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
  18894. * @param subMesh defines the subMesh to render
  18895. * @param enableAlphaMode defines if alpha mode can be changed
  18896. * @returns the current mesh
  18897. */
  18898. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  18899. private _onBeforeDraw;
  18900. /**
  18901. * Renormalize the mesh and patch it up if there are no weights
  18902. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  18903. * However in the case of zero weights then we set just a single influence to 1.
  18904. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  18905. */
  18906. cleanMatrixWeights(): void;
  18907. private normalizeSkinFourWeights;
  18908. private normalizeSkinWeightsAndExtra;
  18909. /**
  18910. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  18911. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  18912. * the user know there was an issue with importing the mesh
  18913. * @returns a validation object with skinned, valid and report string
  18914. */
  18915. validateSkinning(): {
  18916. skinned: boolean;
  18917. valid: boolean;
  18918. report: string;
  18919. };
  18920. /** @hidden */
  18921. _checkDelayState(): Mesh;
  18922. private _queueLoad;
  18923. /**
  18924. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  18925. * A mesh is in the frustum if its bounding box intersects the frustum
  18926. * @param frustumPlanes defines the frustum to test
  18927. * @returns true if the mesh is in the frustum planes
  18928. */
  18929. isInFrustum(frustumPlanes: Plane[]): boolean;
  18930. /**
  18931. * Sets the mesh material by the material or multiMaterial `id` property
  18932. * @param id is a string identifying the material or the multiMaterial
  18933. * @returns the current mesh
  18934. */
  18935. setMaterialByID(id: string): Mesh;
  18936. /**
  18937. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  18938. * @returns an array of IAnimatable
  18939. */
  18940. getAnimatables(): IAnimatable[];
  18941. /**
  18942. * Modifies the mesh geometry according to the passed transformation matrix.
  18943. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  18944. * The mesh normals are modified using the same transformation.
  18945. * Note that, under the hood, this method sets a new VertexBuffer each call.
  18946. * @param transform defines the transform matrix to use
  18947. * @see http://doc.babylonjs.com/resources/baking_transformations
  18948. * @returns the current mesh
  18949. */
  18950. bakeTransformIntoVertices(transform: Matrix): Mesh;
  18951. /**
  18952. * Modifies the mesh geometry according to its own current World Matrix.
  18953. * The mesh World Matrix is then reset.
  18954. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  18955. * Note that, under the hood, this method sets a new VertexBuffer each call.
  18956. * @see http://doc.babylonjs.com/resources/baking_transformations
  18957. * @returns the current mesh
  18958. */
  18959. bakeCurrentTransformIntoVertices(): Mesh;
  18960. /** @hidden */
  18961. readonly _positions: Nullable<Vector3[]>;
  18962. /** @hidden */
  18963. _resetPointsArrayCache(): Mesh;
  18964. /** @hidden */
  18965. _generatePointsArray(): boolean;
  18966. /**
  18967. * Returns a new Mesh object generated from the current mesh properties.
  18968. * This method must not get confused with createInstance()
  18969. * @param name is a string, the name given to the new mesh
  18970. * @param newParent can be any Node object (default `null`)
  18971. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  18972. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  18973. * @returns a new mesh
  18974. */
  18975. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  18976. /**
  18977. * Releases resources associated with this mesh.
  18978. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18979. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18980. */
  18981. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18982. /**
  18983. * Modifies the mesh geometry according to a displacement map.
  18984. * 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.
  18985. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  18986. * @param url is a string, the URL from the image file is to be downloaded.
  18987. * @param minHeight is the lower limit of the displacement.
  18988. * @param maxHeight is the upper limit of the displacement.
  18989. * @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.
  18990. * @param uvOffset is an optional vector2 used to offset UV.
  18991. * @param uvScale is an optional vector2 used to scale UV.
  18992. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  18993. * @returns the Mesh.
  18994. */
  18995. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  18996. /**
  18997. * Modifies the mesh geometry according to a displacementMap buffer.
  18998. * 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.
  18999. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  19000. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  19001. * @param heightMapWidth is the width of the buffer image.
  19002. * @param heightMapHeight is the height of the buffer image.
  19003. * @param minHeight is the lower limit of the displacement.
  19004. * @param maxHeight is the upper limit of the displacement.
  19005. * @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.
  19006. * @param uvOffset is an optional vector2 used to offset UV.
  19007. * @param uvScale is an optional vector2 used to scale UV.
  19008. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  19009. * @returns the Mesh.
  19010. */
  19011. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  19012. /**
  19013. * Modify the mesh to get a flat shading rendering.
  19014. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  19015. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  19016. * @returns current mesh
  19017. */
  19018. convertToFlatShadedMesh(): Mesh;
  19019. /**
  19020. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  19021. * In other words, more vertices, no more indices and a single bigger VBO.
  19022. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  19023. * @returns current mesh
  19024. */
  19025. convertToUnIndexedMesh(): Mesh;
  19026. /**
  19027. * Inverses facet orientations.
  19028. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  19029. * @param flipNormals will also inverts the normals
  19030. * @returns current mesh
  19031. */
  19032. flipFaces(flipNormals?: boolean): Mesh;
  19033. /** @hidden */
  19034. static _instancedMeshFactory: (name: string, mesh: Mesh) => InstancedMesh;
  19035. /**
  19036. * Creates a new InstancedMesh object from the mesh model.
  19037. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19038. * @param name defines the name of the new instance
  19039. * @returns a new InstancedMesh
  19040. */
  19041. createInstance(name: string): InstancedMesh;
  19042. /**
  19043. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  19044. * After this call, all the mesh instances have the same submeshes than the current mesh.
  19045. * @returns the current mesh
  19046. */
  19047. synchronizeInstances(): Mesh;
  19048. /**
  19049. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  19050. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  19051. * This should be used together with the simplification to avoid disappearing triangles.
  19052. * @param successCallback an optional success callback to be called after the optimization finished.
  19053. * @returns the current mesh
  19054. */
  19055. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  19056. /**
  19057. * Serialize current mesh
  19058. * @param serializationObject defines the object which will receive the serialization data
  19059. */
  19060. serialize(serializationObject: any): void;
  19061. /** @hidden */
  19062. _syncGeometryWithMorphTargetManager(): void;
  19063. /** @hidden */
  19064. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  19065. /**
  19066. * Returns a new Mesh object parsed from the source provided.
  19067. * @param parsedMesh is the source
  19068. * @param scene defines the hosting scene
  19069. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  19070. * @returns a new Mesh
  19071. */
  19072. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  19073. /**
  19074. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  19075. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19076. * @param name defines the name of the mesh to create
  19077. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  19078. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  19079. * @param closePath creates a seam between the first and the last points of each path of the path array
  19080. * @param offset is taken in account only if the `pathArray` is containing a single path
  19081. * @param scene defines the hosting scene
  19082. * @param updatable defines if the mesh must be flagged as updatable
  19083. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19084. * @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)
  19085. * @returns a new Mesh
  19086. */
  19087. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19088. /**
  19089. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  19090. * @param name defines the name of the mesh to create
  19091. * @param radius sets the radius size (float) of the polygon (default 0.5)
  19092. * @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
  19093. * @param scene defines the hosting scene
  19094. * @param updatable defines if the mesh must be flagged as updatable
  19095. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19096. * @returns a new Mesh
  19097. */
  19098. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  19099. /**
  19100. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  19101. * @param name defines the name of the mesh to create
  19102. * @param size sets the size (float) of each box side (default 1)
  19103. * @param scene defines the hosting scene
  19104. * @param updatable defines if the mesh must be flagged as updatable
  19105. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19106. * @returns a new Mesh
  19107. */
  19108. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  19109. /**
  19110. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  19111. * @param name defines the name of the mesh to create
  19112. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  19113. * @param diameter sets the diameter size (float) of the sphere (default 1)
  19114. * @param scene defines the hosting scene
  19115. * @param updatable defines if the mesh must be flagged as updatable
  19116. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19117. * @returns a new Mesh
  19118. */
  19119. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19120. /**
  19121. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  19122. * @param name defines the name of the mesh to create
  19123. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  19124. * @param diameterTop set the top cap diameter (floats, default 1)
  19125. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  19126. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  19127. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  19128. * @param scene defines the hosting scene
  19129. * @param updatable defines if the mesh must be flagged as updatable
  19130. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19131. * @returns a new Mesh
  19132. */
  19133. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  19134. /**
  19135. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  19136. * @param name defines the name of the mesh to create
  19137. * @param diameter sets the diameter size (float) of the torus (default 1)
  19138. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  19139. * @param tessellation sets the number of torus sides (postive integer, default 16)
  19140. * @param scene defines the hosting scene
  19141. * @param updatable defines if the mesh must be flagged as updatable
  19142. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19143. * @returns a new Mesh
  19144. */
  19145. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19146. /**
  19147. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  19148. * @param name defines the name of the mesh to create
  19149. * @param radius sets the global radius size (float) of the torus knot (default 2)
  19150. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  19151. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  19152. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  19153. * @param p the number of windings on X axis (positive integers, default 2)
  19154. * @param q the number of windings on Y axis (positive integers, default 3)
  19155. * @param scene defines the hosting scene
  19156. * @param updatable defines if the mesh must be flagged as updatable
  19157. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19158. * @returns a new Mesh
  19159. */
  19160. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19161. /**
  19162. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  19163. * @param name defines the name of the mesh to create
  19164. * @param points is an array successive Vector3
  19165. * @param scene defines the hosting scene
  19166. * @param updatable defines if the mesh must be flagged as updatable
  19167. * @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).
  19168. * @returns a new Mesh
  19169. */
  19170. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  19171. /**
  19172. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  19173. * @param name defines the name of the mesh to create
  19174. * @param points is an array successive Vector3
  19175. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  19176. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  19177. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  19178. * @param scene defines the hosting scene
  19179. * @param updatable defines if the mesh must be flagged as updatable
  19180. * @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)
  19181. * @returns a new Mesh
  19182. */
  19183. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  19184. /**
  19185. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  19186. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  19187. * 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.
  19188. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  19189. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19190. * Remember you can only change the shape positions, not their number when updating a polygon.
  19191. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  19192. * @param name defines the name of the mesh to create
  19193. * @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
  19194. * @param scene defines the hosting scene
  19195. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  19196. * @param updatable defines if the mesh must be flagged as updatable
  19197. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19198. * @param earcutInjection can be used to inject your own earcut reference
  19199. * @returns a new Mesh
  19200. */
  19201. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  19202. /**
  19203. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  19204. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  19205. * @param name defines the name of the mesh to create
  19206. * @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
  19207. * @param depth defines the height of extrusion
  19208. * @param scene defines the hosting scene
  19209. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  19210. * @param updatable defines if the mesh must be flagged as updatable
  19211. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19212. * @param earcutInjection can be used to inject your own earcut reference
  19213. * @returns a new Mesh
  19214. */
  19215. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  19216. /**
  19217. * Creates an extruded shape mesh.
  19218. * 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
  19219. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19220. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  19221. * @param name defines the name of the mesh to create
  19222. * @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
  19223. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  19224. * @param scale is the value to scale the shape
  19225. * @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
  19226. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  19227. * @param scene defines the hosting scene
  19228. * @param updatable defines if the mesh must be flagged as updatable
  19229. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19230. * @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)
  19231. * @returns a new Mesh
  19232. */
  19233. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19234. /**
  19235. * Creates an custom extruded shape mesh.
  19236. * The custom extrusion is a parametric shape.
  19237. * It has no predefined shape. Its final shape will depend on the input parameters.
  19238. * Please consider using the same method from the MeshBuilder class instead
  19239. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  19240. * @param name defines the name of the mesh to create
  19241. * @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
  19242. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  19243. * @param scaleFunction is a custom Javascript function called on each path point
  19244. * @param rotationFunction is a custom Javascript function called on each path point
  19245. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  19246. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  19247. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  19248. * @param scene defines the hosting scene
  19249. * @param updatable defines if the mesh must be flagged as updatable
  19250. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19251. * @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)
  19252. * @returns a new Mesh
  19253. */
  19254. 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;
  19255. /**
  19256. * Creates lathe mesh.
  19257. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  19258. * Please consider using the same method from the MeshBuilder class instead
  19259. * @param name defines the name of the mesh to create
  19260. * @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
  19261. * @param radius is the radius value of the lathe
  19262. * @param tessellation is the side number of the lathe.
  19263. * @param scene defines the hosting scene
  19264. * @param updatable defines if the mesh must be flagged as updatable
  19265. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19266. * @returns a new Mesh
  19267. */
  19268. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19269. /**
  19270. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  19271. * @param name defines the name of the mesh to create
  19272. * @param size sets the size (float) of both sides of the plane at once (default 1)
  19273. * @param scene defines the hosting scene
  19274. * @param updatable defines if the mesh must be flagged as updatable
  19275. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19276. * @returns a new Mesh
  19277. */
  19278. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19279. /**
  19280. * Creates a ground mesh.
  19281. * Please consider using the same method from the MeshBuilder class instead
  19282. * @param name defines the name of the mesh to create
  19283. * @param width set the width of the ground
  19284. * @param height set the height of the ground
  19285. * @param subdivisions sets the number of subdivisions per side
  19286. * @param scene defines the hosting scene
  19287. * @param updatable defines if the mesh must be flagged as updatable
  19288. * @returns a new Mesh
  19289. */
  19290. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  19291. /**
  19292. * Creates a tiled ground mesh.
  19293. * Please consider using the same method from the MeshBuilder class instead
  19294. * @param name defines the name of the mesh to create
  19295. * @param xmin set the ground minimum X coordinate
  19296. * @param zmin set the ground minimum Y coordinate
  19297. * @param xmax set the ground maximum X coordinate
  19298. * @param zmax set the ground maximum Z coordinate
  19299. * @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
  19300. * @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
  19301. * @param scene defines the hosting scene
  19302. * @param updatable defines if the mesh must be flagged as updatable
  19303. * @returns a new Mesh
  19304. */
  19305. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  19306. w: number;
  19307. h: number;
  19308. }, precision: {
  19309. w: number;
  19310. h: number;
  19311. }, scene: Scene, updatable?: boolean): Mesh;
  19312. /**
  19313. * Creates a ground mesh from a height map.
  19314. * Please consider using the same method from the MeshBuilder class instead
  19315. * @see http://doc.babylonjs.com/babylon101/height_map
  19316. * @param name defines the name of the mesh to create
  19317. * @param url sets the URL of the height map image resource
  19318. * @param width set the ground width size
  19319. * @param height set the ground height size
  19320. * @param subdivisions sets the number of subdivision per side
  19321. * @param minHeight is the minimum altitude on the ground
  19322. * @param maxHeight is the maximum altitude on the ground
  19323. * @param scene defines the hosting scene
  19324. * @param updatable defines if the mesh must be flagged as updatable
  19325. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  19326. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  19327. * @returns a new Mesh
  19328. */
  19329. 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;
  19330. /**
  19331. * Creates a tube mesh.
  19332. * The tube is a parametric shape.
  19333. * It has no predefined shape. Its final shape will depend on the input parameters.
  19334. * Please consider using the same method from the MeshBuilder class instead
  19335. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19336. * @param name defines the name of the mesh to create
  19337. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  19338. * @param radius sets the tube radius size
  19339. * @param tessellation is the number of sides on the tubular surface
  19340. * @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
  19341. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  19342. * @param scene defines the hosting scene
  19343. * @param updatable defines if the mesh must be flagged as updatable
  19344. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19345. * @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)
  19346. * @returns a new Mesh
  19347. */
  19348. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  19349. (i: number, distance: number): number;
  19350. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19351. /**
  19352. * Creates a polyhedron mesh.
  19353. * Please consider using the same method from the MeshBuilder class instead.
  19354. * * 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
  19355. * * The parameter `size` (positive float, default 1) sets the polygon size
  19356. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  19357. * * 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`
  19358. * * 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
  19359. * * 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)`)
  19360. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  19361. * * 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
  19362. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  19363. * * 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
  19364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19365. * @param name defines the name of the mesh to create
  19366. * @param options defines the options used to create the mesh
  19367. * @param scene defines the hosting scene
  19368. * @returns a new Mesh
  19369. */
  19370. static CreatePolyhedron(name: string, options: {
  19371. type?: number;
  19372. size?: number;
  19373. sizeX?: number;
  19374. sizeY?: number;
  19375. sizeZ?: number;
  19376. custom?: any;
  19377. faceUV?: Vector4[];
  19378. faceColors?: Color4[];
  19379. updatable?: boolean;
  19380. sideOrientation?: number;
  19381. }, scene: Scene): Mesh;
  19382. /**
  19383. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  19384. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  19385. * * 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`)
  19386. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  19387. * * 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
  19388. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  19389. * * 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
  19390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19391. * @param name defines the name of the mesh
  19392. * @param options defines the options used to create the mesh
  19393. * @param scene defines the hosting scene
  19394. * @returns a new Mesh
  19395. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  19396. */
  19397. static CreateIcoSphere(name: string, options: {
  19398. radius?: number;
  19399. flat?: boolean;
  19400. subdivisions?: number;
  19401. sideOrientation?: number;
  19402. updatable?: boolean;
  19403. }, scene: Scene): Mesh;
  19404. /**
  19405. * Creates a decal mesh.
  19406. * Please consider using the same method from the MeshBuilder class instead.
  19407. * A decal is a mesh usually applied as a model onto the surface of another mesh
  19408. * @param name defines the name of the mesh
  19409. * @param sourceMesh defines the mesh receiving the decal
  19410. * @param position sets the position of the decal in world coordinates
  19411. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  19412. * @param size sets the decal scaling
  19413. * @param angle sets the angle to rotate the decal
  19414. * @returns a new Mesh
  19415. */
  19416. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  19417. /**
  19418. * Prepare internal position array for software CPU skinning
  19419. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  19420. */
  19421. setPositionsForCPUSkinning(): Float32Array;
  19422. /**
  19423. * Prepare internal normal array for software CPU skinning
  19424. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  19425. */
  19426. setNormalsForCPUSkinning(): Float32Array;
  19427. /**
  19428. * Updates the vertex buffer by applying transformation from the bones
  19429. * @param skeleton defines the skeleton to apply to current mesh
  19430. * @returns the current mesh
  19431. */
  19432. applySkeleton(skeleton: Skeleton): Mesh;
  19433. /**
  19434. * 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
  19435. * @param meshes defines the list of meshes to scan
  19436. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  19437. */
  19438. static MinMax(meshes: AbstractMesh[]): {
  19439. min: Vector3;
  19440. max: Vector3;
  19441. };
  19442. /**
  19443. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  19444. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  19445. * @returns a vector3
  19446. */
  19447. static Center(meshesOrMinMaxVector: {
  19448. min: Vector3;
  19449. max: Vector3;
  19450. } | AbstractMesh[]): Vector3;
  19451. /**
  19452. * Merge the array of meshes into a single mesh for performance reasons.
  19453. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  19454. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  19455. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  19456. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  19457. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  19458. * @returns a new mesh
  19459. */
  19460. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  19461. /** @hidden */
  19462. addInstance(instance: InstancedMesh): void;
  19463. /** @hidden */
  19464. removeInstance(instance: InstancedMesh): void;
  19465. }
  19466. }
  19467. declare module BABYLON {
  19468. /**
  19469. * Interface used to define Action
  19470. */
  19471. export interface IAction {
  19472. /**
  19473. * Trigger for the action
  19474. */
  19475. trigger: number;
  19476. /** the trigger, with or without parameters, for the action */
  19477. triggerOptions: any;
  19478. /**
  19479. * Gets the trigger parameters
  19480. * @returns the trigger parameters
  19481. */
  19482. getTriggerParameter(): any;
  19483. /**
  19484. * Internal only - executes current action event
  19485. * @hidden
  19486. */
  19487. _executeCurrent(evt?: ActionEvent): void;
  19488. /**
  19489. * Serialize placeholder for child classes
  19490. * @param parent of child
  19491. * @returns the serialized object
  19492. */
  19493. serialize(parent: any): any;
  19494. }
  19495. /**
  19496. * The action to be carried out following a trigger
  19497. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  19498. */
  19499. export class Action implements IAction {
  19500. /** the trigger, with or without parameters, for the action */
  19501. triggerOptions: any;
  19502. /**
  19503. * Trigger for the action
  19504. */
  19505. trigger: number;
  19506. /**
  19507. * Internal only - manager for action
  19508. * @hidden
  19509. */
  19510. _actionManager: ActionManager;
  19511. private _nextActiveAction;
  19512. private _child;
  19513. private _condition?;
  19514. private _triggerParameter;
  19515. /**
  19516. * An event triggered prior to action being executed.
  19517. */
  19518. onBeforeExecuteObservable: Observable<Action>;
  19519. /**
  19520. * Creates a new Action
  19521. * @param triggerOptions the trigger, with or without parameters, for the action
  19522. * @param condition an optional determinant of action
  19523. */
  19524. constructor(
  19525. /** the trigger, with or without parameters, for the action */
  19526. triggerOptions: any, condition?: Condition);
  19527. /**
  19528. * Internal only
  19529. * @hidden
  19530. */
  19531. _prepare(): void;
  19532. /**
  19533. * Gets the trigger parameters
  19534. * @returns the trigger parameters
  19535. */
  19536. getTriggerParameter(): any;
  19537. /**
  19538. * Internal only - executes current action event
  19539. * @hidden
  19540. */
  19541. _executeCurrent(evt?: ActionEvent): void;
  19542. /**
  19543. * Execute placeholder for child classes
  19544. * @param evt optional action event
  19545. */
  19546. execute(evt?: ActionEvent): void;
  19547. /**
  19548. * Skips to next active action
  19549. */
  19550. skipToNextActiveAction(): void;
  19551. /**
  19552. * Adds action to chain of actions, may be a DoNothingAction
  19553. * @param action defines the next action to execute
  19554. * @returns The action passed in
  19555. * @see https://www.babylonjs-playground.com/#1T30HR#0
  19556. */
  19557. then(action: Action): Action;
  19558. /**
  19559. * Internal only
  19560. * @hidden
  19561. */
  19562. _getProperty(propertyPath: string): string;
  19563. /**
  19564. * Internal only
  19565. * @hidden
  19566. */
  19567. _getEffectiveTarget(target: any, propertyPath: string): any;
  19568. /**
  19569. * Serialize placeholder for child classes
  19570. * @param parent of child
  19571. * @returns the serialized object
  19572. */
  19573. serialize(parent: any): any;
  19574. /**
  19575. * Internal only called by serialize
  19576. * @hidden
  19577. */
  19578. protected _serialize(serializedAction: any, parent?: any): any;
  19579. /**
  19580. * Internal only
  19581. * @hidden
  19582. */
  19583. static _SerializeValueAsString: (value: any) => string;
  19584. /**
  19585. * Internal only
  19586. * @hidden
  19587. */
  19588. static _GetTargetProperty: (target: Scene | Node) => {
  19589. name: string;
  19590. targetType: string;
  19591. value: string;
  19592. };
  19593. }
  19594. }
  19595. declare module BABYLON {
  19596. /**
  19597. * A Condition applied to an Action
  19598. */
  19599. export class Condition {
  19600. /**
  19601. * Internal only - manager for action
  19602. * @hidden
  19603. */
  19604. _actionManager: ActionManager;
  19605. /**
  19606. * Internal only
  19607. * @hidden
  19608. */
  19609. _evaluationId: number;
  19610. /**
  19611. * Internal only
  19612. * @hidden
  19613. */
  19614. _currentResult: boolean;
  19615. /**
  19616. * Creates a new Condition
  19617. * @param actionManager the manager of the action the condition is applied to
  19618. */
  19619. constructor(actionManager: ActionManager);
  19620. /**
  19621. * Check if the current condition is valid
  19622. * @returns a boolean
  19623. */
  19624. isValid(): boolean;
  19625. /**
  19626. * Internal only
  19627. * @hidden
  19628. */
  19629. _getProperty(propertyPath: string): string;
  19630. /**
  19631. * Internal only
  19632. * @hidden
  19633. */
  19634. _getEffectiveTarget(target: any, propertyPath: string): any;
  19635. /**
  19636. * Serialize placeholder for child classes
  19637. * @returns the serialized object
  19638. */
  19639. serialize(): any;
  19640. /**
  19641. * Internal only
  19642. * @hidden
  19643. */
  19644. protected _serialize(serializedCondition: any): any;
  19645. }
  19646. /**
  19647. * Defines specific conditional operators as extensions of Condition
  19648. */
  19649. export class ValueCondition extends Condition {
  19650. /** path to specify the property of the target the conditional operator uses */
  19651. propertyPath: string;
  19652. /** the value compared by the conditional operator against the current value of the property */
  19653. value: any;
  19654. /** the conditional operator, default ValueCondition.IsEqual */
  19655. operator: number;
  19656. /**
  19657. * Internal only
  19658. * @hidden
  19659. */
  19660. private static _IsEqual;
  19661. /**
  19662. * Internal only
  19663. * @hidden
  19664. */
  19665. private static _IsDifferent;
  19666. /**
  19667. * Internal only
  19668. * @hidden
  19669. */
  19670. private static _IsGreater;
  19671. /**
  19672. * Internal only
  19673. * @hidden
  19674. */
  19675. private static _IsLesser;
  19676. /**
  19677. * returns the number for IsEqual
  19678. */
  19679. static readonly IsEqual: number;
  19680. /**
  19681. * Returns the number for IsDifferent
  19682. */
  19683. static readonly IsDifferent: number;
  19684. /**
  19685. * Returns the number for IsGreater
  19686. */
  19687. static readonly IsGreater: number;
  19688. /**
  19689. * Returns the number for IsLesser
  19690. */
  19691. static readonly IsLesser: number;
  19692. /**
  19693. * Internal only The action manager for the condition
  19694. * @hidden
  19695. */
  19696. _actionManager: ActionManager;
  19697. /**
  19698. * Internal only
  19699. * @hidden
  19700. */
  19701. private _target;
  19702. /**
  19703. * Internal only
  19704. * @hidden
  19705. */
  19706. private _effectiveTarget;
  19707. /**
  19708. * Internal only
  19709. * @hidden
  19710. */
  19711. private _property;
  19712. /**
  19713. * Creates a new ValueCondition
  19714. * @param actionManager manager for the action the condition applies to
  19715. * @param target for the action
  19716. * @param propertyPath path to specify the property of the target the conditional operator uses
  19717. * @param value the value compared by the conditional operator against the current value of the property
  19718. * @param operator the conditional operator, default ValueCondition.IsEqual
  19719. */
  19720. constructor(actionManager: ActionManager, target: any,
  19721. /** path to specify the property of the target the conditional operator uses */
  19722. propertyPath: string,
  19723. /** the value compared by the conditional operator against the current value of the property */
  19724. value: any,
  19725. /** the conditional operator, default ValueCondition.IsEqual */
  19726. operator?: number);
  19727. /**
  19728. * Compares the given value with the property value for the specified conditional operator
  19729. * @returns the result of the comparison
  19730. */
  19731. isValid(): boolean;
  19732. /**
  19733. * Serialize the ValueCondition into a JSON compatible object
  19734. * @returns serialization object
  19735. */
  19736. serialize(): any;
  19737. /**
  19738. * Gets the name of the conditional operator for the ValueCondition
  19739. * @param operator the conditional operator
  19740. * @returns the name
  19741. */
  19742. static GetOperatorName(operator: number): string;
  19743. }
  19744. /**
  19745. * Defines a predicate condition as an extension of Condition
  19746. */
  19747. export class PredicateCondition extends Condition {
  19748. /** defines the predicate function used to validate the condition */
  19749. predicate: () => boolean;
  19750. /**
  19751. * Internal only - manager for action
  19752. * @hidden
  19753. */
  19754. _actionManager: ActionManager;
  19755. /**
  19756. * Creates a new PredicateCondition
  19757. * @param actionManager manager for the action the condition applies to
  19758. * @param predicate defines the predicate function used to validate the condition
  19759. */
  19760. constructor(actionManager: ActionManager,
  19761. /** defines the predicate function used to validate the condition */
  19762. predicate: () => boolean);
  19763. /**
  19764. * @returns the validity of the predicate condition
  19765. */
  19766. isValid(): boolean;
  19767. }
  19768. /**
  19769. * Defines a state condition as an extension of Condition
  19770. */
  19771. export class StateCondition extends Condition {
  19772. /** Value to compare with target state */
  19773. value: string;
  19774. /**
  19775. * Internal only - manager for action
  19776. * @hidden
  19777. */
  19778. _actionManager: ActionManager;
  19779. /**
  19780. * Internal only
  19781. * @hidden
  19782. */
  19783. private _target;
  19784. /**
  19785. * Creates a new StateCondition
  19786. * @param actionManager manager for the action the condition applies to
  19787. * @param target of the condition
  19788. * @param value to compare with target state
  19789. */
  19790. constructor(actionManager: ActionManager, target: any,
  19791. /** Value to compare with target state */
  19792. value: string);
  19793. /**
  19794. * Gets a boolean indicating if the current condition is met
  19795. * @returns the validity of the state
  19796. */
  19797. isValid(): boolean;
  19798. /**
  19799. * Serialize the StateCondition into a JSON compatible object
  19800. * @returns serialization object
  19801. */
  19802. serialize(): any;
  19803. }
  19804. }
  19805. declare module BABYLON {
  19806. /**
  19807. * This defines an action responsible to toggle a boolean once triggered.
  19808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  19809. */
  19810. export class SwitchBooleanAction extends Action {
  19811. /**
  19812. * The path to the boolean property in the target object
  19813. */
  19814. propertyPath: string;
  19815. private _target;
  19816. private _effectiveTarget;
  19817. private _property;
  19818. /**
  19819. * Instantiate the action
  19820. * @param triggerOptions defines the trigger options
  19821. * @param target defines the object containing the boolean
  19822. * @param propertyPath defines the path to the boolean property in the target object
  19823. * @param condition defines the trigger related conditions
  19824. */
  19825. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  19826. /** @hidden */
  19827. _prepare(): void;
  19828. /**
  19829. * Execute the action toggle the boolean value.
  19830. */
  19831. execute(): void;
  19832. /**
  19833. * Serializes the actions and its related information.
  19834. * @param parent defines the object to serialize in
  19835. * @returns the serialized object
  19836. */
  19837. serialize(parent: any): any;
  19838. }
  19839. /**
  19840. * This defines an action responsible to set a the state field of the target
  19841. * to a desired value once triggered.
  19842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  19843. */
  19844. export class SetStateAction extends Action {
  19845. /**
  19846. * The value to store in the state field.
  19847. */
  19848. value: string;
  19849. private _target;
  19850. /**
  19851. * Instantiate the action
  19852. * @param triggerOptions defines the trigger options
  19853. * @param target defines the object containing the state property
  19854. * @param value defines the value to store in the state field
  19855. * @param condition defines the trigger related conditions
  19856. */
  19857. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  19858. /**
  19859. * Execute the action and store the value on the target state property.
  19860. */
  19861. execute(): void;
  19862. /**
  19863. * Serializes the actions and its related information.
  19864. * @param parent defines the object to serialize in
  19865. * @returns the serialized object
  19866. */
  19867. serialize(parent: any): any;
  19868. }
  19869. /**
  19870. * This defines an action responsible to set a property of the target
  19871. * to a desired value once triggered.
  19872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  19873. */
  19874. export class SetValueAction extends Action {
  19875. /**
  19876. * The path of the property to set in the target.
  19877. */
  19878. propertyPath: string;
  19879. /**
  19880. * The value to set in the property
  19881. */
  19882. value: any;
  19883. private _target;
  19884. private _effectiveTarget;
  19885. private _property;
  19886. /**
  19887. * Instantiate the action
  19888. * @param triggerOptions defines the trigger options
  19889. * @param target defines the object containing the property
  19890. * @param propertyPath defines the path of the property to set in the target
  19891. * @param value defines the value to set in the property
  19892. * @param condition defines the trigger related conditions
  19893. */
  19894. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  19895. /** @hidden */
  19896. _prepare(): void;
  19897. /**
  19898. * Execute the action and set the targetted property to the desired value.
  19899. */
  19900. execute(): void;
  19901. /**
  19902. * Serializes the actions and its related information.
  19903. * @param parent defines the object to serialize in
  19904. * @returns the serialized object
  19905. */
  19906. serialize(parent: any): any;
  19907. }
  19908. /**
  19909. * This defines an action responsible to increment the target value
  19910. * to a desired value once triggered.
  19911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  19912. */
  19913. export class IncrementValueAction extends Action {
  19914. /**
  19915. * The path of the property to increment in the target.
  19916. */
  19917. propertyPath: string;
  19918. /**
  19919. * The value we should increment the property by.
  19920. */
  19921. value: any;
  19922. private _target;
  19923. private _effectiveTarget;
  19924. private _property;
  19925. /**
  19926. * Instantiate the action
  19927. * @param triggerOptions defines the trigger options
  19928. * @param target defines the object containing the property
  19929. * @param propertyPath defines the path of the property to increment in the target
  19930. * @param value defines the value value we should increment the property by
  19931. * @param condition defines the trigger related conditions
  19932. */
  19933. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  19934. /** @hidden */
  19935. _prepare(): void;
  19936. /**
  19937. * Execute the action and increment the target of the value amount.
  19938. */
  19939. execute(): void;
  19940. /**
  19941. * Serializes the actions and its related information.
  19942. * @param parent defines the object to serialize in
  19943. * @returns the serialized object
  19944. */
  19945. serialize(parent: any): any;
  19946. }
  19947. /**
  19948. * This defines an action responsible to start an animation once triggered.
  19949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  19950. */
  19951. export class PlayAnimationAction extends Action {
  19952. /**
  19953. * Where the animation should start (animation frame)
  19954. */
  19955. from: number;
  19956. /**
  19957. * Where the animation should stop (animation frame)
  19958. */
  19959. to: number;
  19960. /**
  19961. * Define if the animation should loop or stop after the first play.
  19962. */
  19963. loop?: boolean;
  19964. private _target;
  19965. /**
  19966. * Instantiate the action
  19967. * @param triggerOptions defines the trigger options
  19968. * @param target defines the target animation or animation name
  19969. * @param from defines from where the animation should start (animation frame)
  19970. * @param end defines where the animation should stop (animation frame)
  19971. * @param loop defines if the animation should loop or stop after the first play
  19972. * @param condition defines the trigger related conditions
  19973. */
  19974. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  19975. /** @hidden */
  19976. _prepare(): void;
  19977. /**
  19978. * Execute the action and play the animation.
  19979. */
  19980. execute(): void;
  19981. /**
  19982. * Serializes the actions and its related information.
  19983. * @param parent defines the object to serialize in
  19984. * @returns the serialized object
  19985. */
  19986. serialize(parent: any): any;
  19987. }
  19988. /**
  19989. * This defines an action responsible to stop an animation once triggered.
  19990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  19991. */
  19992. export class StopAnimationAction extends Action {
  19993. private _target;
  19994. /**
  19995. * Instantiate the action
  19996. * @param triggerOptions defines the trigger options
  19997. * @param target defines the target animation or animation name
  19998. * @param condition defines the trigger related conditions
  19999. */
  20000. constructor(triggerOptions: any, target: any, condition?: Condition);
  20001. /** @hidden */
  20002. _prepare(): void;
  20003. /**
  20004. * Execute the action and stop the animation.
  20005. */
  20006. execute(): void;
  20007. /**
  20008. * Serializes the actions and its related information.
  20009. * @param parent defines the object to serialize in
  20010. * @returns the serialized object
  20011. */
  20012. serialize(parent: any): any;
  20013. }
  20014. /**
  20015. * This defines an action responsible that does nothing once triggered.
  20016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20017. */
  20018. export class DoNothingAction extends Action {
  20019. /**
  20020. * Instantiate the action
  20021. * @param triggerOptions defines the trigger options
  20022. * @param condition defines the trigger related conditions
  20023. */
  20024. constructor(triggerOptions?: any, condition?: Condition);
  20025. /**
  20026. * Execute the action and do nothing.
  20027. */
  20028. execute(): void;
  20029. /**
  20030. * Serializes the actions and its related information.
  20031. * @param parent defines the object to serialize in
  20032. * @returns the serialized object
  20033. */
  20034. serialize(parent: any): any;
  20035. }
  20036. /**
  20037. * This defines an action responsible to trigger several actions once triggered.
  20038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20039. */
  20040. export class CombineAction extends Action {
  20041. /**
  20042. * The list of aggregated animations to run.
  20043. */
  20044. children: Action[];
  20045. /**
  20046. * Instantiate the action
  20047. * @param triggerOptions defines the trigger options
  20048. * @param children defines the list of aggregated animations to run
  20049. * @param condition defines the trigger related conditions
  20050. */
  20051. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  20052. /** @hidden */
  20053. _prepare(): void;
  20054. /**
  20055. * Execute the action and executes all the aggregated actions.
  20056. */
  20057. execute(evt: ActionEvent): void;
  20058. /**
  20059. * Serializes the actions and its related information.
  20060. * @param parent defines the object to serialize in
  20061. * @returns the serialized object
  20062. */
  20063. serialize(parent: any): any;
  20064. }
  20065. /**
  20066. * This defines an action responsible to run code (external event) once triggered.
  20067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20068. */
  20069. export class ExecuteCodeAction extends Action {
  20070. /**
  20071. * The callback function to run.
  20072. */
  20073. func: (evt: ActionEvent) => void;
  20074. /**
  20075. * Instantiate the action
  20076. * @param triggerOptions defines the trigger options
  20077. * @param func defines the callback function to run
  20078. * @param condition defines the trigger related conditions
  20079. */
  20080. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  20081. /**
  20082. * Execute the action and run the attached code.
  20083. */
  20084. execute(evt: ActionEvent): void;
  20085. }
  20086. /**
  20087. * This defines an action responsible to set the parent property of the target once triggered.
  20088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20089. */
  20090. export class SetParentAction extends Action {
  20091. private _parent;
  20092. private _target;
  20093. /**
  20094. * Instantiate the action
  20095. * @param triggerOptions defines the trigger options
  20096. * @param target defines the target containing the parent property
  20097. * @param parent defines from where the animation should start (animation frame)
  20098. * @param condition defines the trigger related conditions
  20099. */
  20100. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  20101. /** @hidden */
  20102. _prepare(): void;
  20103. /**
  20104. * Execute the action and set the parent property.
  20105. */
  20106. execute(): void;
  20107. /**
  20108. * Serializes the actions and its related information.
  20109. * @param parent defines the object to serialize in
  20110. * @returns the serialized object
  20111. */
  20112. serialize(parent: any): any;
  20113. }
  20114. }
  20115. declare module BABYLON {
  20116. /**
  20117. * Abstract class used to decouple action Manager from scene and meshes.
  20118. * Do not instantiate.
  20119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20120. */
  20121. export abstract class AbstractActionManager implements IDisposable {
  20122. /** Gets the list of active triggers */
  20123. static Triggers: {
  20124. [key: string]: number;
  20125. };
  20126. /** Gets the cursor to use when hovering items */
  20127. hoverCursor: string;
  20128. /** Gets the list of actions */
  20129. actions: IAction[];
  20130. /**
  20131. * Releases all associated resources
  20132. */
  20133. abstract dispose(): void;
  20134. /**
  20135. * Does this action manager has pointer triggers
  20136. */
  20137. abstract readonly hasPointerTriggers: boolean;
  20138. /**
  20139. * Does this action manager has pick triggers
  20140. */
  20141. abstract readonly hasPickTriggers: boolean;
  20142. /**
  20143. * Process a specific trigger
  20144. * @param trigger defines the trigger to process
  20145. * @param evt defines the event details to be processed
  20146. */
  20147. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  20148. /**
  20149. * Does this action manager handles actions of any of the given triggers
  20150. * @param triggers defines the triggers to be tested
  20151. * @return a boolean indicating whether one (or more) of the triggers is handled
  20152. */
  20153. abstract hasSpecificTriggers(triggers: number[]): boolean;
  20154. /**
  20155. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  20156. * speed.
  20157. * @param triggerA defines the trigger to be tested
  20158. * @param triggerB defines the trigger to be tested
  20159. * @return a boolean indicating whether one (or more) of the triggers is handled
  20160. */
  20161. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  20162. /**
  20163. * Does this action manager handles actions of a given trigger
  20164. * @param trigger defines the trigger to be tested
  20165. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  20166. * @return whether the trigger is handled
  20167. */
  20168. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  20169. /**
  20170. * Serialize this manager to a JSON object
  20171. * @param name defines the property name to store this manager
  20172. * @returns a JSON representation of this manager
  20173. */
  20174. abstract serialize(name: string): any;
  20175. /**
  20176. * Does exist one action manager with at least one trigger
  20177. **/
  20178. static readonly HasTriggers: boolean;
  20179. /**
  20180. * Does exist one action manager with at least one pick trigger
  20181. **/
  20182. static readonly HasPickTriggers: boolean;
  20183. /**
  20184. * Does exist one action manager that handles actions of a given trigger
  20185. * @param trigger defines the trigger to be tested
  20186. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  20187. **/
  20188. static HasSpecificTrigger(trigger: number): boolean;
  20189. }
  20190. }
  20191. declare module BABYLON {
  20192. /**
  20193. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  20194. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  20195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20196. */
  20197. export class ActionManager extends AbstractActionManager {
  20198. /**
  20199. * Nothing
  20200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20201. */
  20202. static readonly NothingTrigger: number;
  20203. /**
  20204. * On pick
  20205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20206. */
  20207. static readonly OnPickTrigger: number;
  20208. /**
  20209. * On left pick
  20210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20211. */
  20212. static readonly OnLeftPickTrigger: number;
  20213. /**
  20214. * On right pick
  20215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20216. */
  20217. static readonly OnRightPickTrigger: number;
  20218. /**
  20219. * On center pick
  20220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20221. */
  20222. static readonly OnCenterPickTrigger: number;
  20223. /**
  20224. * On pick down
  20225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20226. */
  20227. static readonly OnPickDownTrigger: number;
  20228. /**
  20229. * On double pick
  20230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20231. */
  20232. static readonly OnDoublePickTrigger: number;
  20233. /**
  20234. * On pick up
  20235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20236. */
  20237. static readonly OnPickUpTrigger: number;
  20238. /**
  20239. * On pick out.
  20240. * This trigger will only be raised if you also declared a OnPickDown
  20241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20242. */
  20243. static readonly OnPickOutTrigger: number;
  20244. /**
  20245. * On long press
  20246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20247. */
  20248. static readonly OnLongPressTrigger: number;
  20249. /**
  20250. * On pointer over
  20251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20252. */
  20253. static readonly OnPointerOverTrigger: number;
  20254. /**
  20255. * On pointer out
  20256. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20257. */
  20258. static readonly OnPointerOutTrigger: number;
  20259. /**
  20260. * On every frame
  20261. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20262. */
  20263. static readonly OnEveryFrameTrigger: number;
  20264. /**
  20265. * On intersection enter
  20266. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20267. */
  20268. static readonly OnIntersectionEnterTrigger: number;
  20269. /**
  20270. * On intersection exit
  20271. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20272. */
  20273. static readonly OnIntersectionExitTrigger: number;
  20274. /**
  20275. * On key down
  20276. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20277. */
  20278. static readonly OnKeyDownTrigger: number;
  20279. /**
  20280. * On key up
  20281. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20282. */
  20283. static readonly OnKeyUpTrigger: number;
  20284. private _scene;
  20285. /**
  20286. * Creates a new action manager
  20287. * @param scene defines the hosting scene
  20288. */
  20289. constructor(scene: Scene);
  20290. /**
  20291. * Releases all associated resources
  20292. */
  20293. dispose(): void;
  20294. /**
  20295. * Gets hosting scene
  20296. * @returns the hosting scene
  20297. */
  20298. getScene(): Scene;
  20299. /**
  20300. * Does this action manager handles actions of any of the given triggers
  20301. * @param triggers defines the triggers to be tested
  20302. * @return a boolean indicating whether one (or more) of the triggers is handled
  20303. */
  20304. hasSpecificTriggers(triggers: number[]): boolean;
  20305. /**
  20306. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  20307. * speed.
  20308. * @param triggerA defines the trigger to be tested
  20309. * @param triggerB defines the trigger to be tested
  20310. * @return a boolean indicating whether one (or more) of the triggers is handled
  20311. */
  20312. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  20313. /**
  20314. * Does this action manager handles actions of a given trigger
  20315. * @param trigger defines the trigger to be tested
  20316. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  20317. * @return whether the trigger is handled
  20318. */
  20319. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  20320. /**
  20321. * Does this action manager has pointer triggers
  20322. */
  20323. readonly hasPointerTriggers: boolean;
  20324. /**
  20325. * Does this action manager has pick triggers
  20326. */
  20327. readonly hasPickTriggers: boolean;
  20328. /**
  20329. * Registers an action to this action manager
  20330. * @param action defines the action to be registered
  20331. * @return the action amended (prepared) after registration
  20332. */
  20333. registerAction(action: Action): Nullable<Action>;
  20334. /**
  20335. * Unregisters an action to this action manager
  20336. * @param action defines the action to be unregistered
  20337. * @return a boolean indicating whether the action has been unregistered
  20338. */
  20339. unregisterAction(action: Action): Boolean;
  20340. /**
  20341. * Process a specific trigger
  20342. * @param trigger defines the trigger to process
  20343. * @param evt defines the event details to be processed
  20344. */
  20345. processTrigger(trigger: number, evt?: IActionEvent): void;
  20346. /** @hidden */
  20347. _getEffectiveTarget(target: any, propertyPath: string): any;
  20348. /** @hidden */
  20349. _getProperty(propertyPath: string): string;
  20350. /**
  20351. * Serialize this manager to a JSON object
  20352. * @param name defines the property name to store this manager
  20353. * @returns a JSON representation of this manager
  20354. */
  20355. serialize(name: string): any;
  20356. /**
  20357. * Creates a new ActionManager from a JSON data
  20358. * @param parsedActions defines the JSON data to read from
  20359. * @param object defines the hosting mesh
  20360. * @param scene defines the hosting scene
  20361. */
  20362. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  20363. /**
  20364. * Get a trigger name by index
  20365. * @param trigger defines the trigger index
  20366. * @returns a trigger name
  20367. */
  20368. static GetTriggerName(trigger: number): string;
  20369. }
  20370. }
  20371. declare module BABYLON {
  20372. /**
  20373. * Class used to represent a sprite
  20374. * @see http://doc.babylonjs.com/babylon101/sprites
  20375. */
  20376. export class Sprite {
  20377. /** defines the name */
  20378. name: string;
  20379. /** Gets or sets the current world position */
  20380. position: Vector3;
  20381. /** Gets or sets the main color */
  20382. color: Color4;
  20383. /** Gets or sets the width */
  20384. width: number;
  20385. /** Gets or sets the height */
  20386. height: number;
  20387. /** Gets or sets rotation angle */
  20388. angle: number;
  20389. /** Gets or sets the cell index in the sprite sheet */
  20390. cellIndex: number;
  20391. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  20392. invertU: number;
  20393. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  20394. invertV: number;
  20395. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  20396. disposeWhenFinishedAnimating: boolean;
  20397. /** Gets the list of attached animations */
  20398. animations: Animation[];
  20399. /** Gets or sets a boolean indicating if the sprite can be picked */
  20400. isPickable: boolean;
  20401. /**
  20402. * Gets or sets the associated action manager
  20403. */
  20404. actionManager: Nullable<ActionManager>;
  20405. private _animationStarted;
  20406. private _loopAnimation;
  20407. private _fromIndex;
  20408. private _toIndex;
  20409. private _delay;
  20410. private _direction;
  20411. private _manager;
  20412. private _time;
  20413. private _onAnimationEnd;
  20414. /**
  20415. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  20416. */
  20417. isVisible: boolean;
  20418. /**
  20419. * Gets or sets the sprite size
  20420. */
  20421. size: number;
  20422. /**
  20423. * Creates a new Sprite
  20424. * @param name defines the name
  20425. * @param manager defines the manager
  20426. */
  20427. constructor(
  20428. /** defines the name */
  20429. name: string, manager: ISpriteManager);
  20430. /**
  20431. * Starts an animation
  20432. * @param from defines the initial key
  20433. * @param to defines the end key
  20434. * @param loop defines if the animation must loop
  20435. * @param delay defines the start delay (in ms)
  20436. * @param onAnimationEnd defines a callback to call when animation ends
  20437. */
  20438. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  20439. /** Stops current animation (if any) */
  20440. stopAnimation(): void;
  20441. /** @hidden */
  20442. _animate(deltaTime: number): void;
  20443. /** Release associated resources */
  20444. dispose(): void;
  20445. }
  20446. }
  20447. declare module BABYLON {
  20448. /**
  20449. * Information about the result of picking within a scene
  20450. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  20451. */
  20452. export class PickingInfo {
  20453. /**
  20454. * If the pick collided with an object
  20455. */
  20456. hit: boolean;
  20457. /**
  20458. * Distance away where the pick collided
  20459. */
  20460. distance: number;
  20461. /**
  20462. * The location of pick collision
  20463. */
  20464. pickedPoint: Nullable<Vector3>;
  20465. /**
  20466. * The mesh corresponding the the pick collision
  20467. */
  20468. pickedMesh: Nullable<AbstractMesh>;
  20469. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  20470. bu: number;
  20471. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  20472. bv: number;
  20473. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  20474. faceId: number;
  20475. /** Id of the the submesh that was picked */
  20476. subMeshId: number;
  20477. /** If a sprite was picked, this will be the sprite the pick collided with */
  20478. pickedSprite: Nullable<Sprite>;
  20479. /**
  20480. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  20481. */
  20482. originMesh: Nullable<AbstractMesh>;
  20483. /**
  20484. * The ray that was used to perform the picking.
  20485. */
  20486. ray: Nullable<Ray>;
  20487. /**
  20488. * Gets the normal correspodning to the face the pick collided with
  20489. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  20490. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  20491. * @returns The normal correspodning to the face the pick collided with
  20492. */
  20493. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  20494. /**
  20495. * Gets the texture coordinates of where the pick occured
  20496. * @returns the vector containing the coordnates of the texture
  20497. */
  20498. getTextureCoordinates(): Nullable<Vector2>;
  20499. }
  20500. }
  20501. declare module BABYLON {
  20502. /**
  20503. * Class representing a ray with position and direction
  20504. */
  20505. export class Ray {
  20506. /** origin point */
  20507. origin: Vector3;
  20508. /** direction */
  20509. direction: Vector3;
  20510. /** length of the ray */
  20511. length: number;
  20512. private static readonly TmpVector3;
  20513. private _tmpRay;
  20514. /**
  20515. * Creates a new ray
  20516. * @param origin origin point
  20517. * @param direction direction
  20518. * @param length length of the ray
  20519. */
  20520. constructor(
  20521. /** origin point */
  20522. origin: Vector3,
  20523. /** direction */
  20524. direction: Vector3,
  20525. /** length of the ray */
  20526. length?: number);
  20527. /**
  20528. * Checks if the ray intersects a box
  20529. * @param minimum bound of the box
  20530. * @param maximum bound of the box
  20531. * @param intersectionTreshold extra extend to be added to the box in all direction
  20532. * @returns if the box was hit
  20533. */
  20534. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  20535. /**
  20536. * Checks if the ray intersects a box
  20537. * @param box the bounding box to check
  20538. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  20539. * @returns if the box was hit
  20540. */
  20541. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  20542. /**
  20543. * If the ray hits a sphere
  20544. * @param sphere the bounding sphere to check
  20545. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  20546. * @returns true if it hits the sphere
  20547. */
  20548. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  20549. /**
  20550. * If the ray hits a triange
  20551. * @param vertex0 triangle vertex
  20552. * @param vertex1 triangle vertex
  20553. * @param vertex2 triangle vertex
  20554. * @returns intersection information if hit
  20555. */
  20556. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  20557. /**
  20558. * Checks if ray intersects a plane
  20559. * @param plane the plane to check
  20560. * @returns the distance away it was hit
  20561. */
  20562. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  20563. /**
  20564. * Checks if ray intersects a mesh
  20565. * @param mesh the mesh to check
  20566. * @param fastCheck if only the bounding box should checked
  20567. * @returns picking info of the intersecton
  20568. */
  20569. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  20570. /**
  20571. * Checks if ray intersects a mesh
  20572. * @param meshes the meshes to check
  20573. * @param fastCheck if only the bounding box should checked
  20574. * @param results array to store result in
  20575. * @returns Array of picking infos
  20576. */
  20577. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  20578. private _comparePickingInfo;
  20579. private static smallnum;
  20580. private static rayl;
  20581. /**
  20582. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  20583. * @param sega the first point of the segment to test the intersection against
  20584. * @param segb the second point of the segment to test the intersection against
  20585. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  20586. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  20587. */
  20588. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  20589. /**
  20590. * Update the ray from viewport position
  20591. * @param x position
  20592. * @param y y position
  20593. * @param viewportWidth viewport width
  20594. * @param viewportHeight viewport height
  20595. * @param world world matrix
  20596. * @param view view matrix
  20597. * @param projection projection matrix
  20598. * @returns this ray updated
  20599. */
  20600. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  20601. /**
  20602. * Creates a ray with origin and direction of 0,0,0
  20603. * @returns the new ray
  20604. */
  20605. static Zero(): Ray;
  20606. /**
  20607. * Creates a new ray from screen space and viewport
  20608. * @param x position
  20609. * @param y y position
  20610. * @param viewportWidth viewport width
  20611. * @param viewportHeight viewport height
  20612. * @param world world matrix
  20613. * @param view view matrix
  20614. * @param projection projection matrix
  20615. * @returns new ray
  20616. */
  20617. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  20618. /**
  20619. * 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
  20620. * transformed to the given world matrix.
  20621. * @param origin The origin point
  20622. * @param end The end point
  20623. * @param world a matrix to transform the ray to. Default is the identity matrix.
  20624. * @returns the new ray
  20625. */
  20626. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  20627. /**
  20628. * Transforms a ray by a matrix
  20629. * @param ray ray to transform
  20630. * @param matrix matrix to apply
  20631. * @returns the resulting new ray
  20632. */
  20633. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  20634. /**
  20635. * Transforms a ray by a matrix
  20636. * @param ray ray to transform
  20637. * @param matrix matrix to apply
  20638. * @param result ray to store result in
  20639. */
  20640. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  20641. /**
  20642. * Unproject a ray from screen space to object space
  20643. * @param sourceX defines the screen space x coordinate to use
  20644. * @param sourceY defines the screen space y coordinate to use
  20645. * @param viewportWidth defines the current width of the viewport
  20646. * @param viewportHeight defines the current height of the viewport
  20647. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  20648. * @param view defines the view matrix to use
  20649. * @param projection defines the projection matrix to use
  20650. */
  20651. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  20652. }
  20653. }
  20654. declare module BABYLON {
  20655. /**
  20656. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20657. * separate meshes. This can be use to improve performances.
  20658. * @see http://doc.babylonjs.com/how_to/multi_materials
  20659. */
  20660. export class MultiMaterial extends Material {
  20661. private _subMaterials;
  20662. /**
  20663. * Gets or Sets the list of Materials used within the multi material.
  20664. * They need to be ordered according to the submeshes order in the associated mesh
  20665. */
  20666. subMaterials: Nullable<Material>[];
  20667. /**
  20668. * Function used to align with Node.getChildren()
  20669. * @returns the list of Materials used within the multi material
  20670. */
  20671. getChildren(): Nullable<Material>[];
  20672. /**
  20673. * Instantiates a new Multi Material
  20674. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20675. * separate meshes. This can be use to improve performances.
  20676. * @see http://doc.babylonjs.com/how_to/multi_materials
  20677. * @param name Define the name in the scene
  20678. * @param scene Define the scene the material belongs to
  20679. */
  20680. constructor(name: string, scene: Scene);
  20681. private _hookArray;
  20682. /**
  20683. * Get one of the submaterial by its index in the submaterials array
  20684. * @param index The index to look the sub material at
  20685. * @returns The Material if the index has been defined
  20686. */
  20687. getSubMaterial(index: number): Nullable<Material>;
  20688. /**
  20689. * Get the list of active textures for the whole sub materials list.
  20690. * @returns All the textures that will be used during the rendering
  20691. */
  20692. getActiveTextures(): BaseTexture[];
  20693. /**
  20694. * Gets the current class name of the material e.g. "MultiMaterial"
  20695. * Mainly use in serialization.
  20696. * @returns the class name
  20697. */
  20698. getClassName(): string;
  20699. /**
  20700. * Checks if the material is ready to render the requested sub mesh
  20701. * @param mesh Define the mesh the submesh belongs to
  20702. * @param subMesh Define the sub mesh to look readyness for
  20703. * @param useInstances Define whether or not the material is used with instances
  20704. * @returns true if ready, otherwise false
  20705. */
  20706. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20707. /**
  20708. * Clones the current material and its related sub materials
  20709. * @param name Define the name of the newly cloned material
  20710. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20711. * @returns the cloned material
  20712. */
  20713. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20714. /**
  20715. * Serializes the materials into a JSON representation.
  20716. * @returns the JSON representation
  20717. */
  20718. serialize(): any;
  20719. /**
  20720. * Dispose the material and release its associated resources
  20721. * @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)
  20722. * @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)
  20723. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  20724. */
  20725. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20726. /**
  20727. * Creates a MultiMaterial from parsed MultiMaterial data.
  20728. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20729. * @param scene defines the hosting scene
  20730. * @returns a new MultiMaterial
  20731. */
  20732. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20733. }
  20734. }
  20735. declare module BABYLON {
  20736. /**
  20737. * Base class for submeshes
  20738. */
  20739. export class BaseSubMesh {
  20740. /** @hidden */
  20741. _materialDefines: Nullable<MaterialDefines>;
  20742. /** @hidden */
  20743. _materialEffect: Nullable<Effect>;
  20744. /**
  20745. * Gets associated effect
  20746. */
  20747. readonly effect: Nullable<Effect>;
  20748. /**
  20749. * Sets associated effect (effect used to render this submesh)
  20750. * @param effect defines the effect to associate with
  20751. * @param defines defines the set of defines used to compile this effect
  20752. */
  20753. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20754. }
  20755. /**
  20756. * Defines a subdivision inside a mesh
  20757. */
  20758. export class SubMesh extends BaseSubMesh implements ICullable {
  20759. /** the material index to use */
  20760. materialIndex: number;
  20761. /** vertex index start */
  20762. verticesStart: number;
  20763. /** vertices count */
  20764. verticesCount: number;
  20765. /** index start */
  20766. indexStart: number;
  20767. /** indices count */
  20768. indexCount: number;
  20769. /** @hidden */
  20770. _linesIndexCount: number;
  20771. private _mesh;
  20772. private _renderingMesh;
  20773. private _boundingInfo;
  20774. private _linesIndexBuffer;
  20775. /** @hidden */
  20776. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20777. /** @hidden */
  20778. _trianglePlanes: Plane[];
  20779. /** @hidden */
  20780. _lastColliderTransformMatrix: Matrix;
  20781. /** @hidden */
  20782. _renderId: number;
  20783. /** @hidden */
  20784. _alphaIndex: number;
  20785. /** @hidden */
  20786. _distanceToCamera: number;
  20787. /** @hidden */
  20788. _id: number;
  20789. private _currentMaterial;
  20790. /**
  20791. * Add a new submesh to a mesh
  20792. * @param materialIndex defines the material index to use
  20793. * @param verticesStart defines vertex index start
  20794. * @param verticesCount defines vertices count
  20795. * @param indexStart defines index start
  20796. * @param indexCount defines indices count
  20797. * @param mesh defines the parent mesh
  20798. * @param renderingMesh defines an optional rendering mesh
  20799. * @param createBoundingBox defines if bounding box should be created for this submesh
  20800. * @returns the new submesh
  20801. */
  20802. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20803. /**
  20804. * Creates a new submesh
  20805. * @param materialIndex defines the material index to use
  20806. * @param verticesStart defines vertex index start
  20807. * @param verticesCount defines vertices count
  20808. * @param indexStart defines index start
  20809. * @param indexCount defines indices count
  20810. * @param mesh defines the parent mesh
  20811. * @param renderingMesh defines an optional rendering mesh
  20812. * @param createBoundingBox defines if bounding box should be created for this submesh
  20813. */
  20814. constructor(
  20815. /** the material index to use */
  20816. materialIndex: number,
  20817. /** vertex index start */
  20818. verticesStart: number,
  20819. /** vertices count */
  20820. verticesCount: number,
  20821. /** index start */
  20822. indexStart: number,
  20823. /** indices count */
  20824. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20825. /**
  20826. * Returns true if this submesh covers the entire parent mesh
  20827. * @ignorenaming
  20828. */
  20829. readonly IsGlobal: boolean;
  20830. /**
  20831. * Returns the submesh BoudingInfo object
  20832. * @returns current bounding info (or mesh's one if the submesh is global)
  20833. */
  20834. getBoundingInfo(): BoundingInfo;
  20835. /**
  20836. * Sets the submesh BoundingInfo
  20837. * @param boundingInfo defines the new bounding info to use
  20838. * @returns the SubMesh
  20839. */
  20840. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20841. /**
  20842. * Returns the mesh of the current submesh
  20843. * @return the parent mesh
  20844. */
  20845. getMesh(): AbstractMesh;
  20846. /**
  20847. * Returns the rendering mesh of the submesh
  20848. * @returns the rendering mesh (could be different from parent mesh)
  20849. */
  20850. getRenderingMesh(): Mesh;
  20851. /**
  20852. * Returns the submesh material
  20853. * @returns null or the current material
  20854. */
  20855. getMaterial(): Nullable<Material>;
  20856. /**
  20857. * Sets a new updated BoundingInfo object to the submesh
  20858. * @returns the SubMesh
  20859. */
  20860. refreshBoundingInfo(): SubMesh;
  20861. /** @hidden */
  20862. _checkCollision(collider: Collider): boolean;
  20863. /**
  20864. * Updates the submesh BoundingInfo
  20865. * @param world defines the world matrix to use to update the bounding info
  20866. * @returns the submesh
  20867. */
  20868. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20869. /**
  20870. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20871. * @param frustumPlanes defines the frustum planes
  20872. * @returns true if the submesh is intersecting with the frustum
  20873. */
  20874. isInFrustum(frustumPlanes: Plane[]): boolean;
  20875. /**
  20876. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20877. * @param frustumPlanes defines the frustum planes
  20878. * @returns true if the submesh is inside the frustum
  20879. */
  20880. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20881. /**
  20882. * Renders the submesh
  20883. * @param enableAlphaMode defines if alpha needs to be used
  20884. * @returns the submesh
  20885. */
  20886. render(enableAlphaMode: boolean): SubMesh;
  20887. /**
  20888. * @hidden
  20889. */
  20890. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  20891. /**
  20892. * Checks if the submesh intersects with a ray
  20893. * @param ray defines the ray to test
  20894. * @returns true is the passed ray intersects the submesh bounding box
  20895. */
  20896. canIntersects(ray: Ray): boolean;
  20897. /**
  20898. * Intersects current submesh with a ray
  20899. * @param ray defines the ray to test
  20900. * @param positions defines mesh's positions array
  20901. * @param indices defines mesh's indices array
  20902. * @param fastCheck defines if only bounding info should be used
  20903. * @returns intersection info or null if no intersection
  20904. */
  20905. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  20906. /** @hidden */
  20907. private _intersectLines;
  20908. /** @hidden */
  20909. private _intersectTriangles;
  20910. /** @hidden */
  20911. _rebuild(): void;
  20912. /**
  20913. * Creates a new submesh from the passed mesh
  20914. * @param newMesh defines the new hosting mesh
  20915. * @param newRenderingMesh defines an optional rendering mesh
  20916. * @returns the new submesh
  20917. */
  20918. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20919. /**
  20920. * Release associated resources
  20921. */
  20922. dispose(): void;
  20923. /**
  20924. * Gets the class name
  20925. * @returns the string "SubMesh".
  20926. */
  20927. getClassName(): string;
  20928. /**
  20929. * Creates a new submesh from indices data
  20930. * @param materialIndex the index of the main mesh material
  20931. * @param startIndex the index where to start the copy in the mesh indices array
  20932. * @param indexCount the number of indices to copy then from the startIndex
  20933. * @param mesh the main mesh to create the submesh from
  20934. * @param renderingMesh the optional rendering mesh
  20935. * @returns a new submesh
  20936. */
  20937. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20938. }
  20939. }
  20940. declare module BABYLON {
  20941. /**
  20942. * Class used to store geometry data (vertex buffers + index buffer)
  20943. */
  20944. export class Geometry implements IGetSetVerticesData {
  20945. /**
  20946. * Gets or sets the ID of the geometry
  20947. */
  20948. id: string;
  20949. /**
  20950. * Gets or sets the unique ID of the geometry
  20951. */
  20952. uniqueId: number;
  20953. /**
  20954. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20955. */
  20956. delayLoadState: number;
  20957. /**
  20958. * Gets the file containing the data to load when running in delay load state
  20959. */
  20960. delayLoadingFile: Nullable<string>;
  20961. /**
  20962. * Callback called when the geometry is updated
  20963. */
  20964. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20965. private _scene;
  20966. private _engine;
  20967. private _meshes;
  20968. private _totalVertices;
  20969. /** @hidden */
  20970. _indices: IndicesArray;
  20971. /** @hidden */
  20972. _vertexBuffers: {
  20973. [key: string]: VertexBuffer;
  20974. };
  20975. private _isDisposed;
  20976. private _extend;
  20977. private _boundingBias;
  20978. /** @hidden */
  20979. _delayInfo: Array<string>;
  20980. private _indexBuffer;
  20981. private _indexBufferIsUpdatable;
  20982. /** @hidden */
  20983. _boundingInfo: Nullable<BoundingInfo>;
  20984. /** @hidden */
  20985. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20986. /** @hidden */
  20987. _softwareSkinningFrameId: number;
  20988. private _vertexArrayObjects;
  20989. private _updatable;
  20990. /** @hidden */
  20991. _positions: Nullable<Vector3[]>;
  20992. /**
  20993. * 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
  20994. */
  20995. /**
  20996. * 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
  20997. */
  20998. boundingBias: Vector2;
  20999. /**
  21000. * Static function used to attach a new empty geometry to a mesh
  21001. * @param mesh defines the mesh to attach the geometry to
  21002. * @returns the new Geometry
  21003. */
  21004. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21005. /**
  21006. * Creates a new geometry
  21007. * @param id defines the unique ID
  21008. * @param scene defines the hosting scene
  21009. * @param vertexData defines the VertexData used to get geometry data
  21010. * @param updatable defines if geometry must be updatable (false by default)
  21011. * @param mesh defines the mesh that will be associated with the geometry
  21012. */
  21013. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21014. /**
  21015. * Gets the current extend of the geometry
  21016. */
  21017. readonly extend: {
  21018. minimum: Vector3;
  21019. maximum: Vector3;
  21020. };
  21021. /**
  21022. * Gets the hosting scene
  21023. * @returns the hosting Scene
  21024. */
  21025. getScene(): Scene;
  21026. /**
  21027. * Gets the hosting engine
  21028. * @returns the hosting Engine
  21029. */
  21030. getEngine(): Engine;
  21031. /**
  21032. * Defines if the geometry is ready to use
  21033. * @returns true if the geometry is ready to be used
  21034. */
  21035. isReady(): boolean;
  21036. /**
  21037. * Gets a value indicating that the geometry should not be serialized
  21038. */
  21039. readonly doNotSerialize: boolean;
  21040. /** @hidden */
  21041. _rebuild(): void;
  21042. /**
  21043. * Affects all geometry data in one call
  21044. * @param vertexData defines the geometry data
  21045. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21046. */
  21047. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21048. /**
  21049. * Set specific vertex data
  21050. * @param kind defines the data kind (Position, normal, etc...)
  21051. * @param data defines the vertex data to use
  21052. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21053. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21054. */
  21055. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21056. /**
  21057. * Removes a specific vertex data
  21058. * @param kind defines the data kind (Position, normal, etc...)
  21059. */
  21060. removeVerticesData(kind: string): void;
  21061. /**
  21062. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21063. * @param buffer defines the vertex buffer to use
  21064. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21065. */
  21066. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21067. /**
  21068. * Update a specific vertex buffer
  21069. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  21070. * It will do nothing if the buffer is not updatable
  21071. * @param kind defines the data kind (Position, normal, etc...)
  21072. * @param data defines the data to use
  21073. * @param offset defines the offset in the target buffer where to store the data
  21074. * @param useBytes set to true if the offset is in bytes
  21075. */
  21076. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21077. /**
  21078. * Update a specific vertex buffer
  21079. * This function will create a new buffer if the current one is not updatable
  21080. * @param kind defines the data kind (Position, normal, etc...)
  21081. * @param data defines the data to use
  21082. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21083. */
  21084. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21085. private _updateBoundingInfo;
  21086. /** @hidden */
  21087. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  21088. /**
  21089. * Gets total number of vertices
  21090. * @returns the total number of vertices
  21091. */
  21092. getTotalVertices(): number;
  21093. /**
  21094. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21095. * @param kind defines the data kind (Position, normal, etc...)
  21096. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21097. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21098. * @returns a float array containing vertex data
  21099. */
  21100. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21101. /**
  21102. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21103. * @param kind defines the data kind (Position, normal, etc...)
  21104. * @returns true if the vertex buffer with the specified kind is updatable
  21105. */
  21106. isVertexBufferUpdatable(kind: string): boolean;
  21107. /**
  21108. * Gets a specific vertex buffer
  21109. * @param kind defines the data kind (Position, normal, etc...)
  21110. * @returns a VertexBuffer
  21111. */
  21112. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21113. /**
  21114. * Returns all vertex buffers
  21115. * @return an object holding all vertex buffers indexed by kind
  21116. */
  21117. getVertexBuffers(): Nullable<{
  21118. [key: string]: VertexBuffer;
  21119. }>;
  21120. /**
  21121. * Gets a boolean indicating if specific vertex buffer is present
  21122. * @param kind defines the data kind (Position, normal, etc...)
  21123. * @returns true if data is present
  21124. */
  21125. isVerticesDataPresent(kind: string): boolean;
  21126. /**
  21127. * Gets a list of all attached data kinds (Position, normal, etc...)
  21128. * @returns a list of string containing all kinds
  21129. */
  21130. getVerticesDataKinds(): string[];
  21131. /**
  21132. * Update index buffer
  21133. * @param indices defines the indices to store in the index buffer
  21134. * @param offset defines the offset in the target buffer where to store the data
  21135. */
  21136. updateIndices(indices: IndicesArray, offset?: number): void;
  21137. /**
  21138. * Creates a new index buffer
  21139. * @param indices defines the indices to store in the index buffer
  21140. * @param totalVertices defines the total number of vertices (could be null)
  21141. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21142. */
  21143. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21144. /**
  21145. * Return the total number of indices
  21146. * @returns the total number of indices
  21147. */
  21148. getTotalIndices(): number;
  21149. /**
  21150. * Gets the index buffer array
  21151. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21152. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21153. * @returns the index buffer array
  21154. */
  21155. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21156. /**
  21157. * Gets the index buffer
  21158. * @return the index buffer
  21159. */
  21160. getIndexBuffer(): Nullable<WebGLBuffer>;
  21161. /** @hidden */
  21162. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21163. /**
  21164. * Release the associated resources for a specific mesh
  21165. * @param mesh defines the source mesh
  21166. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21167. */
  21168. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21169. /**
  21170. * Apply current geometry to a given mesh
  21171. * @param mesh defines the mesh to apply geometry to
  21172. */
  21173. applyToMesh(mesh: Mesh): void;
  21174. private _updateExtend;
  21175. private _applyToMesh;
  21176. private notifyUpdate;
  21177. /**
  21178. * Load the geometry if it was flagged as delay loaded
  21179. * @param scene defines the hosting scene
  21180. * @param onLoaded defines a callback called when the geometry is loaded
  21181. */
  21182. load(scene: Scene, onLoaded?: () => void): void;
  21183. private _queueLoad;
  21184. /**
  21185. * Invert the geometry to move from a right handed system to a left handed one.
  21186. */
  21187. toLeftHanded(): void;
  21188. /** @hidden */
  21189. _resetPointsArrayCache(): void;
  21190. /** @hidden */
  21191. _generatePointsArray(): boolean;
  21192. /**
  21193. * Gets a value indicating if the geometry is disposed
  21194. * @returns true if the geometry was disposed
  21195. */
  21196. isDisposed(): boolean;
  21197. private _disposeVertexArrayObjects;
  21198. /**
  21199. * Free all associated resources
  21200. */
  21201. dispose(): void;
  21202. /**
  21203. * Clone the current geometry into a new geometry
  21204. * @param id defines the unique ID of the new geometry
  21205. * @returns a new geometry object
  21206. */
  21207. copy(id: string): Geometry;
  21208. /**
  21209. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21210. * @return a JSON representation of the current geometry data (without the vertices data)
  21211. */
  21212. serialize(): any;
  21213. private toNumberArray;
  21214. /**
  21215. * Serialize all vertices data into a JSON oject
  21216. * @returns a JSON representation of the current geometry data
  21217. */
  21218. serializeVerticeData(): any;
  21219. /**
  21220. * Extracts a clone of a mesh geometry
  21221. * @param mesh defines the source mesh
  21222. * @param id defines the unique ID of the new geometry object
  21223. * @returns the new geometry object
  21224. */
  21225. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21226. /**
  21227. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21228. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21229. * Be aware Math.random() could cause collisions, but:
  21230. * "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"
  21231. * @returns a string containing a new GUID
  21232. */
  21233. static RandomId(): string;
  21234. /** @hidden */
  21235. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21236. private static _CleanMatricesWeights;
  21237. /**
  21238. * Create a new geometry from persisted data (Using .babylon file format)
  21239. * @param parsedVertexData defines the persisted data
  21240. * @param scene defines the hosting scene
  21241. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21242. * @returns the new geometry object
  21243. */
  21244. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21245. }
  21246. }
  21247. declare module BABYLON {
  21248. /**
  21249. * Define an interface for all classes that will get and set the data on vertices
  21250. */
  21251. export interface IGetSetVerticesData {
  21252. /**
  21253. * Gets a boolean indicating if specific vertex data is present
  21254. * @param kind defines the vertex data kind to use
  21255. * @returns true is data kind is present
  21256. */
  21257. isVerticesDataPresent(kind: string): boolean;
  21258. /**
  21259. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21260. * @param kind defines the data kind (Position, normal, etc...)
  21261. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21262. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21263. * @returns a float array containing vertex data
  21264. */
  21265. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21266. /**
  21267. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21268. * @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.
  21269. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21270. * @returns the indices array or an empty array if the mesh has no geometry
  21271. */
  21272. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21273. /**
  21274. * Set specific vertex data
  21275. * @param kind defines the data kind (Position, normal, etc...)
  21276. * @param data defines the vertex data to use
  21277. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21278. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21279. */
  21280. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21281. /**
  21282. * Update a specific associated vertex buffer
  21283. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21284. * - VertexBuffer.PositionKind
  21285. * - VertexBuffer.UVKind
  21286. * - VertexBuffer.UV2Kind
  21287. * - VertexBuffer.UV3Kind
  21288. * - VertexBuffer.UV4Kind
  21289. * - VertexBuffer.UV5Kind
  21290. * - VertexBuffer.UV6Kind
  21291. * - VertexBuffer.ColorKind
  21292. * - VertexBuffer.MatricesIndicesKind
  21293. * - VertexBuffer.MatricesIndicesExtraKind
  21294. * - VertexBuffer.MatricesWeightsKind
  21295. * - VertexBuffer.MatricesWeightsExtraKind
  21296. * @param data defines the data source
  21297. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21298. * @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)
  21299. */
  21300. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21301. /**
  21302. * Creates a new index buffer
  21303. * @param indices defines the indices to store in the index buffer
  21304. * @param totalVertices defines the total number of vertices (could be null)
  21305. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21306. */
  21307. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21308. }
  21309. /**
  21310. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21311. */
  21312. export class VertexData {
  21313. /**
  21314. * Mesh side orientation : usually the external or front surface
  21315. */
  21316. static readonly FRONTSIDE: number;
  21317. /**
  21318. * Mesh side orientation : usually the internal or back surface
  21319. */
  21320. static readonly BACKSIDE: number;
  21321. /**
  21322. * Mesh side orientation : both internal and external or front and back surfaces
  21323. */
  21324. static readonly DOUBLESIDE: number;
  21325. /**
  21326. * Mesh side orientation : by default, `FRONTSIDE`
  21327. */
  21328. static readonly DEFAULTSIDE: number;
  21329. /**
  21330. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21331. */
  21332. positions: Nullable<FloatArray>;
  21333. /**
  21334. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21335. */
  21336. normals: Nullable<FloatArray>;
  21337. /**
  21338. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21339. */
  21340. tangents: Nullable<FloatArray>;
  21341. /**
  21342. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21343. */
  21344. uvs: Nullable<FloatArray>;
  21345. /**
  21346. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21347. */
  21348. uvs2: Nullable<FloatArray>;
  21349. /**
  21350. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21351. */
  21352. uvs3: Nullable<FloatArray>;
  21353. /**
  21354. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21355. */
  21356. uvs4: Nullable<FloatArray>;
  21357. /**
  21358. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21359. */
  21360. uvs5: Nullable<FloatArray>;
  21361. /**
  21362. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21363. */
  21364. uvs6: Nullable<FloatArray>;
  21365. /**
  21366. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21367. */
  21368. colors: Nullable<FloatArray>;
  21369. /**
  21370. * 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).
  21371. */
  21372. matricesIndices: Nullable<FloatArray>;
  21373. /**
  21374. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21375. */
  21376. matricesWeights: Nullable<FloatArray>;
  21377. /**
  21378. * An array extending the number of possible indices
  21379. */
  21380. matricesIndicesExtra: Nullable<FloatArray>;
  21381. /**
  21382. * An array extending the number of possible weights when the number of indices is extended
  21383. */
  21384. matricesWeightsExtra: Nullable<FloatArray>;
  21385. /**
  21386. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21387. */
  21388. indices: Nullable<IndicesArray>;
  21389. /**
  21390. * Uses the passed data array to set the set the values for the specified kind of data
  21391. * @param data a linear array of floating numbers
  21392. * @param kind the type of data that is being set, eg positions, colors etc
  21393. */
  21394. set(data: FloatArray, kind: string): void;
  21395. /**
  21396. * Associates the vertexData to the passed Mesh.
  21397. * Sets it as updatable or not (default `false`)
  21398. * @param mesh the mesh the vertexData is applied to
  21399. * @param updatable when used and having the value true allows new data to update the vertexData
  21400. * @returns the VertexData
  21401. */
  21402. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21403. /**
  21404. * Associates the vertexData to the passed Geometry.
  21405. * Sets it as updatable or not (default `false`)
  21406. * @param geometry the geometry the vertexData is applied to
  21407. * @param updatable when used and having the value true allows new data to update the vertexData
  21408. * @returns VertexData
  21409. */
  21410. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21411. /**
  21412. * Updates the associated mesh
  21413. * @param mesh the mesh to be updated
  21414. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21415. * @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
  21416. * @returns VertexData
  21417. */
  21418. updateMesh(mesh: Mesh): VertexData;
  21419. /**
  21420. * Updates the associated geometry
  21421. * @param geometry the geometry to be updated
  21422. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21423. * @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
  21424. * @returns VertexData.
  21425. */
  21426. updateGeometry(geometry: Geometry): VertexData;
  21427. private _applyTo;
  21428. private _update;
  21429. /**
  21430. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21431. * @param matrix the transforming matrix
  21432. * @returns the VertexData
  21433. */
  21434. transform(matrix: Matrix): VertexData;
  21435. /**
  21436. * Merges the passed VertexData into the current one
  21437. * @param other the VertexData to be merged into the current one
  21438. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21439. * @returns the modified VertexData
  21440. */
  21441. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21442. private _mergeElement;
  21443. private _validate;
  21444. /**
  21445. * Serializes the VertexData
  21446. * @returns a serialized object
  21447. */
  21448. serialize(): any;
  21449. /**
  21450. * Extracts the vertexData from a mesh
  21451. * @param mesh the mesh from which to extract the VertexData
  21452. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21453. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21454. * @returns the object VertexData associated to the passed mesh
  21455. */
  21456. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21457. /**
  21458. * Extracts the vertexData from the geometry
  21459. * @param geometry the geometry from which to extract the VertexData
  21460. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21461. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21462. * @returns the object VertexData associated to the passed mesh
  21463. */
  21464. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21465. private static _ExtractFrom;
  21466. /**
  21467. * Creates the VertexData for a Ribbon
  21468. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21469. * * pathArray array of paths, each of which an array of successive Vector3
  21470. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21471. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21472. * * 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
  21473. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21474. * * 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)
  21475. * * 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)
  21476. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21477. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21478. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21479. * @returns the VertexData of the ribbon
  21480. */
  21481. static CreateRibbon(options: {
  21482. pathArray: Vector3[][];
  21483. closeArray?: boolean;
  21484. closePath?: boolean;
  21485. offset?: number;
  21486. sideOrientation?: number;
  21487. frontUVs?: Vector4;
  21488. backUVs?: Vector4;
  21489. invertUV?: boolean;
  21490. uvs?: Vector2[];
  21491. colors?: Color4[];
  21492. }): VertexData;
  21493. /**
  21494. * Creates the VertexData for a box
  21495. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21496. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21497. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21498. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21499. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21500. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21501. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21502. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21503. * * 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)
  21504. * * 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)
  21505. * @returns the VertexData of the box
  21506. */
  21507. static CreateBox(options: {
  21508. size?: number;
  21509. width?: number;
  21510. height?: number;
  21511. depth?: number;
  21512. faceUV?: Vector4[];
  21513. faceColors?: Color4[];
  21514. sideOrientation?: number;
  21515. frontUVs?: Vector4;
  21516. backUVs?: Vector4;
  21517. }): VertexData;
  21518. /**
  21519. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21520. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21521. * * segments sets the number of horizontal strips optional, default 32
  21522. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21523. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21524. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21525. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21526. * * 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
  21527. * * 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
  21528. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21529. * * 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)
  21530. * * 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)
  21531. * @returns the VertexData of the ellipsoid
  21532. */
  21533. static CreateSphere(options: {
  21534. segments?: number;
  21535. diameter?: number;
  21536. diameterX?: number;
  21537. diameterY?: number;
  21538. diameterZ?: number;
  21539. arc?: number;
  21540. slice?: number;
  21541. sideOrientation?: number;
  21542. frontUVs?: Vector4;
  21543. backUVs?: Vector4;
  21544. }): VertexData;
  21545. /**
  21546. * Creates the VertexData for a cylinder, cone or prism
  21547. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21548. * * height sets the height (y direction) of the cylinder, optional, default 2
  21549. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21550. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21551. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21552. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21553. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21554. * * 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
  21555. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21556. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21557. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21558. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21559. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21560. * * 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)
  21561. * * 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)
  21562. * @returns the VertexData of the cylinder, cone or prism
  21563. */
  21564. static CreateCylinder(options: {
  21565. height?: number;
  21566. diameterTop?: number;
  21567. diameterBottom?: number;
  21568. diameter?: number;
  21569. tessellation?: number;
  21570. subdivisions?: number;
  21571. arc?: number;
  21572. faceColors?: Color4[];
  21573. faceUV?: Vector4[];
  21574. hasRings?: boolean;
  21575. enclose?: boolean;
  21576. sideOrientation?: number;
  21577. frontUVs?: Vector4;
  21578. backUVs?: Vector4;
  21579. }): VertexData;
  21580. /**
  21581. * Creates the VertexData for a torus
  21582. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21583. * * diameter the diameter of the torus, optional default 1
  21584. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21585. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21586. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21587. * * 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)
  21588. * * 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)
  21589. * @returns the VertexData of the torus
  21590. */
  21591. static CreateTorus(options: {
  21592. diameter?: number;
  21593. thickness?: number;
  21594. tessellation?: number;
  21595. sideOrientation?: number;
  21596. frontUVs?: Vector4;
  21597. backUVs?: Vector4;
  21598. }): VertexData;
  21599. /**
  21600. * Creates the VertexData of the LineSystem
  21601. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21602. * - lines an array of lines, each line being an array of successive Vector3
  21603. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21604. * @returns the VertexData of the LineSystem
  21605. */
  21606. static CreateLineSystem(options: {
  21607. lines: Vector3[][];
  21608. colors?: Nullable<Color4[][]>;
  21609. }): VertexData;
  21610. /**
  21611. * Create the VertexData for a DashedLines
  21612. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21613. * - points an array successive Vector3
  21614. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21615. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21616. * - dashNb the intended total number of dashes, optional, default 200
  21617. * @returns the VertexData for the DashedLines
  21618. */
  21619. static CreateDashedLines(options: {
  21620. points: Vector3[];
  21621. dashSize?: number;
  21622. gapSize?: number;
  21623. dashNb?: number;
  21624. }): VertexData;
  21625. /**
  21626. * Creates the VertexData for a Ground
  21627. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21628. * - width the width (x direction) of the ground, optional, default 1
  21629. * - height the height (z direction) of the ground, optional, default 1
  21630. * - subdivisions the number of subdivisions per side, optional, default 1
  21631. * @returns the VertexData of the Ground
  21632. */
  21633. static CreateGround(options: {
  21634. width?: number;
  21635. height?: number;
  21636. subdivisions?: number;
  21637. subdivisionsX?: number;
  21638. subdivisionsY?: number;
  21639. }): VertexData;
  21640. /**
  21641. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21642. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21643. * * xmin the ground minimum X coordinate, optional, default -1
  21644. * * zmin the ground minimum Z coordinate, optional, default -1
  21645. * * xmax the ground maximum X coordinate, optional, default 1
  21646. * * zmax the ground maximum Z coordinate, optional, default 1
  21647. * * 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}
  21648. * * 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}
  21649. * @returns the VertexData of the TiledGround
  21650. */
  21651. static CreateTiledGround(options: {
  21652. xmin: number;
  21653. zmin: number;
  21654. xmax: number;
  21655. zmax: number;
  21656. subdivisions?: {
  21657. w: number;
  21658. h: number;
  21659. };
  21660. precision?: {
  21661. w: number;
  21662. h: number;
  21663. };
  21664. }): VertexData;
  21665. /**
  21666. * Creates the VertexData of the Ground designed from a heightmap
  21667. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21668. * * width the width (x direction) of the ground
  21669. * * height the height (z direction) of the ground
  21670. * * subdivisions the number of subdivisions per side
  21671. * * minHeight the minimum altitude on the ground, optional, default 0
  21672. * * maxHeight the maximum altitude on the ground, optional default 1
  21673. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21674. * * buffer the array holding the image color data
  21675. * * bufferWidth the width of image
  21676. * * bufferHeight the height of image
  21677. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21678. * @returns the VertexData of the Ground designed from a heightmap
  21679. */
  21680. static CreateGroundFromHeightMap(options: {
  21681. width: number;
  21682. height: number;
  21683. subdivisions: number;
  21684. minHeight: number;
  21685. maxHeight: number;
  21686. colorFilter: Color3;
  21687. buffer: Uint8Array;
  21688. bufferWidth: number;
  21689. bufferHeight: number;
  21690. alphaFilter: number;
  21691. }): VertexData;
  21692. /**
  21693. * Creates the VertexData for a Plane
  21694. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21695. * * size sets the width and height of the plane to the value of size, optional default 1
  21696. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21697. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21698. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21699. * * 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)
  21700. * * 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)
  21701. * @returns the VertexData of the box
  21702. */
  21703. static CreatePlane(options: {
  21704. size?: number;
  21705. width?: number;
  21706. height?: number;
  21707. sideOrientation?: number;
  21708. frontUVs?: Vector4;
  21709. backUVs?: Vector4;
  21710. }): VertexData;
  21711. /**
  21712. * Creates the VertexData of the Disc or regular Polygon
  21713. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21714. * * radius the radius of the disc, optional default 0.5
  21715. * * tessellation the number of polygon sides, optional, default 64
  21716. * * 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
  21717. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21718. * * 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)
  21719. * * 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)
  21720. * @returns the VertexData of the box
  21721. */
  21722. static CreateDisc(options: {
  21723. radius?: number;
  21724. tessellation?: number;
  21725. arc?: number;
  21726. sideOrientation?: number;
  21727. frontUVs?: Vector4;
  21728. backUVs?: Vector4;
  21729. }): VertexData;
  21730. /**
  21731. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21732. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21733. * @param polygon a mesh built from polygonTriangulation.build()
  21734. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21735. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21736. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21737. * @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)
  21738. * @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)
  21739. * @returns the VertexData of the Polygon
  21740. */
  21741. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21742. /**
  21743. * Creates the VertexData of the IcoSphere
  21744. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21745. * * radius the radius of the IcoSphere, optional default 1
  21746. * * radiusX allows stretching in the x direction, optional, default radius
  21747. * * radiusY allows stretching in the y direction, optional, default radius
  21748. * * radiusZ allows stretching in the z direction, optional, default radius
  21749. * * flat when true creates a flat shaded mesh, optional, default true
  21750. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21751. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21752. * * 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)
  21753. * * 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)
  21754. * @returns the VertexData of the IcoSphere
  21755. */
  21756. static CreateIcoSphere(options: {
  21757. radius?: number;
  21758. radiusX?: number;
  21759. radiusY?: number;
  21760. radiusZ?: number;
  21761. flat?: boolean;
  21762. subdivisions?: number;
  21763. sideOrientation?: number;
  21764. frontUVs?: Vector4;
  21765. backUVs?: Vector4;
  21766. }): VertexData;
  21767. /**
  21768. * Creates the VertexData for a Polyhedron
  21769. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21770. * * type provided types are:
  21771. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21772. * * 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)
  21773. * * size the size of the IcoSphere, optional default 1
  21774. * * sizeX allows stretching in the x direction, optional, default size
  21775. * * sizeY allows stretching in the y direction, optional, default size
  21776. * * sizeZ allows stretching in the z direction, optional, default size
  21777. * * 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
  21778. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21779. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21780. * * flat when true creates a flat shaded mesh, optional, default true
  21781. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21782. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21783. * * 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)
  21784. * * 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)
  21785. * @returns the VertexData of the Polyhedron
  21786. */
  21787. static CreatePolyhedron(options: {
  21788. type?: number;
  21789. size?: number;
  21790. sizeX?: number;
  21791. sizeY?: number;
  21792. sizeZ?: number;
  21793. custom?: any;
  21794. faceUV?: Vector4[];
  21795. faceColors?: Color4[];
  21796. flat?: boolean;
  21797. sideOrientation?: number;
  21798. frontUVs?: Vector4;
  21799. backUVs?: Vector4;
  21800. }): VertexData;
  21801. /**
  21802. * Creates the VertexData for a TorusKnot
  21803. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21804. * * radius the radius of the torus knot, optional, default 2
  21805. * * tube the thickness of the tube, optional, default 0.5
  21806. * * radialSegments the number of sides on each tube segments, optional, default 32
  21807. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21808. * * p the number of windings around the z axis, optional, default 2
  21809. * * q the number of windings around the x axis, optional, default 3
  21810. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21811. * * 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)
  21812. * * 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)
  21813. * @returns the VertexData of the Torus Knot
  21814. */
  21815. static CreateTorusKnot(options: {
  21816. radius?: number;
  21817. tube?: number;
  21818. radialSegments?: number;
  21819. tubularSegments?: number;
  21820. p?: number;
  21821. q?: number;
  21822. sideOrientation?: number;
  21823. frontUVs?: Vector4;
  21824. backUVs?: Vector4;
  21825. }): VertexData;
  21826. /**
  21827. * Compute normals for given positions and indices
  21828. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21829. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21830. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21831. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21832. * * facetNormals : optional array of facet normals (vector3)
  21833. * * facetPositions : optional array of facet positions (vector3)
  21834. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21835. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21836. * * bInfo : optional bounding info, required for facetPartitioning computation
  21837. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21838. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21839. * * useRightHandedSystem: optional boolean to for right handed system computation
  21840. * * depthSort : optional boolean to enable the facet depth sort computation
  21841. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21842. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21843. */
  21844. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21845. facetNormals?: any;
  21846. facetPositions?: any;
  21847. facetPartitioning?: any;
  21848. ratio?: number;
  21849. bInfo?: any;
  21850. bbSize?: Vector3;
  21851. subDiv?: any;
  21852. useRightHandedSystem?: boolean;
  21853. depthSort?: boolean;
  21854. distanceTo?: Vector3;
  21855. depthSortedFacets?: any;
  21856. }): void;
  21857. /** @hidden */
  21858. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21859. /**
  21860. * Applies VertexData created from the imported parameters to the geometry
  21861. * @param parsedVertexData the parsed data from an imported file
  21862. * @param geometry the geometry to apply the VertexData to
  21863. */
  21864. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21865. }
  21866. }
  21867. declare module BABYLON {
  21868. /**
  21869. * Class containing static functions to help procedurally build meshes
  21870. */
  21871. export class DiscBuilder {
  21872. /**
  21873. * Creates a plane polygonal mesh. By default, this is a disc
  21874. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  21875. * * 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
  21876. * * 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
  21877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21878. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  21879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21880. * @param name defines the name of the mesh
  21881. * @param options defines the options used to create the mesh
  21882. * @param scene defines the hosting scene
  21883. * @returns the plane polygonal mesh
  21884. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  21885. */
  21886. static CreateDisc(name: string, options: {
  21887. radius?: number;
  21888. tessellation?: number;
  21889. arc?: number;
  21890. updatable?: boolean;
  21891. sideOrientation?: number;
  21892. frontUVs?: Vector4;
  21893. backUVs?: Vector4;
  21894. }, scene?: Nullable<Scene>): Mesh;
  21895. }
  21896. }
  21897. declare module BABYLON {
  21898. /**
  21899. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  21900. *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.
  21901. * The SPS is also a particle system. It provides some methods to manage the particles.
  21902. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  21903. *
  21904. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  21905. */
  21906. export class SolidParticleSystem implements IDisposable {
  21907. /**
  21908. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  21909. * Example : var p = SPS.particles[i];
  21910. */
  21911. particles: SolidParticle[];
  21912. /**
  21913. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  21914. */
  21915. nbParticles: number;
  21916. /**
  21917. * If the particles must ever face the camera (default false). Useful for planar particles.
  21918. */
  21919. billboard: boolean;
  21920. /**
  21921. * Recompute normals when adding a shape
  21922. */
  21923. recomputeNormals: boolean;
  21924. /**
  21925. * This a counter ofr your own usage. It's not set by any SPS functions.
  21926. */
  21927. counter: number;
  21928. /**
  21929. * The SPS name. This name is also given to the underlying mesh.
  21930. */
  21931. name: string;
  21932. /**
  21933. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  21934. */
  21935. mesh: Mesh;
  21936. /**
  21937. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  21938. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  21939. */
  21940. vars: any;
  21941. /**
  21942. * This array is populated when the SPS is set as 'pickable'.
  21943. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  21944. * Each element of this array is an object `{idx: int, faceId: int}`.
  21945. * `idx` is the picked particle index in the `SPS.particles` array
  21946. * `faceId` is the picked face index counted within this particle.
  21947. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  21948. */
  21949. pickedParticles: {
  21950. idx: number;
  21951. faceId: number;
  21952. }[];
  21953. /**
  21954. * This array is populated when `enableDepthSort` is set to true.
  21955. * Each element of this array is an instance of the class DepthSortedParticle.
  21956. */
  21957. depthSortedParticles: DepthSortedParticle[];
  21958. /**
  21959. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  21960. * @hidden
  21961. */
  21962. _bSphereOnly: boolean;
  21963. /**
  21964. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  21965. * @hidden
  21966. */
  21967. _bSphereRadiusFactor: number;
  21968. private _scene;
  21969. private _positions;
  21970. private _indices;
  21971. private _normals;
  21972. private _colors;
  21973. private _uvs;
  21974. private _indices32;
  21975. private _positions32;
  21976. private _normals32;
  21977. private _fixedNormal32;
  21978. private _colors32;
  21979. private _uvs32;
  21980. private _index;
  21981. private _updatable;
  21982. private _pickable;
  21983. private _isVisibilityBoxLocked;
  21984. private _alwaysVisible;
  21985. private _depthSort;
  21986. private _shapeCounter;
  21987. private _copy;
  21988. private _color;
  21989. private _computeParticleColor;
  21990. private _computeParticleTexture;
  21991. private _computeParticleRotation;
  21992. private _computeParticleVertex;
  21993. private _computeBoundingBox;
  21994. private _depthSortParticles;
  21995. private _camera;
  21996. private _mustUnrotateFixedNormals;
  21997. private _particlesIntersect;
  21998. private _needs32Bits;
  21999. /**
  22000. * Creates a SPS (Solid Particle System) object.
  22001. * @param name (String) is the SPS name, this will be the underlying mesh name.
  22002. * @param scene (Scene) is the scene in which the SPS is added.
  22003. * @param options defines the options of the sps e.g.
  22004. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  22005. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  22006. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  22007. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  22008. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  22009. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  22010. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  22011. */
  22012. constructor(name: string, scene: Scene, options?: {
  22013. updatable?: boolean;
  22014. isPickable?: boolean;
  22015. enableDepthSort?: boolean;
  22016. particleIntersection?: boolean;
  22017. boundingSphereOnly?: boolean;
  22018. bSphereRadiusFactor?: number;
  22019. });
  22020. /**
  22021. * Builds the SPS underlying mesh. Returns a standard Mesh.
  22022. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  22023. * @returns the created mesh
  22024. */
  22025. buildMesh(): Mesh;
  22026. /**
  22027. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  22028. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  22029. * Thus the particles generated from `digest()` have their property `position` set yet.
  22030. * @param mesh ( Mesh ) is the mesh to be digested
  22031. * @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
  22032. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  22033. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  22034. * @returns the current SPS
  22035. */
  22036. digest(mesh: Mesh, options?: {
  22037. facetNb?: number;
  22038. number?: number;
  22039. delta?: number;
  22040. }): SolidParticleSystem;
  22041. private _unrotateFixedNormals;
  22042. private _resetCopy;
  22043. private _meshBuilder;
  22044. private _posToShape;
  22045. private _uvsToShapeUV;
  22046. private _addParticle;
  22047. /**
  22048. * Adds some particles to the SPS from the model shape. Returns the shape id.
  22049. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  22050. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  22051. * @param nb (positive integer) the number of particles to be created from this model
  22052. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  22053. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  22054. * @returns the number of shapes in the system
  22055. */
  22056. addShape(mesh: Mesh, nb: number, options?: {
  22057. positionFunction?: any;
  22058. vertexFunction?: any;
  22059. }): number;
  22060. private _rebuildParticle;
  22061. /**
  22062. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  22063. * @returns the SPS.
  22064. */
  22065. rebuildMesh(): SolidParticleSystem;
  22066. /**
  22067. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  22068. * This method calls `updateParticle()` for each particle of the SPS.
  22069. * For an animated SPS, it is usually called within the render loop.
  22070. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  22071. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  22072. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  22073. * @returns the SPS.
  22074. */
  22075. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  22076. /**
  22077. * Disposes the SPS.
  22078. */
  22079. dispose(): void;
  22080. /**
  22081. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  22082. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22083. * @returns the SPS.
  22084. */
  22085. refreshVisibleSize(): SolidParticleSystem;
  22086. /**
  22087. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  22088. * @param size the size (float) of the visibility box
  22089. * note : this doesn't lock the SPS mesh bounding box.
  22090. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22091. */
  22092. setVisibilityBox(size: number): void;
  22093. /**
  22094. * Gets whether the SPS as always visible or not
  22095. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22096. */
  22097. /**
  22098. * Sets the SPS as always visible or not
  22099. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22100. */
  22101. isAlwaysVisible: boolean;
  22102. /**
  22103. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  22104. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22105. */
  22106. /**
  22107. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  22108. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22109. */
  22110. isVisibilityBoxLocked: boolean;
  22111. /**
  22112. * Tells to `setParticles()` to compute the particle rotations or not.
  22113. * Default value : true. The SPS is faster when it's set to false.
  22114. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  22115. */
  22116. /**
  22117. * Gets if `setParticles()` computes the particle rotations or not.
  22118. * Default value : true. The SPS is faster when it's set to false.
  22119. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  22120. */
  22121. computeParticleRotation: boolean;
  22122. /**
  22123. * Tells to `setParticles()` to compute the particle colors or not.
  22124. * Default value : true. The SPS is faster when it's set to false.
  22125. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  22126. */
  22127. /**
  22128. * Gets if `setParticles()` computes the particle colors or not.
  22129. * Default value : true. The SPS is faster when it's set to false.
  22130. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  22131. */
  22132. computeParticleColor: boolean;
  22133. /**
  22134. * Gets if `setParticles()` computes the particle textures or not.
  22135. * Default value : true. The SPS is faster when it's set to false.
  22136. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  22137. */
  22138. computeParticleTexture: boolean;
  22139. /**
  22140. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  22141. * Default value : false. The SPS is faster when it's set to false.
  22142. * Note : the particle custom vertex positions aren't stored values.
  22143. */
  22144. /**
  22145. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  22146. * Default value : false. The SPS is faster when it's set to false.
  22147. * Note : the particle custom vertex positions aren't stored values.
  22148. */
  22149. computeParticleVertex: boolean;
  22150. /**
  22151. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  22152. */
  22153. /**
  22154. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  22155. */
  22156. computeBoundingBox: boolean;
  22157. /**
  22158. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  22159. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  22160. * Default : `true`
  22161. */
  22162. /**
  22163. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  22164. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  22165. * Default : `true`
  22166. */
  22167. depthSortParticles: boolean;
  22168. /**
  22169. * This function does nothing. It may be overwritten to set all the particle first values.
  22170. * The SPS doesn't call this function, you may have to call it by your own.
  22171. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22172. */
  22173. initParticles(): void;
  22174. /**
  22175. * This function does nothing. It may be overwritten to recycle a particle.
  22176. * The SPS doesn't call this function, you may have to call it by your own.
  22177. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22178. * @param particle The particle to recycle
  22179. * @returns the recycled particle
  22180. */
  22181. recycleParticle(particle: SolidParticle): SolidParticle;
  22182. /**
  22183. * Updates a particle : this function should be overwritten by the user.
  22184. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  22185. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22186. * @example : just set a particle position or velocity and recycle conditions
  22187. * @param particle The particle to update
  22188. * @returns the updated particle
  22189. */
  22190. updateParticle(particle: SolidParticle): SolidParticle;
  22191. /**
  22192. * Updates a vertex of a particle : it can be overwritten by the user.
  22193. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  22194. * @param particle the current particle
  22195. * @param vertex the current index of the current particle
  22196. * @param pt the index of the current vertex in the particle shape
  22197. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  22198. * @example : just set a vertex particle position
  22199. * @returns the updated vertex
  22200. */
  22201. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  22202. /**
  22203. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  22204. * This does nothing and may be overwritten by the user.
  22205. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22206. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22207. * @param update the boolean update value actually passed to setParticles()
  22208. */
  22209. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  22210. /**
  22211. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  22212. * This will be passed three parameters.
  22213. * This does nothing and may be overwritten by the user.
  22214. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22215. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22216. * @param update the boolean update value actually passed to setParticles()
  22217. */
  22218. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  22219. }
  22220. }
  22221. declare module BABYLON {
  22222. /**
  22223. * Represents one particle of a solid particle system.
  22224. */
  22225. export class SolidParticle {
  22226. /**
  22227. * particle global index
  22228. */
  22229. idx: number;
  22230. /**
  22231. * The color of the particle
  22232. */
  22233. color: Nullable<Color4>;
  22234. /**
  22235. * The world space position of the particle.
  22236. */
  22237. position: Vector3;
  22238. /**
  22239. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  22240. */
  22241. rotation: Vector3;
  22242. /**
  22243. * The world space rotation quaternion of the particle.
  22244. */
  22245. rotationQuaternion: Nullable<Quaternion>;
  22246. /**
  22247. * The scaling of the particle.
  22248. */
  22249. scaling: Vector3;
  22250. /**
  22251. * The uvs of the particle.
  22252. */
  22253. uvs: Vector4;
  22254. /**
  22255. * The current speed of the particle.
  22256. */
  22257. velocity: Vector3;
  22258. /**
  22259. * The pivot point in the particle local space.
  22260. */
  22261. pivot: Vector3;
  22262. /**
  22263. * Must the particle be translated from its pivot point in its local space ?
  22264. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  22265. * Default : false
  22266. */
  22267. translateFromPivot: boolean;
  22268. /**
  22269. * Is the particle active or not ?
  22270. */
  22271. alive: boolean;
  22272. /**
  22273. * Is the particle visible or not ?
  22274. */
  22275. isVisible: boolean;
  22276. /**
  22277. * Index of this particle in the global "positions" array (Internal use)
  22278. * @hidden
  22279. */
  22280. _pos: number;
  22281. /**
  22282. * @hidden Index of this particle in the global "indices" array (Internal use)
  22283. */
  22284. _ind: number;
  22285. /**
  22286. * @hidden ModelShape of this particle (Internal use)
  22287. */
  22288. _model: ModelShape;
  22289. /**
  22290. * ModelShape id of this particle
  22291. */
  22292. shapeId: number;
  22293. /**
  22294. * Index of the particle in its shape id (Internal use)
  22295. */
  22296. idxInShape: number;
  22297. /**
  22298. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  22299. */
  22300. _modelBoundingInfo: BoundingInfo;
  22301. /**
  22302. * @hidden Particle BoundingInfo object (Internal use)
  22303. */
  22304. _boundingInfo: BoundingInfo;
  22305. /**
  22306. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  22307. */
  22308. _sps: SolidParticleSystem;
  22309. /**
  22310. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  22311. */
  22312. _stillInvisible: boolean;
  22313. /**
  22314. * @hidden Last computed particle rotation matrix
  22315. */
  22316. _rotationMatrix: number[];
  22317. /**
  22318. * Parent particle Id, if any.
  22319. * Default null.
  22320. */
  22321. parentId: Nullable<number>;
  22322. /**
  22323. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  22324. * The possible values are :
  22325. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  22326. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22327. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  22328. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  22329. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22330. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  22331. * */
  22332. cullingStrategy: number;
  22333. /**
  22334. * @hidden Internal global position in the SPS.
  22335. */
  22336. _globalPosition: Vector3;
  22337. /**
  22338. * Creates a Solid Particle object.
  22339. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  22340. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  22341. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  22342. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  22343. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  22344. * @param shapeId (integer) is the model shape identifier in the SPS.
  22345. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  22346. * @param sps defines the sps it is associated to
  22347. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  22348. */
  22349. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  22350. /**
  22351. * Legacy support, changed scale to scaling
  22352. */
  22353. /**
  22354. * Legacy support, changed scale to scaling
  22355. */
  22356. scale: Vector3;
  22357. /**
  22358. * Legacy support, changed quaternion to rotationQuaternion
  22359. */
  22360. /**
  22361. * Legacy support, changed quaternion to rotationQuaternion
  22362. */
  22363. quaternion: Nullable<Quaternion>;
  22364. /**
  22365. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  22366. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  22367. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  22368. * @returns true if it intersects
  22369. */
  22370. intersectsMesh(target: Mesh | SolidParticle): boolean;
  22371. /**
  22372. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  22373. * A particle is in the frustum if its bounding box intersects the frustum
  22374. * @param frustumPlanes defines the frustum to test
  22375. * @returns true if the particle is in the frustum planes
  22376. */
  22377. isInFrustum(frustumPlanes: Plane[]): boolean;
  22378. /**
  22379. * get the rotation matrix of the particle
  22380. * @hidden
  22381. */
  22382. getRotationMatrix(m: Matrix): void;
  22383. }
  22384. /**
  22385. * Represents the shape of the model used by one particle of a solid particle system.
  22386. * SPS internal tool, don't use it manually.
  22387. */
  22388. export class ModelShape {
  22389. /**
  22390. * The shape id
  22391. * @hidden
  22392. */
  22393. shapeID: number;
  22394. /**
  22395. * flat array of model positions (internal use)
  22396. * @hidden
  22397. */
  22398. _shape: Vector3[];
  22399. /**
  22400. * flat array of model UVs (internal use)
  22401. * @hidden
  22402. */
  22403. _shapeUV: number[];
  22404. /**
  22405. * length of the shape in the model indices array (internal use)
  22406. * @hidden
  22407. */
  22408. _indicesLength: number;
  22409. /**
  22410. * Custom position function (internal use)
  22411. * @hidden
  22412. */
  22413. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  22414. /**
  22415. * Custom vertex function (internal use)
  22416. * @hidden
  22417. */
  22418. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  22419. /**
  22420. * 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.
  22421. * SPS internal tool, don't use it manually.
  22422. * @hidden
  22423. */
  22424. 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>);
  22425. }
  22426. /**
  22427. * Represents a Depth Sorted Particle in the solid particle system.
  22428. */
  22429. export class DepthSortedParticle {
  22430. /**
  22431. * Index of the particle in the "indices" array
  22432. */
  22433. ind: number;
  22434. /**
  22435. * Length of the particle shape in the "indices" array
  22436. */
  22437. indicesLength: number;
  22438. /**
  22439. * Squared distance from the particle to the camera
  22440. */
  22441. sqDistance: number;
  22442. }
  22443. }
  22444. declare module BABYLON {
  22445. /**
  22446. * Class used to store all common mesh properties
  22447. */
  22448. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  22449. /** No occlusion */
  22450. static OCCLUSION_TYPE_NONE: number;
  22451. /** Occlusion set to optimisitic */
  22452. static OCCLUSION_TYPE_OPTIMISTIC: number;
  22453. /** Occlusion set to strict */
  22454. static OCCLUSION_TYPE_STRICT: number;
  22455. /** Use an accurante occlusion algorithm */
  22456. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  22457. /** Use a conservative occlusion algorithm */
  22458. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  22459. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  22460. * Test order :
  22461. * Is the bounding sphere outside the frustum ?
  22462. * If not, are the bounding box vertices outside the frustum ?
  22463. * It not, then the cullable object is in the frustum.
  22464. */
  22465. static readonly CULLINGSTRATEGY_STANDARD: number;
  22466. /** Culling strategy : Bounding Sphere Only.
  22467. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  22468. * It's also less accurate than the standard because some not visible objects can still be selected.
  22469. * Test : is the bounding sphere outside the frustum ?
  22470. * If not, then the cullable object is in the frustum.
  22471. */
  22472. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  22473. /** Culling strategy : Optimistic Inclusion.
  22474. * This in an inclusion test first, then the standard exclusion test.
  22475. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  22476. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  22477. * Anyway, it's as accurate as the standard strategy.
  22478. * Test :
  22479. * Is the cullable object bounding sphere center in the frustum ?
  22480. * If not, apply the default culling strategy.
  22481. */
  22482. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  22483. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  22484. * This in an inclusion test first, then the bounding sphere only exclusion test.
  22485. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  22486. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  22487. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  22488. * Test :
  22489. * Is the cullable object bounding sphere center in the frustum ?
  22490. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  22491. */
  22492. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  22493. /**
  22494. * No billboard
  22495. */
  22496. static readonly BILLBOARDMODE_NONE: number;
  22497. /** Billboard on X axis */
  22498. static readonly BILLBOARDMODE_X: number;
  22499. /** Billboard on Y axis */
  22500. static readonly BILLBOARDMODE_Y: number;
  22501. /** Billboard on Z axis */
  22502. static readonly BILLBOARDMODE_Z: number;
  22503. /** Billboard on all axes */
  22504. static readonly BILLBOARDMODE_ALL: number;
  22505. private _facetData;
  22506. /**
  22507. * The culling strategy to use to check whether the mesh must be rendered or not.
  22508. * This value can be changed at any time and will be used on the next render mesh selection.
  22509. * The possible values are :
  22510. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  22511. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22512. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  22513. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  22514. * Please read each static variable documentation to get details about the culling process.
  22515. * */
  22516. cullingStrategy: number;
  22517. /**
  22518. * Gets the number of facets in the mesh
  22519. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  22520. */
  22521. readonly facetNb: number;
  22522. /**
  22523. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  22524. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  22525. */
  22526. partitioningSubdivisions: number;
  22527. /**
  22528. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  22529. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  22530. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  22531. */
  22532. partitioningBBoxRatio: number;
  22533. /**
  22534. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  22535. * Works only for updatable meshes.
  22536. * Doesn't work with multi-materials
  22537. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  22538. */
  22539. mustDepthSortFacets: boolean;
  22540. /**
  22541. * The location (Vector3) where the facet depth sort must be computed from.
  22542. * By default, the active camera position.
  22543. * Used only when facet depth sort is enabled
  22544. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  22545. */
  22546. facetDepthSortFrom: Vector3;
  22547. /**
  22548. * gets a boolean indicating if facetData is enabled
  22549. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  22550. */
  22551. readonly isFacetDataEnabled: boolean;
  22552. /** @hidden */
  22553. _updateNonUniformScalingState(value: boolean): boolean;
  22554. /**
  22555. * An event triggered when this mesh collides with another one
  22556. */
  22557. onCollideObservable: Observable<AbstractMesh>;
  22558. private _onCollideObserver;
  22559. /** Set a function to call when this mesh collides with another one */
  22560. onCollide: () => void;
  22561. /**
  22562. * An event triggered when the collision's position changes
  22563. */
  22564. onCollisionPositionChangeObservable: Observable<Vector3>;
  22565. private _onCollisionPositionChangeObserver;
  22566. /** Set a function to call when the collision's position changes */
  22567. onCollisionPositionChange: () => void;
  22568. /**
  22569. * An event triggered when material is changed
  22570. */
  22571. onMaterialChangedObservable: Observable<AbstractMesh>;
  22572. /**
  22573. * Gets or sets the orientation for POV movement & rotation
  22574. */
  22575. definedFacingForward: boolean;
  22576. /** @hidden */
  22577. _occlusionQuery: Nullable<WebGLQuery>;
  22578. private _visibility;
  22579. /**
  22580. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  22581. */
  22582. /**
  22583. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  22584. */
  22585. visibility: number;
  22586. /** Gets or sets the alpha index used to sort transparent meshes
  22587. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  22588. */
  22589. alphaIndex: number;
  22590. /**
  22591. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  22592. */
  22593. isVisible: boolean;
  22594. /**
  22595. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  22596. */
  22597. isPickable: boolean;
  22598. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  22599. showSubMeshesBoundingBox: boolean;
  22600. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  22601. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  22602. */
  22603. isBlocker: boolean;
  22604. /**
  22605. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  22606. */
  22607. enablePointerMoveEvents: boolean;
  22608. /**
  22609. * Specifies the rendering group id for this mesh (0 by default)
  22610. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  22611. */
  22612. renderingGroupId: number;
  22613. private _material;
  22614. /** Gets or sets current material */
  22615. material: Nullable<Material>;
  22616. private _receiveShadows;
  22617. /**
  22618. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  22619. * @see http://doc.babylonjs.com/babylon101/shadows
  22620. */
  22621. receiveShadows: boolean;
  22622. /** Defines color to use when rendering outline */
  22623. outlineColor: Color3;
  22624. /** Define width to use when rendering outline */
  22625. outlineWidth: number;
  22626. /** Defines color to use when rendering overlay */
  22627. overlayColor: Color3;
  22628. /** Defines alpha to use when rendering overlay */
  22629. overlayAlpha: number;
  22630. private _hasVertexAlpha;
  22631. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  22632. hasVertexAlpha: boolean;
  22633. private _useVertexColors;
  22634. /** 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) */
  22635. useVertexColors: boolean;
  22636. private _computeBonesUsingShaders;
  22637. /**
  22638. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  22639. */
  22640. computeBonesUsingShaders: boolean;
  22641. private _numBoneInfluencers;
  22642. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  22643. numBoneInfluencers: number;
  22644. private _applyFog;
  22645. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  22646. applyFog: boolean;
  22647. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  22648. useOctreeForRenderingSelection: boolean;
  22649. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  22650. useOctreeForPicking: boolean;
  22651. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  22652. useOctreeForCollisions: boolean;
  22653. private _layerMask;
  22654. /**
  22655. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  22656. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  22657. */
  22658. layerMask: number;
  22659. /**
  22660. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  22661. */
  22662. alwaysSelectAsActiveMesh: boolean;
  22663. /**
  22664. * Gets or sets the current action manager
  22665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  22666. */
  22667. actionManager: Nullable<AbstractActionManager>;
  22668. private _checkCollisions;
  22669. private _collisionMask;
  22670. private _collisionGroup;
  22671. /**
  22672. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  22673. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22674. */
  22675. ellipsoid: Vector3;
  22676. /**
  22677. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  22678. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22679. */
  22680. ellipsoidOffset: Vector3;
  22681. private _collider;
  22682. private _oldPositionForCollisions;
  22683. private _diffPositionForCollisions;
  22684. /**
  22685. * Gets or sets a collision mask used to mask collisions (default is -1).
  22686. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  22687. */
  22688. collisionMask: number;
  22689. /**
  22690. * Gets or sets the current collision group mask (-1 by default).
  22691. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  22692. */
  22693. collisionGroup: number;
  22694. /**
  22695. * Defines edge width used when edgesRenderer is enabled
  22696. * @see https://www.babylonjs-playground.com/#10OJSG#13
  22697. */
  22698. edgesWidth: number;
  22699. /**
  22700. * Defines edge color used when edgesRenderer is enabled
  22701. * @see https://www.babylonjs-playground.com/#10OJSG#13
  22702. */
  22703. edgesColor: Color4;
  22704. /** @hidden */
  22705. _edgesRenderer: Nullable<IEdgesRenderer>;
  22706. /** @hidden */
  22707. _masterMesh: Nullable<AbstractMesh>;
  22708. /** @hidden */
  22709. _boundingInfo: Nullable<BoundingInfo>;
  22710. /** @hidden */
  22711. _renderId: number;
  22712. /**
  22713. * Gets or sets the list of subMeshes
  22714. * @see http://doc.babylonjs.com/how_to/multi_materials
  22715. */
  22716. subMeshes: SubMesh[];
  22717. /** @hidden */
  22718. _intersectionsInProgress: AbstractMesh[];
  22719. /** @hidden */
  22720. _unIndexed: boolean;
  22721. /** @hidden */
  22722. _lightSources: Light[];
  22723. /** @hidden */
  22724. readonly _positions: Nullable<Vector3[]>;
  22725. /** @hidden */
  22726. _waitingActions: any;
  22727. /** @hidden */
  22728. _waitingFreezeWorldMatrix: Nullable<boolean>;
  22729. private _skeleton;
  22730. /** @hidden */
  22731. _bonesTransformMatrices: Nullable<Float32Array>;
  22732. /**
  22733. * Gets or sets a skeleton to apply skining transformations
  22734. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  22735. */
  22736. skeleton: Nullable<Skeleton>;
  22737. /**
  22738. * An event triggered when the mesh is rebuilt.
  22739. */
  22740. onRebuildObservable: Observable<AbstractMesh>;
  22741. /**
  22742. * Creates a new AbstractMesh
  22743. * @param name defines the name of the mesh
  22744. * @param scene defines the hosting scene
  22745. */
  22746. constructor(name: string, scene?: Nullable<Scene>);
  22747. /**
  22748. * Returns the string "AbstractMesh"
  22749. * @returns "AbstractMesh"
  22750. */
  22751. getClassName(): string;
  22752. /**
  22753. * Gets a string representation of the current mesh
  22754. * @param fullDetails defines a boolean indicating if full details must be included
  22755. * @returns a string representation of the current mesh
  22756. */
  22757. toString(fullDetails?: boolean): string;
  22758. /** @hidden */
  22759. _rebuild(): void;
  22760. /** @hidden */
  22761. _resyncLightSources(): void;
  22762. /** @hidden */
  22763. _resyncLighSource(light: Light): void;
  22764. /** @hidden */
  22765. _unBindEffect(): void;
  22766. /** @hidden */
  22767. _removeLightSource(light: Light): void;
  22768. private _markSubMeshesAsDirty;
  22769. /** @hidden */
  22770. _markSubMeshesAsLightDirty(): void;
  22771. /** @hidden */
  22772. _markSubMeshesAsAttributesDirty(): void;
  22773. /** @hidden */
  22774. _markSubMeshesAsMiscDirty(): void;
  22775. /**
  22776. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  22777. */
  22778. scaling: Vector3;
  22779. /**
  22780. * Returns true if the mesh is blocked. Implemented by child classes
  22781. */
  22782. readonly isBlocked: boolean;
  22783. /**
  22784. * Returns the mesh itself by default. Implemented by child classes
  22785. * @param camera defines the camera to use to pick the right LOD level
  22786. * @returns the currentAbstractMesh
  22787. */
  22788. getLOD(camera: Camera): Nullable<AbstractMesh>;
  22789. /**
  22790. * Returns 0 by default. Implemented by child classes
  22791. * @returns an integer
  22792. */
  22793. getTotalVertices(): number;
  22794. /**
  22795. * Returns a positive integer : the total number of indices in this mesh geometry.
  22796. * @returns the numner of indices or zero if the mesh has no geometry.
  22797. */
  22798. getTotalIndices(): number;
  22799. /**
  22800. * Returns null by default. Implemented by child classes
  22801. * @returns null
  22802. */
  22803. getIndices(): Nullable<IndicesArray>;
  22804. /**
  22805. * Returns the array of the requested vertex data kind. Implemented by child classes
  22806. * @param kind defines the vertex data kind to use
  22807. * @returns null
  22808. */
  22809. getVerticesData(kind: string): Nullable<FloatArray>;
  22810. /**
  22811. * Sets the vertex data of the mesh geometry for the requested `kind`.
  22812. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  22813. * Note that a new underlying VertexBuffer object is created each call.
  22814. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  22815. * @param kind defines vertex data kind:
  22816. * * VertexBuffer.PositionKind
  22817. * * VertexBuffer.UVKind
  22818. * * VertexBuffer.UV2Kind
  22819. * * VertexBuffer.UV3Kind
  22820. * * VertexBuffer.UV4Kind
  22821. * * VertexBuffer.UV5Kind
  22822. * * VertexBuffer.UV6Kind
  22823. * * VertexBuffer.ColorKind
  22824. * * VertexBuffer.MatricesIndicesKind
  22825. * * VertexBuffer.MatricesIndicesExtraKind
  22826. * * VertexBuffer.MatricesWeightsKind
  22827. * * VertexBuffer.MatricesWeightsExtraKind
  22828. * @param data defines the data source
  22829. * @param updatable defines if the data must be flagged as updatable (or static)
  22830. * @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
  22831. * @returns the current mesh
  22832. */
  22833. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  22834. /**
  22835. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  22836. * If the mesh has no geometry, it is simply returned as it is.
  22837. * @param kind defines vertex data kind:
  22838. * * VertexBuffer.PositionKind
  22839. * * VertexBuffer.UVKind
  22840. * * VertexBuffer.UV2Kind
  22841. * * VertexBuffer.UV3Kind
  22842. * * VertexBuffer.UV4Kind
  22843. * * VertexBuffer.UV5Kind
  22844. * * VertexBuffer.UV6Kind
  22845. * * VertexBuffer.ColorKind
  22846. * * VertexBuffer.MatricesIndicesKind
  22847. * * VertexBuffer.MatricesIndicesExtraKind
  22848. * * VertexBuffer.MatricesWeightsKind
  22849. * * VertexBuffer.MatricesWeightsExtraKind
  22850. * @param data defines the data source
  22851. * @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
  22852. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  22853. * @returns the current mesh
  22854. */
  22855. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  22856. /**
  22857. * Sets the mesh indices,
  22858. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  22859. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  22860. * @param totalVertices Defines the total number of vertices
  22861. * @returns the current mesh
  22862. */
  22863. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  22864. /**
  22865. * Gets a boolean indicating if specific vertex data is present
  22866. * @param kind defines the vertex data kind to use
  22867. * @returns true is data kind is present
  22868. */
  22869. isVerticesDataPresent(kind: string): boolean;
  22870. /**
  22871. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  22872. * @returns a BoundingInfo
  22873. */
  22874. getBoundingInfo(): BoundingInfo;
  22875. /**
  22876. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  22877. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  22878. * @returns the current mesh
  22879. */
  22880. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  22881. /**
  22882. * Overwrite the current bounding info
  22883. * @param boundingInfo defines the new bounding info
  22884. * @returns the current mesh
  22885. */
  22886. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  22887. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  22888. readonly useBones: boolean;
  22889. /** @hidden */
  22890. _preActivate(): void;
  22891. /** @hidden */
  22892. _preActivateForIntermediateRendering(renderId: number): void;
  22893. /** @hidden */
  22894. _activate(renderId: number): void;
  22895. /**
  22896. * Gets the current world matrix
  22897. * @returns a Matrix
  22898. */
  22899. getWorldMatrix(): Matrix;
  22900. /** @hidden */
  22901. _getWorldMatrixDeterminant(): number;
  22902. /**
  22903. * Perform relative position change from the point of view of behind the front of the mesh.
  22904. * This is performed taking into account the meshes current rotation, so you do not have to care.
  22905. * Supports definition of mesh facing forward or backward
  22906. * @param amountRight defines the distance on the right axis
  22907. * @param amountUp defines the distance on the up axis
  22908. * @param amountForward defines the distance on the forward axis
  22909. * @returns the current mesh
  22910. */
  22911. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  22912. /**
  22913. * Calculate relative position change from the point of view of behind the front of the mesh.
  22914. * This is performed taking into account the meshes current rotation, so you do not have to care.
  22915. * Supports definition of mesh facing forward or backward
  22916. * @param amountRight defines the distance on the right axis
  22917. * @param amountUp defines the distance on the up axis
  22918. * @param amountForward defines the distance on the forward axis
  22919. * @returns the new displacement vector
  22920. */
  22921. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  22922. /**
  22923. * Perform relative rotation change from the point of view of behind the front of the mesh.
  22924. * Supports definition of mesh facing forward or backward
  22925. * @param flipBack defines the flip
  22926. * @param twirlClockwise defines the twirl
  22927. * @param tiltRight defines the tilt
  22928. * @returns the current mesh
  22929. */
  22930. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  22931. /**
  22932. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  22933. * Supports definition of mesh facing forward or backward.
  22934. * @param flipBack defines the flip
  22935. * @param twirlClockwise defines the twirl
  22936. * @param tiltRight defines the tilt
  22937. * @returns the new rotation vector
  22938. */
  22939. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  22940. /**
  22941. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  22942. * @param includeDescendants Include bounding info from descendants as well (true by default)
  22943. * @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
  22944. * @returns the new bounding vectors
  22945. */
  22946. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  22947. min: Vector3;
  22948. max: Vector3;
  22949. };
  22950. /**
  22951. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  22952. * This means the mesh underlying bounding box and sphere are recomputed.
  22953. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  22954. * @returns the current mesh
  22955. */
  22956. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  22957. /** @hidden */
  22958. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  22959. /** @hidden */
  22960. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  22961. /** @hidden */
  22962. _updateBoundingInfo(): AbstractMesh;
  22963. /** @hidden */
  22964. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  22965. /** @hidden */
  22966. protected _afterComputeWorldMatrix(): void;
  22967. /**
  22968. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  22969. * A mesh is in the frustum if its bounding box intersects the frustum
  22970. * @param frustumPlanes defines the frustum to test
  22971. * @returns true if the mesh is in the frustum planes
  22972. */
  22973. isInFrustum(frustumPlanes: Plane[]): boolean;
  22974. /**
  22975. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  22976. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  22977. * @param frustumPlanes defines the frustum to test
  22978. * @returns true if the mesh is completely in the frustum planes
  22979. */
  22980. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22981. /**
  22982. * True if the mesh intersects another mesh or a SolidParticle object
  22983. * @param mesh defines a target mesh or SolidParticle to test
  22984. * @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)
  22985. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  22986. * @returns true if there is an intersection
  22987. */
  22988. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  22989. /**
  22990. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  22991. * @param point defines the point to test
  22992. * @returns true if there is an intersection
  22993. */
  22994. intersectsPoint(point: Vector3): boolean;
  22995. /**
  22996. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  22997. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22998. */
  22999. checkCollisions: boolean;
  23000. /**
  23001. * Gets Collider object used to compute collisions (not physics)
  23002. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23003. */
  23004. readonly collider: Collider;
  23005. /**
  23006. * Move the mesh using collision engine
  23007. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23008. * @param displacement defines the requested displacement vector
  23009. * @returns the current mesh
  23010. */
  23011. moveWithCollisions(displacement: Vector3): AbstractMesh;
  23012. private _onCollisionPositionChange;
  23013. /** @hidden */
  23014. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  23015. /** @hidden */
  23016. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  23017. /** @hidden */
  23018. _checkCollision(collider: Collider): AbstractMesh;
  23019. /** @hidden */
  23020. _generatePointsArray(): boolean;
  23021. /**
  23022. * Checks if the passed Ray intersects with the mesh
  23023. * @param ray defines the ray to use
  23024. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  23025. * @returns the picking info
  23026. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  23027. */
  23028. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  23029. /**
  23030. * Clones the current mesh
  23031. * @param name defines the mesh name
  23032. * @param newParent defines the new mesh parent
  23033. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  23034. * @returns the new mesh
  23035. */
  23036. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  23037. /**
  23038. * Disposes all the submeshes of the current meshnp
  23039. * @returns the current mesh
  23040. */
  23041. releaseSubMeshes(): AbstractMesh;
  23042. /**
  23043. * Releases resources associated with this abstract mesh.
  23044. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23045. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23046. */
  23047. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23048. /**
  23049. * Adds the passed mesh as a child to the current mesh
  23050. * @param mesh defines the child mesh
  23051. * @returns the current mesh
  23052. */
  23053. addChild(mesh: AbstractMesh): AbstractMesh;
  23054. /**
  23055. * Removes the passed mesh from the current mesh children list
  23056. * @param mesh defines the child mesh
  23057. * @returns the current mesh
  23058. */
  23059. removeChild(mesh: AbstractMesh): AbstractMesh;
  23060. /** @hidden */
  23061. private _initFacetData;
  23062. /**
  23063. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  23064. * This method can be called within the render loop.
  23065. * 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
  23066. * @returns the current mesh
  23067. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23068. */
  23069. updateFacetData(): AbstractMesh;
  23070. /**
  23071. * Returns the facetLocalNormals array.
  23072. * The normals are expressed in the mesh local spac
  23073. * @returns an array of Vector3
  23074. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23075. */
  23076. getFacetLocalNormals(): Vector3[];
  23077. /**
  23078. * Returns the facetLocalPositions array.
  23079. * The facet positions are expressed in the mesh local space
  23080. * @returns an array of Vector3
  23081. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23082. */
  23083. getFacetLocalPositions(): Vector3[];
  23084. /**
  23085. * Returns the facetLocalPartioning array
  23086. * @returns an array of array of numbers
  23087. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23088. */
  23089. getFacetLocalPartitioning(): number[][];
  23090. /**
  23091. * Returns the i-th facet position in the world system.
  23092. * This method allocates a new Vector3 per call
  23093. * @param i defines the facet index
  23094. * @returns a new Vector3
  23095. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23096. */
  23097. getFacetPosition(i: number): Vector3;
  23098. /**
  23099. * Sets the reference Vector3 with the i-th facet position in the world system
  23100. * @param i defines the facet index
  23101. * @param ref defines the target vector
  23102. * @returns the current mesh
  23103. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23104. */
  23105. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  23106. /**
  23107. * Returns the i-th facet normal in the world system.
  23108. * This method allocates a new Vector3 per call
  23109. * @param i defines the facet index
  23110. * @returns a new Vector3
  23111. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23112. */
  23113. getFacetNormal(i: number): Vector3;
  23114. /**
  23115. * Sets the reference Vector3 with the i-th facet normal in the world system
  23116. * @param i defines the facet index
  23117. * @param ref defines the target vector
  23118. * @returns the current mesh
  23119. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23120. */
  23121. getFacetNormalToRef(i: number, ref: Vector3): this;
  23122. /**
  23123. * 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)
  23124. * @param x defines x coordinate
  23125. * @param y defines y coordinate
  23126. * @param z defines z coordinate
  23127. * @returns the array of facet indexes
  23128. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23129. */
  23130. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  23131. /**
  23132. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  23133. * @param projected sets as the (x,y,z) world projection on the facet
  23134. * @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
  23135. * @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
  23136. * @param x defines x coordinate
  23137. * @param y defines y coordinate
  23138. * @param z defines z coordinate
  23139. * @returns the face index if found (or null instead)
  23140. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23141. */
  23142. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  23143. /**
  23144. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  23145. * @param projected sets as the (x,y,z) local projection on the facet
  23146. * @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
  23147. * @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
  23148. * @param x defines x coordinate
  23149. * @param y defines y coordinate
  23150. * @param z defines z coordinate
  23151. * @returns the face index if found (or null instead)
  23152. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23153. */
  23154. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  23155. /**
  23156. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  23157. * @returns the parameters
  23158. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23159. */
  23160. getFacetDataParameters(): any;
  23161. /**
  23162. * Disables the feature FacetData and frees the related memory
  23163. * @returns the current mesh
  23164. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23165. */
  23166. disableFacetData(): AbstractMesh;
  23167. /**
  23168. * Updates the AbstractMesh indices array
  23169. * @param indices defines the data source
  23170. * @returns the current mesh
  23171. */
  23172. updateIndices(indices: IndicesArray): AbstractMesh;
  23173. /**
  23174. * Creates new normals data for the mesh
  23175. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  23176. * @returns the current mesh
  23177. */
  23178. createNormals(updatable: boolean): AbstractMesh;
  23179. /**
  23180. * Align the mesh with a normal
  23181. * @param normal defines the normal to use
  23182. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  23183. * @returns the current mesh
  23184. */
  23185. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  23186. /** @hidden */
  23187. _checkOcclusionQuery(): boolean;
  23188. }
  23189. }
  23190. declare module BABYLON {
  23191. /**
  23192. * Class used to handle skinning animations
  23193. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23194. */
  23195. export class Skeleton implements IAnimatable {
  23196. /** defines the skeleton name */
  23197. name: string;
  23198. /** defines the skeleton Id */
  23199. id: string;
  23200. /**
  23201. * Defines the list of child bones
  23202. */
  23203. bones: Bone[];
  23204. /**
  23205. * Defines an estimate of the dimension of the skeleton at rest
  23206. */
  23207. dimensionsAtRest: Vector3;
  23208. /**
  23209. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  23210. */
  23211. needInitialSkinMatrix: boolean;
  23212. /**
  23213. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  23214. */
  23215. overrideMesh: Nullable<AbstractMesh>;
  23216. /**
  23217. * Gets the list of animations attached to this skeleton
  23218. */
  23219. animations: Array<Animation>;
  23220. private _scene;
  23221. private _isDirty;
  23222. private _transformMatrices;
  23223. private _transformMatrixTexture;
  23224. private _meshesWithPoseMatrix;
  23225. private _animatables;
  23226. private _identity;
  23227. private _synchronizedWithMesh;
  23228. private _ranges;
  23229. private _lastAbsoluteTransformsUpdateId;
  23230. private _canUseTextureForBones;
  23231. /** @hidden */
  23232. _numBonesWithLinkedTransformNode: number;
  23233. /**
  23234. * Specifies if the skeleton should be serialized
  23235. */
  23236. doNotSerialize: boolean;
  23237. /**
  23238. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  23239. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  23240. */
  23241. useTextureToStoreBoneMatrices: boolean;
  23242. private _animationPropertiesOverride;
  23243. /**
  23244. * Gets or sets the animation properties override
  23245. */
  23246. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  23247. /**
  23248. * An observable triggered before computing the skeleton's matrices
  23249. */
  23250. onBeforeComputeObservable: Observable<Skeleton>;
  23251. /**
  23252. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  23253. */
  23254. readonly isUsingTextureForMatrices: boolean;
  23255. /**
  23256. * Creates a new skeleton
  23257. * @param name defines the skeleton name
  23258. * @param id defines the skeleton Id
  23259. * @param scene defines the hosting scene
  23260. */
  23261. constructor(
  23262. /** defines the skeleton name */
  23263. name: string,
  23264. /** defines the skeleton Id */
  23265. id: string, scene: Scene);
  23266. /**
  23267. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  23268. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  23269. * @returns a Float32Array containing matrices data
  23270. */
  23271. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  23272. /**
  23273. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  23274. * @returns a raw texture containing the data
  23275. */
  23276. getTransformMatrixTexture(): Nullable<RawTexture>;
  23277. /**
  23278. * Gets the current hosting scene
  23279. * @returns a scene object
  23280. */
  23281. getScene(): Scene;
  23282. /**
  23283. * Gets a string representing the current skeleton data
  23284. * @param fullDetails defines a boolean indicating if we want a verbose version
  23285. * @returns a string representing the current skeleton data
  23286. */
  23287. toString(fullDetails?: boolean): string;
  23288. /**
  23289. * Get bone's index searching by name
  23290. * @param name defines bone's name to search for
  23291. * @return the indice of the bone. Returns -1 if not found
  23292. */
  23293. getBoneIndexByName(name: string): number;
  23294. /**
  23295. * Creater a new animation range
  23296. * @param name defines the name of the range
  23297. * @param from defines the start key
  23298. * @param to defines the end key
  23299. */
  23300. createAnimationRange(name: string, from: number, to: number): void;
  23301. /**
  23302. * Delete a specific animation range
  23303. * @param name defines the name of the range
  23304. * @param deleteFrames defines if frames must be removed as well
  23305. */
  23306. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  23307. /**
  23308. * Gets a specific animation range
  23309. * @param name defines the name of the range to look for
  23310. * @returns the requested animation range or null if not found
  23311. */
  23312. getAnimationRange(name: string): Nullable<AnimationRange>;
  23313. /**
  23314. * Gets the list of all animation ranges defined on this skeleton
  23315. * @returns an array
  23316. */
  23317. getAnimationRanges(): Nullable<AnimationRange>[];
  23318. /**
  23319. * Copy animation range from a source skeleton.
  23320. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  23321. * @param source defines the source skeleton
  23322. * @param name defines the name of the range to copy
  23323. * @param rescaleAsRequired defines if rescaling must be applied if required
  23324. * @returns true if operation was successful
  23325. */
  23326. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  23327. /**
  23328. * Forces the skeleton to go to rest pose
  23329. */
  23330. returnToRest(): void;
  23331. private _getHighestAnimationFrame;
  23332. /**
  23333. * Begin a specific animation range
  23334. * @param name defines the name of the range to start
  23335. * @param loop defines if looping must be turned on (false by default)
  23336. * @param speedRatio defines the speed ratio to apply (1 by default)
  23337. * @param onAnimationEnd defines a callback which will be called when animation will end
  23338. * @returns a new animatable
  23339. */
  23340. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  23341. /** @hidden */
  23342. _markAsDirty(): void;
  23343. /** @hidden */
  23344. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  23345. /** @hidden */
  23346. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  23347. private _computeTransformMatrices;
  23348. /**
  23349. * Build all resources required to render a skeleton
  23350. */
  23351. prepare(): void;
  23352. /**
  23353. * Gets the list of animatables currently running for this skeleton
  23354. * @returns an array of animatables
  23355. */
  23356. getAnimatables(): IAnimatable[];
  23357. /**
  23358. * Clone the current skeleton
  23359. * @param name defines the name of the new skeleton
  23360. * @param id defines the id of the enw skeleton
  23361. * @returns the new skeleton
  23362. */
  23363. clone(name: string, id: string): Skeleton;
  23364. /**
  23365. * Enable animation blending for this skeleton
  23366. * @param blendingSpeed defines the blending speed to apply
  23367. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  23368. */
  23369. enableBlending(blendingSpeed?: number): void;
  23370. /**
  23371. * Releases all resources associated with the current skeleton
  23372. */
  23373. dispose(): void;
  23374. /**
  23375. * Serialize the skeleton in a JSON object
  23376. * @returns a JSON object
  23377. */
  23378. serialize(): any;
  23379. /**
  23380. * Creates a new skeleton from serialized data
  23381. * @param parsedSkeleton defines the serialized data
  23382. * @param scene defines the hosting scene
  23383. * @returns a new skeleton
  23384. */
  23385. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  23386. /**
  23387. * Compute all node absolute transforms
  23388. * @param forceUpdate defines if computation must be done even if cache is up to date
  23389. */
  23390. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  23391. /**
  23392. * Gets the root pose matrix
  23393. * @returns a matrix
  23394. */
  23395. getPoseMatrix(): Nullable<Matrix>;
  23396. /**
  23397. * Sorts bones per internal index
  23398. */
  23399. sortBones(): void;
  23400. private _sortBones;
  23401. }
  23402. }
  23403. declare module BABYLON {
  23404. /**
  23405. * Class used to store bone information
  23406. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23407. */
  23408. export class Bone extends Node {
  23409. /**
  23410. * defines the bone name
  23411. */
  23412. name: string;
  23413. private static _tmpVecs;
  23414. private static _tmpQuat;
  23415. private static _tmpMats;
  23416. /**
  23417. * Gets the list of child bones
  23418. */
  23419. children: Bone[];
  23420. /** Gets the animations associated with this bone */
  23421. animations: Animation[];
  23422. /**
  23423. * Gets or sets bone length
  23424. */
  23425. length: number;
  23426. /**
  23427. * @hidden Internal only
  23428. * Set this value to map this bone to a different index in the transform matrices
  23429. * Set this value to -1 to exclude the bone from the transform matrices
  23430. */
  23431. _index: Nullable<number>;
  23432. private _skeleton;
  23433. private _localMatrix;
  23434. private _restPose;
  23435. private _baseMatrix;
  23436. private _absoluteTransform;
  23437. private _invertedAbsoluteTransform;
  23438. private _parent;
  23439. private _scalingDeterminant;
  23440. private _worldTransform;
  23441. private _localScaling;
  23442. private _localRotation;
  23443. private _localPosition;
  23444. private _needToDecompose;
  23445. private _needToCompose;
  23446. /** @hidden */
  23447. _linkedTransformNode: Nullable<TransformNode>;
  23448. /** @hidden */
  23449. /** @hidden */
  23450. _matrix: Matrix;
  23451. /**
  23452. * Create a new bone
  23453. * @param name defines the bone name
  23454. * @param skeleton defines the parent skeleton
  23455. * @param parentBone defines the parent (can be null if the bone is the root)
  23456. * @param localMatrix defines the local matrix
  23457. * @param restPose defines the rest pose matrix
  23458. * @param baseMatrix defines the base matrix
  23459. * @param index defines index of the bone in the hiearchy
  23460. */
  23461. constructor(
  23462. /**
  23463. * defines the bone name
  23464. */
  23465. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  23466. /**
  23467. * Gets the parent skeleton
  23468. * @returns a skeleton
  23469. */
  23470. getSkeleton(): Skeleton;
  23471. /**
  23472. * Gets parent bone
  23473. * @returns a bone or null if the bone is the root of the bone hierarchy
  23474. */
  23475. getParent(): Nullable<Bone>;
  23476. /**
  23477. * Sets the parent bone
  23478. * @param parent defines the parent (can be null if the bone is the root)
  23479. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  23480. */
  23481. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  23482. /**
  23483. * Gets the local matrix
  23484. * @returns a matrix
  23485. */
  23486. getLocalMatrix(): Matrix;
  23487. /**
  23488. * Gets the base matrix (initial matrix which remains unchanged)
  23489. * @returns a matrix
  23490. */
  23491. getBaseMatrix(): Matrix;
  23492. /**
  23493. * Gets the rest pose matrix
  23494. * @returns a matrix
  23495. */
  23496. getRestPose(): Matrix;
  23497. /**
  23498. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  23499. */
  23500. getWorldMatrix(): Matrix;
  23501. /**
  23502. * Sets the local matrix to rest pose matrix
  23503. */
  23504. returnToRest(): void;
  23505. /**
  23506. * Gets the inverse of the absolute transform matrix.
  23507. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  23508. * @returns a matrix
  23509. */
  23510. getInvertedAbsoluteTransform(): Matrix;
  23511. /**
  23512. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  23513. * @returns a matrix
  23514. */
  23515. getAbsoluteTransform(): Matrix;
  23516. /**
  23517. * Links with the given transform node.
  23518. * The local matrix of this bone is copied from the transform node every frame.
  23519. * @param transformNode defines the transform node to link to
  23520. */
  23521. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  23522. /** Gets or sets current position (in local space) */
  23523. position: Vector3;
  23524. /** Gets or sets current rotation (in local space) */
  23525. rotation: Vector3;
  23526. /** Gets or sets current rotation quaternion (in local space) */
  23527. rotationQuaternion: Quaternion;
  23528. /** Gets or sets current scaling (in local space) */
  23529. scaling: Vector3;
  23530. /**
  23531. * Gets the animation properties override
  23532. */
  23533. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  23534. private _decompose;
  23535. private _compose;
  23536. /**
  23537. * Update the base and local matrices
  23538. * @param matrix defines the new base or local matrix
  23539. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  23540. * @param updateLocalMatrix defines if the local matrix should be updated
  23541. */
  23542. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  23543. /** @hidden */
  23544. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  23545. /**
  23546. * Flag the bone as dirty (Forcing it to update everything)
  23547. */
  23548. markAsDirty(): void;
  23549. private _markAsDirtyAndCompose;
  23550. private _markAsDirtyAndDecompose;
  23551. /**
  23552. * Translate the bone in local or world space
  23553. * @param vec The amount to translate the bone
  23554. * @param space The space that the translation is in
  23555. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23556. */
  23557. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  23558. /**
  23559. * Set the postion of the bone in local or world space
  23560. * @param position The position to set the bone
  23561. * @param space The space that the position is in
  23562. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23563. */
  23564. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  23565. /**
  23566. * Set the absolute position of the bone (world space)
  23567. * @param position The position to set the bone
  23568. * @param mesh The mesh that this bone is attached to
  23569. */
  23570. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  23571. /**
  23572. * Scale the bone on the x, y and z axes (in local space)
  23573. * @param x The amount to scale the bone on the x axis
  23574. * @param y The amount to scale the bone on the y axis
  23575. * @param z The amount to scale the bone on the z axis
  23576. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  23577. */
  23578. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  23579. /**
  23580. * Set the bone scaling in local space
  23581. * @param scale defines the scaling vector
  23582. */
  23583. setScale(scale: Vector3): void;
  23584. /**
  23585. * Gets the current scaling in local space
  23586. * @returns the current scaling vector
  23587. */
  23588. getScale(): Vector3;
  23589. /**
  23590. * Gets the current scaling in local space and stores it in a target vector
  23591. * @param result defines the target vector
  23592. */
  23593. getScaleToRef(result: Vector3): void;
  23594. /**
  23595. * Set the yaw, pitch, and roll of the bone in local or world space
  23596. * @param yaw The rotation of the bone on the y axis
  23597. * @param pitch The rotation of the bone on the x axis
  23598. * @param roll The rotation of the bone on the z axis
  23599. * @param space The space that the axes of rotation are in
  23600. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23601. */
  23602. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  23603. /**
  23604. * Add a rotation to the bone on an axis in local or world space
  23605. * @param axis The axis to rotate the bone on
  23606. * @param amount The amount to rotate the bone
  23607. * @param space The space that the axis is in
  23608. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23609. */
  23610. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  23611. /**
  23612. * Set the rotation of the bone to a particular axis angle in local or world space
  23613. * @param axis The axis to rotate the bone on
  23614. * @param angle The angle that the bone should be rotated to
  23615. * @param space The space that the axis is in
  23616. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23617. */
  23618. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  23619. /**
  23620. * Set the euler rotation of the bone in local of world space
  23621. * @param rotation The euler rotation that the bone should be set to
  23622. * @param space The space that the rotation is in
  23623. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23624. */
  23625. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  23626. /**
  23627. * Set the quaternion rotation of the bone in local of world space
  23628. * @param quat The quaternion rotation that the bone should be set to
  23629. * @param space The space that the rotation is in
  23630. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23631. */
  23632. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  23633. /**
  23634. * Set the rotation matrix of the bone in local of world space
  23635. * @param rotMat The rotation matrix that the bone should be set to
  23636. * @param space The space that the rotation is in
  23637. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23638. */
  23639. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  23640. private _rotateWithMatrix;
  23641. private _getNegativeRotationToRef;
  23642. /**
  23643. * Get the position of the bone in local or world space
  23644. * @param space The space that the returned position is in
  23645. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23646. * @returns The position of the bone
  23647. */
  23648. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  23649. /**
  23650. * Copy the position of the bone to a vector3 in local or world space
  23651. * @param space The space that the returned position is in
  23652. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23653. * @param result The vector3 to copy the position to
  23654. */
  23655. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  23656. /**
  23657. * Get the absolute position of the bone (world space)
  23658. * @param mesh The mesh that this bone is attached to
  23659. * @returns The absolute position of the bone
  23660. */
  23661. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  23662. /**
  23663. * Copy the absolute position of the bone (world space) to the result param
  23664. * @param mesh The mesh that this bone is attached to
  23665. * @param result The vector3 to copy the absolute position to
  23666. */
  23667. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  23668. /**
  23669. * Compute the absolute transforms of this bone and its children
  23670. */
  23671. computeAbsoluteTransforms(): void;
  23672. /**
  23673. * Get the world direction from an axis that is in the local space of the bone
  23674. * @param localAxis The local direction that is used to compute the world direction
  23675. * @param mesh The mesh that this bone is attached to
  23676. * @returns The world direction
  23677. */
  23678. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  23679. /**
  23680. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  23681. * @param localAxis The local direction that is used to compute the world direction
  23682. * @param mesh The mesh that this bone is attached to
  23683. * @param result The vector3 that the world direction will be copied to
  23684. */
  23685. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  23686. /**
  23687. * Get the euler rotation of the bone in local or world space
  23688. * @param space The space that the rotation should be in
  23689. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23690. * @returns The euler rotation
  23691. */
  23692. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  23693. /**
  23694. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  23695. * @param space The space that the rotation should be in
  23696. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23697. * @param result The vector3 that the rotation should be copied to
  23698. */
  23699. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  23700. /**
  23701. * Get the quaternion rotation of the bone in either local or world space
  23702. * @param space The space that the rotation should be in
  23703. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23704. * @returns The quaternion rotation
  23705. */
  23706. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  23707. /**
  23708. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  23709. * @param space The space that the rotation should be in
  23710. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23711. * @param result The quaternion that the rotation should be copied to
  23712. */
  23713. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  23714. /**
  23715. * Get the rotation matrix of the bone in local or world space
  23716. * @param space The space that the rotation should be in
  23717. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23718. * @returns The rotation matrix
  23719. */
  23720. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  23721. /**
  23722. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  23723. * @param space The space that the rotation should be in
  23724. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23725. * @param result The quaternion that the rotation should be copied to
  23726. */
  23727. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  23728. /**
  23729. * Get the world position of a point that is in the local space of the bone
  23730. * @param position The local position
  23731. * @param mesh The mesh that this bone is attached to
  23732. * @returns The world position
  23733. */
  23734. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  23735. /**
  23736. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  23737. * @param position The local position
  23738. * @param mesh The mesh that this bone is attached to
  23739. * @param result The vector3 that the world position should be copied to
  23740. */
  23741. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  23742. /**
  23743. * Get the local position of a point that is in world space
  23744. * @param position The world position
  23745. * @param mesh The mesh that this bone is attached to
  23746. * @returns The local position
  23747. */
  23748. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  23749. /**
  23750. * Get the local position of a point that is in world space and copy it to the result param
  23751. * @param position The world position
  23752. * @param mesh The mesh that this bone is attached to
  23753. * @param result The vector3 that the local position should be copied to
  23754. */
  23755. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  23756. }
  23757. }
  23758. declare module BABYLON {
  23759. /**
  23760. * Class used to store an actual running animation
  23761. */
  23762. export class Animatable {
  23763. /** defines the target object */
  23764. target: any;
  23765. /** defines the starting frame number (default is 0) */
  23766. fromFrame: number;
  23767. /** defines the ending frame number (default is 100) */
  23768. toFrame: number;
  23769. /** defines if the animation must loop (default is false) */
  23770. loopAnimation: boolean;
  23771. /** defines a callback to call when animation ends if it is not looping */
  23772. onAnimationEnd?: (() => void) | null | undefined;
  23773. /** defines a callback to call when animation loops */
  23774. onAnimationLoop?: (() => void) | null | undefined;
  23775. private _localDelayOffset;
  23776. private _pausedDelay;
  23777. private _runtimeAnimations;
  23778. private _paused;
  23779. private _scene;
  23780. private _speedRatio;
  23781. private _weight;
  23782. private _syncRoot;
  23783. /**
  23784. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  23785. * This will only apply for non looping animation (default is true)
  23786. */
  23787. disposeOnEnd: boolean;
  23788. /**
  23789. * Gets a boolean indicating if the animation has started
  23790. */
  23791. animationStarted: boolean;
  23792. /**
  23793. * Observer raised when the animation ends
  23794. */
  23795. onAnimationEndObservable: Observable<Animatable>;
  23796. /**
  23797. * Observer raised when the animation loops
  23798. */
  23799. onAnimationLoopObservable: Observable<Animatable>;
  23800. /**
  23801. * Gets the root Animatable used to synchronize and normalize animations
  23802. */
  23803. readonly syncRoot: Animatable;
  23804. /**
  23805. * Gets the current frame of the first RuntimeAnimation
  23806. * Used to synchronize Animatables
  23807. */
  23808. readonly masterFrame: number;
  23809. /**
  23810. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  23811. */
  23812. weight: number;
  23813. /**
  23814. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  23815. */
  23816. speedRatio: number;
  23817. /**
  23818. * Creates a new Animatable
  23819. * @param scene defines the hosting scene
  23820. * @param target defines the target object
  23821. * @param fromFrame defines the starting frame number (default is 0)
  23822. * @param toFrame defines the ending frame number (default is 100)
  23823. * @param loopAnimation defines if the animation must loop (default is false)
  23824. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  23825. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  23826. * @param animations defines a group of animation to add to the new Animatable
  23827. * @param onAnimationLoop defines a callback to call when animation loops
  23828. */
  23829. constructor(scene: Scene,
  23830. /** defines the target object */
  23831. target: any,
  23832. /** defines the starting frame number (default is 0) */
  23833. fromFrame?: number,
  23834. /** defines the ending frame number (default is 100) */
  23835. toFrame?: number,
  23836. /** defines if the animation must loop (default is false) */
  23837. loopAnimation?: boolean, speedRatio?: number,
  23838. /** defines a callback to call when animation ends if it is not looping */
  23839. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  23840. /** defines a callback to call when animation loops */
  23841. onAnimationLoop?: (() => void) | null | undefined);
  23842. /**
  23843. * Synchronize and normalize current Animatable with a source Animatable
  23844. * This is useful when using animation weights and when animations are not of the same length
  23845. * @param root defines the root Animatable to synchronize with
  23846. * @returns the current Animatable
  23847. */
  23848. syncWith(root: Animatable): Animatable;
  23849. /**
  23850. * Gets the list of runtime animations
  23851. * @returns an array of RuntimeAnimation
  23852. */
  23853. getAnimations(): RuntimeAnimation[];
  23854. /**
  23855. * Adds more animations to the current animatable
  23856. * @param target defines the target of the animations
  23857. * @param animations defines the new animations to add
  23858. */
  23859. appendAnimations(target: any, animations: Animation[]): void;
  23860. /**
  23861. * Gets the source animation for a specific property
  23862. * @param property defines the propertyu to look for
  23863. * @returns null or the source animation for the given property
  23864. */
  23865. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  23866. /**
  23867. * Gets the runtime animation for a specific property
  23868. * @param property defines the propertyu to look for
  23869. * @returns null or the runtime animation for the given property
  23870. */
  23871. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  23872. /**
  23873. * Resets the animatable to its original state
  23874. */
  23875. reset(): void;
  23876. /**
  23877. * Allows the animatable to blend with current running animations
  23878. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  23879. * @param blendingSpeed defines the blending speed to use
  23880. */
  23881. enableBlending(blendingSpeed: number): void;
  23882. /**
  23883. * Disable animation blending
  23884. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  23885. */
  23886. disableBlending(): void;
  23887. /**
  23888. * Jump directly to a given frame
  23889. * @param frame defines the frame to jump to
  23890. */
  23891. goToFrame(frame: number): void;
  23892. /**
  23893. * Pause the animation
  23894. */
  23895. pause(): void;
  23896. /**
  23897. * Restart the animation
  23898. */
  23899. restart(): void;
  23900. private _raiseOnAnimationEnd;
  23901. /**
  23902. * Stop and delete the current animation
  23903. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  23904. * @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)
  23905. */
  23906. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  23907. /**
  23908. * Wait asynchronously for the animation to end
  23909. * @returns a promise which will be fullfilled when the animation ends
  23910. */
  23911. waitAsync(): Promise<Animatable>;
  23912. /** @hidden */
  23913. _animate(delay: number): boolean;
  23914. }
  23915. interface Scene {
  23916. /** @hidden */
  23917. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  23918. /** @hidden */
  23919. _processLateAnimationBindingsForMatrices(holder: {
  23920. totalWeight: number;
  23921. animations: RuntimeAnimation[];
  23922. originalValue: Matrix;
  23923. }): any;
  23924. /** @hidden */
  23925. _processLateAnimationBindingsForQuaternions(holder: {
  23926. totalWeight: number;
  23927. animations: RuntimeAnimation[];
  23928. originalValue: Quaternion;
  23929. }, refQuaternion: Quaternion): Quaternion;
  23930. /** @hidden */
  23931. _processLateAnimationBindings(): void;
  23932. /** @hidden */
  23933. _animate(): void;
  23934. /**
  23935. * Will start the animation sequence of a given target
  23936. * @param target defines the target
  23937. * @param from defines from which frame should animation start
  23938. * @param to defines until which frame should animation run.
  23939. * @param weight defines the weight to apply to the animation (1.0 by default)
  23940. * @param loop defines if the animation loops
  23941. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  23942. * @param onAnimationEnd defines the function to be executed when the animation ends
  23943. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  23944. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  23945. * @param onAnimationLoop defines the callback to call when an animation loops
  23946. * @returns the animatable object created for this animation
  23947. */
  23948. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  23949. /**
  23950. * Will start the animation sequence of a given target
  23951. * @param target defines the target
  23952. * @param from defines from which frame should animation start
  23953. * @param to defines until which frame should animation run.
  23954. * @param loop defines if the animation loops
  23955. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  23956. * @param onAnimationEnd defines the function to be executed when the animation ends
  23957. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  23958. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  23959. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  23960. * @param onAnimationLoop defines the callback to call when an animation loops
  23961. * @returns the animatable object created for this animation
  23962. */
  23963. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  23964. /**
  23965. * Will start the animation sequence of a given target and its hierarchy
  23966. * @param target defines the target
  23967. * @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.
  23968. * @param from defines from which frame should animation start
  23969. * @param to defines until which frame should animation run.
  23970. * @param loop defines if the animation loops
  23971. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  23972. * @param onAnimationEnd defines the function to be executed when the animation ends
  23973. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  23974. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  23975. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  23976. * @param onAnimationLoop defines the callback to call when an animation loops
  23977. * @returns the list of created animatables
  23978. */
  23979. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  23980. /**
  23981. * Begin a new animation on a given node
  23982. * @param target defines the target where the animation will take place
  23983. * @param animations defines the list of animations to start
  23984. * @param from defines the initial value
  23985. * @param to defines the final value
  23986. * @param loop defines if you want animation to loop (off by default)
  23987. * @param speedRatio defines the speed ratio to apply to all animations
  23988. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  23989. * @param onAnimationLoop defines the callback to call when an animation loops
  23990. * @returns the list of created animatables
  23991. */
  23992. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  23993. /**
  23994. * Begin a new animation on a given node and its hierarchy
  23995. * @param target defines the root node where the animation will take place
  23996. * @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.
  23997. * @param animations defines the list of animations to start
  23998. * @param from defines the initial value
  23999. * @param to defines the final value
  24000. * @param loop defines if you want animation to loop (off by default)
  24001. * @param speedRatio defines the speed ratio to apply to all animations
  24002. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24003. * @param onAnimationLoop defines the callback to call when an animation loops
  24004. * @returns the list of animatables created for all nodes
  24005. */
  24006. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  24007. /**
  24008. * Gets the animatable associated with a specific target
  24009. * @param target defines the target of the animatable
  24010. * @returns the required animatable if found
  24011. */
  24012. getAnimatableByTarget(target: any): Nullable<Animatable>;
  24013. /**
  24014. * Gets all animatables associated with a given target
  24015. * @param target defines the target to look animatables for
  24016. * @returns an array of Animatables
  24017. */
  24018. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  24019. /**
  24020. * Will stop the animation of the given target
  24021. * @param target - the target
  24022. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  24023. * @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)
  24024. */
  24025. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  24026. /**
  24027. * Stops and removes all animations that have been applied to the scene
  24028. */
  24029. stopAllAnimations(): void;
  24030. }
  24031. interface Bone {
  24032. /**
  24033. * Copy an animation range from another bone
  24034. * @param source defines the source bone
  24035. * @param rangeName defines the range name to copy
  24036. * @param frameOffset defines the frame offset
  24037. * @param rescaleAsRequired defines if rescaling must be applied if required
  24038. * @param skelDimensionsRatio defines the scaling ratio
  24039. * @returns true if operation was successful
  24040. */
  24041. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  24042. }
  24043. }
  24044. declare module BABYLON {
  24045. /**
  24046. * Defines how a node can be built from a string name.
  24047. */
  24048. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24049. /**
  24050. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24051. */
  24052. export class Node implements IBehaviorAware<Node> {
  24053. /** @hidden */
  24054. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24055. private static _NodeConstructors;
  24056. /**
  24057. * Add a new node constructor
  24058. * @param type defines the type name of the node to construct
  24059. * @param constructorFunc defines the constructor function
  24060. */
  24061. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24062. /**
  24063. * Returns a node constructor based on type name
  24064. * @param type defines the type name
  24065. * @param name defines the new node name
  24066. * @param scene defines the hosting scene
  24067. * @param options defines optional options to transmit to constructors
  24068. * @returns the new constructor or null
  24069. */
  24070. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24071. /**
  24072. * Gets or sets the name of the node
  24073. */
  24074. name: string;
  24075. /**
  24076. * Gets or sets the id of the node
  24077. */
  24078. id: string;
  24079. /**
  24080. * Gets or sets the unique id of the node
  24081. */
  24082. uniqueId: number;
  24083. /**
  24084. * Gets or sets a string used to store user defined state for the node
  24085. */
  24086. state: string;
  24087. /**
  24088. * Gets or sets an object used to store user defined information for the node
  24089. */
  24090. metadata: any;
  24091. /**
  24092. * For internal use only. Please do not use.
  24093. */
  24094. reservedDataStore: any;
  24095. /**
  24096. * Gets or sets a boolean used to define if the node must be serialized
  24097. */
  24098. doNotSerialize: boolean;
  24099. /** @hidden */
  24100. _isDisposed: boolean;
  24101. /**
  24102. * Gets a list of Animations associated with the node
  24103. */
  24104. animations: Animation[];
  24105. protected _ranges: {
  24106. [name: string]: Nullable<AnimationRange>;
  24107. };
  24108. /**
  24109. * Callback raised when the node is ready to be used
  24110. */
  24111. onReady: (node: Node) => void;
  24112. private _isEnabled;
  24113. private _isParentEnabled;
  24114. private _isReady;
  24115. /** @hidden */
  24116. _currentRenderId: number;
  24117. private _parentRenderId;
  24118. protected _childRenderId: number;
  24119. /** @hidden */
  24120. _waitingParentId: Nullable<string>;
  24121. /** @hidden */
  24122. _scene: Scene;
  24123. /** @hidden */
  24124. _cache: any;
  24125. private _parentNode;
  24126. private _children;
  24127. /** @hidden */
  24128. _worldMatrix: Matrix;
  24129. /** @hidden */
  24130. _worldMatrixDeterminant: number;
  24131. /** @hidden */
  24132. private _sceneRootNodesIndex;
  24133. /**
  24134. * Gets a boolean indicating if the node has been disposed
  24135. * @returns true if the node was disposed
  24136. */
  24137. isDisposed(): boolean;
  24138. /**
  24139. * Gets or sets the parent of the node
  24140. */
  24141. parent: Nullable<Node>;
  24142. private addToSceneRootNodes;
  24143. private removeFromSceneRootNodes;
  24144. private _animationPropertiesOverride;
  24145. /**
  24146. * Gets or sets the animation properties override
  24147. */
  24148. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24149. /**
  24150. * Gets a string idenfifying the name of the class
  24151. * @returns "Node" string
  24152. */
  24153. getClassName(): string;
  24154. /** @hidden */
  24155. readonly _isNode: boolean;
  24156. /**
  24157. * An event triggered when the mesh is disposed
  24158. */
  24159. onDisposeObservable: Observable<Node>;
  24160. private _onDisposeObserver;
  24161. /**
  24162. * Sets a callback that will be raised when the node will be disposed
  24163. */
  24164. onDispose: () => void;
  24165. /**
  24166. * Creates a new Node
  24167. * @param name the name and id to be given to this node
  24168. * @param scene the scene this node will be added to
  24169. * @param addToRootNodes the node will be added to scene.rootNodes
  24170. */
  24171. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24172. /**
  24173. * Gets the scene of the node
  24174. * @returns a scene
  24175. */
  24176. getScene(): Scene;
  24177. /**
  24178. * Gets the engine of the node
  24179. * @returns a Engine
  24180. */
  24181. getEngine(): Engine;
  24182. private _behaviors;
  24183. /**
  24184. * Attach a behavior to the node
  24185. * @see http://doc.babylonjs.com/features/behaviour
  24186. * @param behavior defines the behavior to attach
  24187. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24188. * @returns the current Node
  24189. */
  24190. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24191. /**
  24192. * Remove an attached behavior
  24193. * @see http://doc.babylonjs.com/features/behaviour
  24194. * @param behavior defines the behavior to attach
  24195. * @returns the current Node
  24196. */
  24197. removeBehavior(behavior: Behavior<Node>): Node;
  24198. /**
  24199. * Gets the list of attached behaviors
  24200. * @see http://doc.babylonjs.com/features/behaviour
  24201. */
  24202. readonly behaviors: Behavior<Node>[];
  24203. /**
  24204. * Gets an attached behavior by name
  24205. * @param name defines the name of the behavior to look for
  24206. * @see http://doc.babylonjs.com/features/behaviour
  24207. * @returns null if behavior was not found else the requested behavior
  24208. */
  24209. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24210. /**
  24211. * Returns the latest update of the World matrix
  24212. * @returns a Matrix
  24213. */
  24214. getWorldMatrix(): Matrix;
  24215. /** @hidden */
  24216. _getWorldMatrixDeterminant(): number;
  24217. /**
  24218. * Returns directly the latest state of the mesh World matrix.
  24219. * A Matrix is returned.
  24220. */
  24221. readonly worldMatrixFromCache: Matrix;
  24222. /** @hidden */
  24223. _initCache(): void;
  24224. /** @hidden */
  24225. updateCache(force?: boolean): void;
  24226. /** @hidden */
  24227. _updateCache(ignoreParentClass?: boolean): void;
  24228. /** @hidden */
  24229. _isSynchronized(): boolean;
  24230. /** @hidden */
  24231. _markSyncedWithParent(): void;
  24232. /** @hidden */
  24233. isSynchronizedWithParent(): boolean;
  24234. /** @hidden */
  24235. isSynchronized(): boolean;
  24236. /**
  24237. * Is this node ready to be used/rendered
  24238. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24239. * @return true if the node is ready
  24240. */
  24241. isReady(completeCheck?: boolean): boolean;
  24242. /**
  24243. * Is this node enabled?
  24244. * 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
  24245. * @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
  24246. * @return whether this node (and its parent) is enabled
  24247. */
  24248. isEnabled(checkAncestors?: boolean): boolean;
  24249. /** @hidden */
  24250. protected _syncParentEnabledState(): void;
  24251. /**
  24252. * Set the enabled state of this node
  24253. * @param value defines the new enabled state
  24254. */
  24255. setEnabled(value: boolean): void;
  24256. /**
  24257. * Is this node a descendant of the given node?
  24258. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24259. * @param ancestor defines the parent node to inspect
  24260. * @returns a boolean indicating if this node is a descendant of the given node
  24261. */
  24262. isDescendantOf(ancestor: Node): boolean;
  24263. /** @hidden */
  24264. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24265. /**
  24266. * Will return all nodes that have this node as ascendant
  24267. * @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
  24268. * @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
  24269. * @return all children nodes of all types
  24270. */
  24271. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24272. /**
  24273. * Get all child-meshes of this node
  24274. * @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
  24275. * @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
  24276. * @returns an array of AbstractMesh
  24277. */
  24278. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24279. /**
  24280. * Get all direct children of this node
  24281. * @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
  24282. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  24283. * @returns an array of Node
  24284. */
  24285. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24286. /** @hidden */
  24287. _setReady(state: boolean): void;
  24288. /**
  24289. * Get an animation by name
  24290. * @param name defines the name of the animation to look for
  24291. * @returns null if not found else the requested animation
  24292. */
  24293. getAnimationByName(name: string): Nullable<Animation>;
  24294. /**
  24295. * Creates an animation range for this node
  24296. * @param name defines the name of the range
  24297. * @param from defines the starting key
  24298. * @param to defines the end key
  24299. */
  24300. createAnimationRange(name: string, from: number, to: number): void;
  24301. /**
  24302. * Delete a specific animation range
  24303. * @param name defines the name of the range to delete
  24304. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24305. */
  24306. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24307. /**
  24308. * Get an animation range by name
  24309. * @param name defines the name of the animation range to look for
  24310. * @returns null if not found else the requested animation range
  24311. */
  24312. getAnimationRange(name: string): Nullable<AnimationRange>;
  24313. /**
  24314. * Will start the animation sequence
  24315. * @param name defines the range frames for animation sequence
  24316. * @param loop defines if the animation should loop (false by default)
  24317. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  24318. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  24319. * @returns the object created for this animation. If range does not exist, it will return null
  24320. */
  24321. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  24322. /**
  24323. * Serialize animation ranges into a JSON compatible object
  24324. * @returns serialization object
  24325. */
  24326. serializeAnimationRanges(): any;
  24327. /**
  24328. * Computes the world matrix of the node
  24329. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24330. * @returns the world matrix
  24331. */
  24332. computeWorldMatrix(force?: boolean): Matrix;
  24333. /**
  24334. * Releases resources associated with this node.
  24335. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24336. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24337. */
  24338. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24339. /**
  24340. * Parse animation range data from a serialization object and store them into a given node
  24341. * @param node defines where to store the animation ranges
  24342. * @param parsedNode defines the serialization object to read data from
  24343. * @param scene defines the hosting scene
  24344. */
  24345. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  24346. }
  24347. }
  24348. declare module BABYLON {
  24349. /**
  24350. * Class used to store any kind of animation
  24351. */
  24352. export class Animation {
  24353. /**Name of the animation */
  24354. name: string;
  24355. /**Property to animate */
  24356. targetProperty: string;
  24357. /**The frames per second of the animation */
  24358. framePerSecond: number;
  24359. /**The data type of the animation */
  24360. dataType: number;
  24361. /**The loop mode of the animation */
  24362. loopMode?: number | undefined;
  24363. /**Specifies if blending should be enabled */
  24364. enableBlending?: boolean | undefined;
  24365. /**
  24366. * Use matrix interpolation instead of using direct key value when animating matrices
  24367. */
  24368. static AllowMatricesInterpolation: boolean;
  24369. /**
  24370. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  24371. */
  24372. static AllowMatrixDecomposeForInterpolation: boolean;
  24373. /**
  24374. * Stores the key frames of the animation
  24375. */
  24376. private _keys;
  24377. /**
  24378. * Stores the easing function of the animation
  24379. */
  24380. private _easingFunction;
  24381. /**
  24382. * @hidden Internal use only
  24383. */
  24384. _runtimeAnimations: RuntimeAnimation[];
  24385. /**
  24386. * The set of event that will be linked to this animation
  24387. */
  24388. private _events;
  24389. /**
  24390. * Stores an array of target property paths
  24391. */
  24392. targetPropertyPath: string[];
  24393. /**
  24394. * Stores the blending speed of the animation
  24395. */
  24396. blendingSpeed: number;
  24397. /**
  24398. * Stores the animation ranges for the animation
  24399. */
  24400. private _ranges;
  24401. /**
  24402. * @hidden Internal use
  24403. */
  24404. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  24405. /**
  24406. * Sets up an animation
  24407. * @param property The property to animate
  24408. * @param animationType The animation type to apply
  24409. * @param framePerSecond The frames per second of the animation
  24410. * @param easingFunction The easing function used in the animation
  24411. * @returns The created animation
  24412. */
  24413. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  24414. /**
  24415. * Create and start an animation on a node
  24416. * @param name defines the name of the global animation that will be run on all nodes
  24417. * @param node defines the root node where the animation will take place
  24418. * @param targetProperty defines property to animate
  24419. * @param framePerSecond defines the number of frame per second yo use
  24420. * @param totalFrame defines the number of frames in total
  24421. * @param from defines the initial value
  24422. * @param to defines the final value
  24423. * @param loopMode defines which loop mode you want to use (off by default)
  24424. * @param easingFunction defines the easing function to use (linear by default)
  24425. * @param onAnimationEnd defines the callback to call when animation end
  24426. * @returns the animatable created for this animation
  24427. */
  24428. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24429. /**
  24430. * Create and start an animation on a node and its descendants
  24431. * @param name defines the name of the global animation that will be run on all nodes
  24432. * @param node defines the root node where the animation will take place
  24433. * @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
  24434. * @param targetProperty defines property to animate
  24435. * @param framePerSecond defines the number of frame per second to use
  24436. * @param totalFrame defines the number of frames in total
  24437. * @param from defines the initial value
  24438. * @param to defines the final value
  24439. * @param loopMode defines which loop mode you want to use (off by default)
  24440. * @param easingFunction defines the easing function to use (linear by default)
  24441. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24442. * @returns the list of animatables created for all nodes
  24443. * @example https://www.babylonjs-playground.com/#MH0VLI
  24444. */
  24445. 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[]>;
  24446. /**
  24447. * Creates a new animation, merges it with the existing animations and starts it
  24448. * @param name Name of the animation
  24449. * @param node Node which contains the scene that begins the animations
  24450. * @param targetProperty Specifies which property to animate
  24451. * @param framePerSecond The frames per second of the animation
  24452. * @param totalFrame The total number of frames
  24453. * @param from The frame at the beginning of the animation
  24454. * @param to The frame at the end of the animation
  24455. * @param loopMode Specifies the loop mode of the animation
  24456. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  24457. * @param onAnimationEnd Callback to run once the animation is complete
  24458. * @returns Nullable animation
  24459. */
  24460. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24461. /**
  24462. * Transition property of an host to the target Value
  24463. * @param property The property to transition
  24464. * @param targetValue The target Value of the property
  24465. * @param host The object where the property to animate belongs
  24466. * @param scene Scene used to run the animation
  24467. * @param frameRate Framerate (in frame/s) to use
  24468. * @param transition The transition type we want to use
  24469. * @param duration The duration of the animation, in milliseconds
  24470. * @param onAnimationEnd Callback trigger at the end of the animation
  24471. * @returns Nullable animation
  24472. */
  24473. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  24474. /**
  24475. * Return the array of runtime animations currently using this animation
  24476. */
  24477. readonly runtimeAnimations: RuntimeAnimation[];
  24478. /**
  24479. * Specifies if any of the runtime animations are currently running
  24480. */
  24481. readonly hasRunningRuntimeAnimations: boolean;
  24482. /**
  24483. * Initializes the animation
  24484. * @param name Name of the animation
  24485. * @param targetProperty Property to animate
  24486. * @param framePerSecond The frames per second of the animation
  24487. * @param dataType The data type of the animation
  24488. * @param loopMode The loop mode of the animation
  24489. * @param enableBlending Specifies if blending should be enabled
  24490. */
  24491. constructor(
  24492. /**Name of the animation */
  24493. name: string,
  24494. /**Property to animate */
  24495. targetProperty: string,
  24496. /**The frames per second of the animation */
  24497. framePerSecond: number,
  24498. /**The data type of the animation */
  24499. dataType: number,
  24500. /**The loop mode of the animation */
  24501. loopMode?: number | undefined,
  24502. /**Specifies if blending should be enabled */
  24503. enableBlending?: boolean | undefined);
  24504. /**
  24505. * Converts the animation to a string
  24506. * @param fullDetails support for multiple levels of logging within scene loading
  24507. * @returns String form of the animation
  24508. */
  24509. toString(fullDetails?: boolean): string;
  24510. /**
  24511. * Add an event to this animation
  24512. * @param event Event to add
  24513. */
  24514. addEvent(event: AnimationEvent): void;
  24515. /**
  24516. * Remove all events found at the given frame
  24517. * @param frame The frame to remove events from
  24518. */
  24519. removeEvents(frame: number): void;
  24520. /**
  24521. * Retrieves all the events from the animation
  24522. * @returns Events from the animation
  24523. */
  24524. getEvents(): AnimationEvent[];
  24525. /**
  24526. * Creates an animation range
  24527. * @param name Name of the animation range
  24528. * @param from Starting frame of the animation range
  24529. * @param to Ending frame of the animation
  24530. */
  24531. createRange(name: string, from: number, to: number): void;
  24532. /**
  24533. * Deletes an animation range by name
  24534. * @param name Name of the animation range to delete
  24535. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  24536. */
  24537. deleteRange(name: string, deleteFrames?: boolean): void;
  24538. /**
  24539. * Gets the animation range by name, or null if not defined
  24540. * @param name Name of the animation range
  24541. * @returns Nullable animation range
  24542. */
  24543. getRange(name: string): Nullable<AnimationRange>;
  24544. /**
  24545. * Gets the key frames from the animation
  24546. * @returns The key frames of the animation
  24547. */
  24548. getKeys(): Array<IAnimationKey>;
  24549. /**
  24550. * Gets the highest frame rate of the animation
  24551. * @returns Highest frame rate of the animation
  24552. */
  24553. getHighestFrame(): number;
  24554. /**
  24555. * Gets the easing function of the animation
  24556. * @returns Easing function of the animation
  24557. */
  24558. getEasingFunction(): IEasingFunction;
  24559. /**
  24560. * Sets the easing function of the animation
  24561. * @param easingFunction A custom mathematical formula for animation
  24562. */
  24563. setEasingFunction(easingFunction: EasingFunction): void;
  24564. /**
  24565. * Interpolates a scalar linearly
  24566. * @param startValue Start value of the animation curve
  24567. * @param endValue End value of the animation curve
  24568. * @param gradient Scalar amount to interpolate
  24569. * @returns Interpolated scalar value
  24570. */
  24571. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  24572. /**
  24573. * Interpolates a scalar cubically
  24574. * @param startValue Start value of the animation curve
  24575. * @param outTangent End tangent of the animation
  24576. * @param endValue End value of the animation curve
  24577. * @param inTangent Start tangent of the animation curve
  24578. * @param gradient Scalar amount to interpolate
  24579. * @returns Interpolated scalar value
  24580. */
  24581. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  24582. /**
  24583. * Interpolates a quaternion using a spherical linear interpolation
  24584. * @param startValue Start value of the animation curve
  24585. * @param endValue End value of the animation curve
  24586. * @param gradient Scalar amount to interpolate
  24587. * @returns Interpolated quaternion value
  24588. */
  24589. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  24590. /**
  24591. * Interpolates a quaternion cubically
  24592. * @param startValue Start value of the animation curve
  24593. * @param outTangent End tangent of the animation curve
  24594. * @param endValue End value of the animation curve
  24595. * @param inTangent Start tangent of the animation curve
  24596. * @param gradient Scalar amount to interpolate
  24597. * @returns Interpolated quaternion value
  24598. */
  24599. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  24600. /**
  24601. * Interpolates a Vector3 linearl
  24602. * @param startValue Start value of the animation curve
  24603. * @param endValue End value of the animation curve
  24604. * @param gradient Scalar amount to interpolate
  24605. * @returns Interpolated scalar value
  24606. */
  24607. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  24608. /**
  24609. * Interpolates a Vector3 cubically
  24610. * @param startValue Start value of the animation curve
  24611. * @param outTangent End tangent of the animation
  24612. * @param endValue End value of the animation curve
  24613. * @param inTangent Start tangent of the animation curve
  24614. * @param gradient Scalar amount to interpolate
  24615. * @returns InterpolatedVector3 value
  24616. */
  24617. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  24618. /**
  24619. * Interpolates a Vector2 linearly
  24620. * @param startValue Start value of the animation curve
  24621. * @param endValue End value of the animation curve
  24622. * @param gradient Scalar amount to interpolate
  24623. * @returns Interpolated Vector2 value
  24624. */
  24625. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  24626. /**
  24627. * Interpolates a Vector2 cubically
  24628. * @param startValue Start value of the animation curve
  24629. * @param outTangent End tangent of the animation
  24630. * @param endValue End value of the animation curve
  24631. * @param inTangent Start tangent of the animation curve
  24632. * @param gradient Scalar amount to interpolate
  24633. * @returns Interpolated Vector2 value
  24634. */
  24635. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  24636. /**
  24637. * Interpolates a size linearly
  24638. * @param startValue Start value of the animation curve
  24639. * @param endValue End value of the animation curve
  24640. * @param gradient Scalar amount to interpolate
  24641. * @returns Interpolated Size value
  24642. */
  24643. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  24644. /**
  24645. * Interpolates a Color3 linearly
  24646. * @param startValue Start value of the animation curve
  24647. * @param endValue End value of the animation curve
  24648. * @param gradient Scalar amount to interpolate
  24649. * @returns Interpolated Color3 value
  24650. */
  24651. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  24652. /**
  24653. * @hidden Internal use only
  24654. */
  24655. _getKeyValue(value: any): any;
  24656. /**
  24657. * @hidden Internal use only
  24658. */
  24659. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  24660. /**
  24661. * Defines the function to use to interpolate matrices
  24662. * @param startValue defines the start matrix
  24663. * @param endValue defines the end matrix
  24664. * @param gradient defines the gradient between both matrices
  24665. * @param result defines an optional target matrix where to store the interpolation
  24666. * @returns the interpolated matrix
  24667. */
  24668. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  24669. /**
  24670. * Makes a copy of the animation
  24671. * @returns Cloned animation
  24672. */
  24673. clone(): Animation;
  24674. /**
  24675. * Sets the key frames of the animation
  24676. * @param values The animation key frames to set
  24677. */
  24678. setKeys(values: Array<IAnimationKey>): void;
  24679. /**
  24680. * Serializes the animation to an object
  24681. * @returns Serialized object
  24682. */
  24683. serialize(): any;
  24684. /**
  24685. * Float animation type
  24686. */
  24687. private static _ANIMATIONTYPE_FLOAT;
  24688. /**
  24689. * Vector3 animation type
  24690. */
  24691. private static _ANIMATIONTYPE_VECTOR3;
  24692. /**
  24693. * Quaternion animation type
  24694. */
  24695. private static _ANIMATIONTYPE_QUATERNION;
  24696. /**
  24697. * Matrix animation type
  24698. */
  24699. private static _ANIMATIONTYPE_MATRIX;
  24700. /**
  24701. * Color3 animation type
  24702. */
  24703. private static _ANIMATIONTYPE_COLOR3;
  24704. /**
  24705. * Vector2 animation type
  24706. */
  24707. private static _ANIMATIONTYPE_VECTOR2;
  24708. /**
  24709. * Size animation type
  24710. */
  24711. private static _ANIMATIONTYPE_SIZE;
  24712. /**
  24713. * Relative Loop Mode
  24714. */
  24715. private static _ANIMATIONLOOPMODE_RELATIVE;
  24716. /**
  24717. * Cycle Loop Mode
  24718. */
  24719. private static _ANIMATIONLOOPMODE_CYCLE;
  24720. /**
  24721. * Constant Loop Mode
  24722. */
  24723. private static _ANIMATIONLOOPMODE_CONSTANT;
  24724. /**
  24725. * Get the float animation type
  24726. */
  24727. static readonly ANIMATIONTYPE_FLOAT: number;
  24728. /**
  24729. * Get the Vector3 animation type
  24730. */
  24731. static readonly ANIMATIONTYPE_VECTOR3: number;
  24732. /**
  24733. * Get the Vector2 animation type
  24734. */
  24735. static readonly ANIMATIONTYPE_VECTOR2: number;
  24736. /**
  24737. * Get the Size animation type
  24738. */
  24739. static readonly ANIMATIONTYPE_SIZE: number;
  24740. /**
  24741. * Get the Quaternion animation type
  24742. */
  24743. static readonly ANIMATIONTYPE_QUATERNION: number;
  24744. /**
  24745. * Get the Matrix animation type
  24746. */
  24747. static readonly ANIMATIONTYPE_MATRIX: number;
  24748. /**
  24749. * Get the Color3 animation type
  24750. */
  24751. static readonly ANIMATIONTYPE_COLOR3: number;
  24752. /**
  24753. * Get the Relative Loop Mode
  24754. */
  24755. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  24756. /**
  24757. * Get the Cycle Loop Mode
  24758. */
  24759. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  24760. /**
  24761. * Get the Constant Loop Mode
  24762. */
  24763. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  24764. /** @hidden */
  24765. static _UniversalLerp(left: any, right: any, amount: number): any;
  24766. /**
  24767. * Parses an animation object and creates an animation
  24768. * @param parsedAnimation Parsed animation object
  24769. * @returns Animation object
  24770. */
  24771. static Parse(parsedAnimation: any): Animation;
  24772. /**
  24773. * Appends the serialized animations from the source animations
  24774. * @param source Source containing the animations
  24775. * @param destination Target to store the animations
  24776. */
  24777. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  24778. }
  24779. }
  24780. declare module BABYLON {
  24781. /**
  24782. * Base class of all the textures in babylon.
  24783. * It groups all the common properties the materials, post process, lights... might need
  24784. * in order to make a correct use of the texture.
  24785. */
  24786. export class BaseTexture implements IAnimatable {
  24787. /**
  24788. * Default anisotropic filtering level for the application.
  24789. * It is set to 4 as a good tradeoff between perf and quality.
  24790. */
  24791. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  24792. /**
  24793. * Gets or sets the unique id of the texture
  24794. */
  24795. uniqueId: number;
  24796. /**
  24797. * Define the name of the texture.
  24798. */
  24799. name: string;
  24800. /**
  24801. * Gets or sets an object used to store user defined information.
  24802. */
  24803. metadata: any;
  24804. /**
  24805. * For internal use only. Please do not use.
  24806. */
  24807. reservedDataStore: any;
  24808. private _hasAlpha;
  24809. /**
  24810. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  24811. */
  24812. hasAlpha: boolean;
  24813. /**
  24814. * Defines if the alpha value should be determined via the rgb values.
  24815. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  24816. */
  24817. getAlphaFromRGB: boolean;
  24818. /**
  24819. * Intensity or strength of the texture.
  24820. * It is commonly used by materials to fine tune the intensity of the texture
  24821. */
  24822. level: number;
  24823. /**
  24824. * Define the UV chanel to use starting from 0 and defaulting to 0.
  24825. * This is part of the texture as textures usually maps to one uv set.
  24826. */
  24827. coordinatesIndex: number;
  24828. private _coordinatesMode;
  24829. /**
  24830. * How a texture is mapped.
  24831. *
  24832. * | Value | Type | Description |
  24833. * | ----- | ----------------------------------- | ----------- |
  24834. * | 0 | EXPLICIT_MODE | |
  24835. * | 1 | SPHERICAL_MODE | |
  24836. * | 2 | PLANAR_MODE | |
  24837. * | 3 | CUBIC_MODE | |
  24838. * | 4 | PROJECTION_MODE | |
  24839. * | 5 | SKYBOX_MODE | |
  24840. * | 6 | INVCUBIC_MODE | |
  24841. * | 7 | EQUIRECTANGULAR_MODE | |
  24842. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  24843. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  24844. */
  24845. coordinatesMode: number;
  24846. /**
  24847. * | Value | Type | Description |
  24848. * | ----- | ------------------ | ----------- |
  24849. * | 0 | CLAMP_ADDRESSMODE | |
  24850. * | 1 | WRAP_ADDRESSMODE | |
  24851. * | 2 | MIRROR_ADDRESSMODE | |
  24852. */
  24853. wrapU: number;
  24854. /**
  24855. * | Value | Type | Description |
  24856. * | ----- | ------------------ | ----------- |
  24857. * | 0 | CLAMP_ADDRESSMODE | |
  24858. * | 1 | WRAP_ADDRESSMODE | |
  24859. * | 2 | MIRROR_ADDRESSMODE | |
  24860. */
  24861. wrapV: number;
  24862. /**
  24863. * | Value | Type | Description |
  24864. * | ----- | ------------------ | ----------- |
  24865. * | 0 | CLAMP_ADDRESSMODE | |
  24866. * | 1 | WRAP_ADDRESSMODE | |
  24867. * | 2 | MIRROR_ADDRESSMODE | |
  24868. */
  24869. wrapR: number;
  24870. /**
  24871. * With compliant hardware and browser (supporting anisotropic filtering)
  24872. * this defines the level of anisotropic filtering in the texture.
  24873. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  24874. */
  24875. anisotropicFilteringLevel: number;
  24876. /**
  24877. * Define if the texture is a cube texture or if false a 2d texture.
  24878. */
  24879. isCube: boolean;
  24880. /**
  24881. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  24882. */
  24883. is3D: boolean;
  24884. /**
  24885. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  24886. * HDR texture are usually stored in linear space.
  24887. * This only impacts the PBR and Background materials
  24888. */
  24889. gammaSpace: boolean;
  24890. /**
  24891. * Gets whether or not the texture contains RGBD data.
  24892. */
  24893. readonly isRGBD: boolean;
  24894. /**
  24895. * Is Z inverted in the texture (useful in a cube texture).
  24896. */
  24897. invertZ: boolean;
  24898. /**
  24899. * Are mip maps generated for this texture or not.
  24900. */
  24901. readonly noMipmap: boolean;
  24902. /**
  24903. * @hidden
  24904. */
  24905. lodLevelInAlpha: boolean;
  24906. /**
  24907. * With prefiltered texture, defined the offset used during the prefiltering steps.
  24908. */
  24909. lodGenerationOffset: number;
  24910. /**
  24911. * With prefiltered texture, defined the scale used during the prefiltering steps.
  24912. */
  24913. lodGenerationScale: number;
  24914. /**
  24915. * Define if the texture is a render target.
  24916. */
  24917. isRenderTarget: boolean;
  24918. /**
  24919. * Define the unique id of the texture in the scene.
  24920. */
  24921. readonly uid: string;
  24922. /**
  24923. * Return a string representation of the texture.
  24924. * @returns the texture as a string
  24925. */
  24926. toString(): string;
  24927. /**
  24928. * Get the class name of the texture.
  24929. * @returns "BaseTexture"
  24930. */
  24931. getClassName(): string;
  24932. /**
  24933. * Define the list of animation attached to the texture.
  24934. */
  24935. animations: Animation[];
  24936. /**
  24937. * An event triggered when the texture is disposed.
  24938. */
  24939. onDisposeObservable: Observable<BaseTexture>;
  24940. private _onDisposeObserver;
  24941. /**
  24942. * Callback triggered when the texture has been disposed.
  24943. * Kept for back compatibility, you can use the onDisposeObservable instead.
  24944. */
  24945. onDispose: () => void;
  24946. /**
  24947. * Define the current state of the loading sequence when in delayed load mode.
  24948. */
  24949. delayLoadState: number;
  24950. private _scene;
  24951. /** @hidden */
  24952. _texture: Nullable<InternalTexture>;
  24953. private _uid;
  24954. /**
  24955. * Define if the texture is preventinga material to render or not.
  24956. * If not and the texture is not ready, the engine will use a default black texture instead.
  24957. */
  24958. readonly isBlocking: boolean;
  24959. /**
  24960. * Instantiates a new BaseTexture.
  24961. * Base class of all the textures in babylon.
  24962. * It groups all the common properties the materials, post process, lights... might need
  24963. * in order to make a correct use of the texture.
  24964. * @param scene Define the scene the texture blongs to
  24965. */
  24966. constructor(scene: Nullable<Scene>);
  24967. /**
  24968. * Get the scene the texture belongs to.
  24969. * @returns the scene or null if undefined
  24970. */
  24971. getScene(): Nullable<Scene>;
  24972. /**
  24973. * Get the texture transform matrix used to offset tile the texture for istance.
  24974. * @returns the transformation matrix
  24975. */
  24976. getTextureMatrix(): Matrix;
  24977. /**
  24978. * Get the texture reflection matrix used to rotate/transform the reflection.
  24979. * @returns the reflection matrix
  24980. */
  24981. getReflectionTextureMatrix(): Matrix;
  24982. /**
  24983. * Get the underlying lower level texture from Babylon.
  24984. * @returns the insternal texture
  24985. */
  24986. getInternalTexture(): Nullable<InternalTexture>;
  24987. /**
  24988. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  24989. * @returns true if ready or not blocking
  24990. */
  24991. isReadyOrNotBlocking(): boolean;
  24992. /**
  24993. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  24994. * @returns true if fully ready
  24995. */
  24996. isReady(): boolean;
  24997. private _cachedSize;
  24998. /**
  24999. * Get the size of the texture.
  25000. * @returns the texture size.
  25001. */
  25002. getSize(): ISize;
  25003. /**
  25004. * Get the base size of the texture.
  25005. * It can be different from the size if the texture has been resized for POT for instance
  25006. * @returns the base size
  25007. */
  25008. getBaseSize(): ISize;
  25009. /**
  25010. * Update the sampling mode of the texture.
  25011. * Default is Trilinear mode.
  25012. *
  25013. * | Value | Type | Description |
  25014. * | ----- | ------------------ | ----------- |
  25015. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25016. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25017. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25018. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25019. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25020. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25021. * | 7 | NEAREST_LINEAR | |
  25022. * | 8 | NEAREST_NEAREST | |
  25023. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25024. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25025. * | 11 | LINEAR_LINEAR | |
  25026. * | 12 | LINEAR_NEAREST | |
  25027. *
  25028. * > _mag_: magnification filter (close to the viewer)
  25029. * > _min_: minification filter (far from the viewer)
  25030. * > _mip_: filter used between mip map levels
  25031. *@param samplingMode Define the new sampling mode of the texture
  25032. */
  25033. updateSamplingMode(samplingMode: number): void;
  25034. /**
  25035. * Scales the texture if is `canRescale()`
  25036. * @param ratio the resize factor we want to use to rescale
  25037. */
  25038. scale(ratio: number): void;
  25039. /**
  25040. * Get if the texture can rescale.
  25041. */
  25042. readonly canRescale: boolean;
  25043. /** @hidden */
  25044. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  25045. /** @hidden */
  25046. _rebuild(): void;
  25047. /**
  25048. * Triggers the load sequence in delayed load mode.
  25049. */
  25050. delayLoad(): void;
  25051. /**
  25052. * Clones the texture.
  25053. * @returns the cloned texture
  25054. */
  25055. clone(): Nullable<BaseTexture>;
  25056. /**
  25057. * Get the texture underlying type (INT, FLOAT...)
  25058. */
  25059. readonly textureType: number;
  25060. /**
  25061. * Get the texture underlying format (RGB, RGBA...)
  25062. */
  25063. readonly textureFormat: number;
  25064. /**
  25065. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25066. * This will returns an RGBA array buffer containing either in values (0-255) or
  25067. * float values (0-1) depending of the underlying buffer type.
  25068. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25069. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25070. * @param buffer defines a user defined buffer to fill with data (can be null)
  25071. * @returns The Array buffer containing the pixels data.
  25072. */
  25073. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25074. /**
  25075. * Release and destroy the underlying lower level texture aka internalTexture.
  25076. */
  25077. releaseInternalTexture(): void;
  25078. /**
  25079. * Get the polynomial representation of the texture data.
  25080. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25081. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25082. */
  25083. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25084. /** @hidden */
  25085. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25086. /** @hidden */
  25087. readonly _lodTextureMid: Nullable<BaseTexture>;
  25088. /** @hidden */
  25089. readonly _lodTextureLow: Nullable<BaseTexture>;
  25090. /**
  25091. * Dispose the texture and release its associated resources.
  25092. */
  25093. dispose(): void;
  25094. /**
  25095. * Serialize the texture into a JSON representation that can be parsed later on.
  25096. * @returns the JSON representation of the texture
  25097. */
  25098. serialize(): any;
  25099. /**
  25100. * Helper function to be called back once a list of texture contains only ready textures.
  25101. * @param textures Define the list of textures to wait for
  25102. * @param callback Define the callback triggered once the entire list will be ready
  25103. */
  25104. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25105. }
  25106. }
  25107. declare module BABYLON {
  25108. /**
  25109. * Uniform buffer objects.
  25110. *
  25111. * Handles blocks of uniform on the GPU.
  25112. *
  25113. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25114. *
  25115. * For more information, please refer to :
  25116. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25117. */
  25118. export class UniformBuffer {
  25119. private _engine;
  25120. private _buffer;
  25121. private _data;
  25122. private _bufferData;
  25123. private _dynamic?;
  25124. private _uniformLocations;
  25125. private _uniformSizes;
  25126. private _uniformLocationPointer;
  25127. private _needSync;
  25128. private _noUBO;
  25129. private _currentEffect;
  25130. private static _MAX_UNIFORM_SIZE;
  25131. private static _tempBuffer;
  25132. /**
  25133. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25134. * This is dynamic to allow compat with webgl 1 and 2.
  25135. * You will need to pass the name of the uniform as well as the value.
  25136. */
  25137. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25138. /**
  25139. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25140. * This is dynamic to allow compat with webgl 1 and 2.
  25141. * You will need to pass the name of the uniform as well as the value.
  25142. */
  25143. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25144. /**
  25145. * Lambda to Update a single float in a uniform buffer.
  25146. * This is dynamic to allow compat with webgl 1 and 2.
  25147. * You will need to pass the name of the uniform as well as the value.
  25148. */
  25149. updateFloat: (name: string, x: number) => void;
  25150. /**
  25151. * Lambda to Update a vec2 of float in a uniform buffer.
  25152. * This is dynamic to allow compat with webgl 1 and 2.
  25153. * You will need to pass the name of the uniform as well as the value.
  25154. */
  25155. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25156. /**
  25157. * Lambda to Update a vec3 of float in a uniform buffer.
  25158. * This is dynamic to allow compat with webgl 1 and 2.
  25159. * You will need to pass the name of the uniform as well as the value.
  25160. */
  25161. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25162. /**
  25163. * Lambda to Update a vec4 of float in a uniform buffer.
  25164. * This is dynamic to allow compat with webgl 1 and 2.
  25165. * You will need to pass the name of the uniform as well as the value.
  25166. */
  25167. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25168. /**
  25169. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25170. * This is dynamic to allow compat with webgl 1 and 2.
  25171. * You will need to pass the name of the uniform as well as the value.
  25172. */
  25173. updateMatrix: (name: string, mat: Matrix) => void;
  25174. /**
  25175. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25176. * This is dynamic to allow compat with webgl 1 and 2.
  25177. * You will need to pass the name of the uniform as well as the value.
  25178. */
  25179. updateVector3: (name: string, vector: Vector3) => void;
  25180. /**
  25181. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25182. * This is dynamic to allow compat with webgl 1 and 2.
  25183. * You will need to pass the name of the uniform as well as the value.
  25184. */
  25185. updateVector4: (name: string, vector: Vector4) => void;
  25186. /**
  25187. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25188. * This is dynamic to allow compat with webgl 1 and 2.
  25189. * You will need to pass the name of the uniform as well as the value.
  25190. */
  25191. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25192. /**
  25193. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25194. * This is dynamic to allow compat with webgl 1 and 2.
  25195. * You will need to pass the name of the uniform as well as the value.
  25196. */
  25197. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25198. /**
  25199. * Instantiates a new Uniform buffer objects.
  25200. *
  25201. * Handles blocks of uniform on the GPU.
  25202. *
  25203. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25204. *
  25205. * For more information, please refer to :
  25206. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25207. * @param engine Define the engine the buffer is associated with
  25208. * @param data Define the data contained in the buffer
  25209. * @param dynamic Define if the buffer is updatable
  25210. */
  25211. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25212. /**
  25213. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25214. * or just falling back on setUniformXXX calls.
  25215. */
  25216. readonly useUbo: boolean;
  25217. /**
  25218. * Indicates if the WebGL underlying uniform buffer is in sync
  25219. * with the javascript cache data.
  25220. */
  25221. readonly isSync: boolean;
  25222. /**
  25223. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25224. * Also, a dynamic UniformBuffer will disable cache verification and always
  25225. * update the underlying WebGL uniform buffer to the GPU.
  25226. * @returns if Dynamic, otherwise false
  25227. */
  25228. isDynamic(): boolean;
  25229. /**
  25230. * The data cache on JS side.
  25231. * @returns the underlying data as a float array
  25232. */
  25233. getData(): Float32Array;
  25234. /**
  25235. * The underlying WebGL Uniform buffer.
  25236. * @returns the webgl buffer
  25237. */
  25238. getBuffer(): Nullable<WebGLBuffer>;
  25239. /**
  25240. * std140 layout specifies how to align data within an UBO structure.
  25241. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25242. * for specs.
  25243. */
  25244. private _fillAlignment;
  25245. /**
  25246. * Adds an uniform in the buffer.
  25247. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25248. * for the layout to be correct !
  25249. * @param name Name of the uniform, as used in the uniform block in the shader.
  25250. * @param size Data size, or data directly.
  25251. */
  25252. addUniform(name: string, size: number | number[]): void;
  25253. /**
  25254. * Adds a Matrix 4x4 to the uniform buffer.
  25255. * @param name Name of the uniform, as used in the uniform block in the shader.
  25256. * @param mat A 4x4 matrix.
  25257. */
  25258. addMatrix(name: string, mat: Matrix): void;
  25259. /**
  25260. * Adds a vec2 to the uniform buffer.
  25261. * @param name Name of the uniform, as used in the uniform block in the shader.
  25262. * @param x Define the x component value of the vec2
  25263. * @param y Define the y component value of the vec2
  25264. */
  25265. addFloat2(name: string, x: number, y: number): void;
  25266. /**
  25267. * Adds a vec3 to the uniform buffer.
  25268. * @param name Name of the uniform, as used in the uniform block in the shader.
  25269. * @param x Define the x component value of the vec3
  25270. * @param y Define the y component value of the vec3
  25271. * @param z Define the z component value of the vec3
  25272. */
  25273. addFloat3(name: string, x: number, y: number, z: number): void;
  25274. /**
  25275. * Adds a vec3 to the uniform buffer.
  25276. * @param name Name of the uniform, as used in the uniform block in the shader.
  25277. * @param color Define the vec3 from a Color
  25278. */
  25279. addColor3(name: string, color: Color3): void;
  25280. /**
  25281. * Adds a vec4 to the uniform buffer.
  25282. * @param name Name of the uniform, as used in the uniform block in the shader.
  25283. * @param color Define the rgb components from a Color
  25284. * @param alpha Define the a component of the vec4
  25285. */
  25286. addColor4(name: string, color: Color3, alpha: number): void;
  25287. /**
  25288. * Adds a vec3 to the uniform buffer.
  25289. * @param name Name of the uniform, as used in the uniform block in the shader.
  25290. * @param vector Define the vec3 components from a Vector
  25291. */
  25292. addVector3(name: string, vector: Vector3): void;
  25293. /**
  25294. * Adds a Matrix 3x3 to the uniform buffer.
  25295. * @param name Name of the uniform, as used in the uniform block in the shader.
  25296. */
  25297. addMatrix3x3(name: string): void;
  25298. /**
  25299. * Adds a Matrix 2x2 to the uniform buffer.
  25300. * @param name Name of the uniform, as used in the uniform block in the shader.
  25301. */
  25302. addMatrix2x2(name: string): void;
  25303. /**
  25304. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  25305. */
  25306. create(): void;
  25307. /** @hidden */
  25308. _rebuild(): void;
  25309. /**
  25310. * Updates the WebGL Uniform Buffer on the GPU.
  25311. * If the `dynamic` flag is set to true, no cache comparison is done.
  25312. * Otherwise, the buffer will be updated only if the cache differs.
  25313. */
  25314. update(): void;
  25315. /**
  25316. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  25317. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25318. * @param data Define the flattened data
  25319. * @param size Define the size of the data.
  25320. */
  25321. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  25322. private _updateMatrix3x3ForUniform;
  25323. private _updateMatrix3x3ForEffect;
  25324. private _updateMatrix2x2ForEffect;
  25325. private _updateMatrix2x2ForUniform;
  25326. private _updateFloatForEffect;
  25327. private _updateFloatForUniform;
  25328. private _updateFloat2ForEffect;
  25329. private _updateFloat2ForUniform;
  25330. private _updateFloat3ForEffect;
  25331. private _updateFloat3ForUniform;
  25332. private _updateFloat4ForEffect;
  25333. private _updateFloat4ForUniform;
  25334. private _updateMatrixForEffect;
  25335. private _updateMatrixForUniform;
  25336. private _updateVector3ForEffect;
  25337. private _updateVector3ForUniform;
  25338. private _updateVector4ForEffect;
  25339. private _updateVector4ForUniform;
  25340. private _updateColor3ForEffect;
  25341. private _updateColor3ForUniform;
  25342. private _updateColor4ForEffect;
  25343. private _updateColor4ForUniform;
  25344. /**
  25345. * Sets a sampler uniform on the effect.
  25346. * @param name Define the name of the sampler.
  25347. * @param texture Define the texture to set in the sampler
  25348. */
  25349. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  25350. /**
  25351. * Directly updates the value of the uniform in the cache AND on the GPU.
  25352. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25353. * @param data Define the flattened data
  25354. */
  25355. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  25356. /**
  25357. * Binds this uniform buffer to an effect.
  25358. * @param effect Define the effect to bind the buffer to
  25359. * @param name Name of the uniform block in the shader.
  25360. */
  25361. bindToEffect(effect: Effect, name: string): void;
  25362. /**
  25363. * Disposes the uniform buffer.
  25364. */
  25365. dispose(): void;
  25366. }
  25367. }
  25368. declare module BABYLON {
  25369. /**
  25370. * This represents the required contract to create a new type of texture loader.
  25371. */
  25372. export interface IInternalTextureLoader {
  25373. /**
  25374. * Defines wether the loader supports cascade loading the different faces.
  25375. */
  25376. supportCascades: boolean;
  25377. /**
  25378. * This returns if the loader support the current file information.
  25379. * @param extension defines the file extension of the file being loaded
  25380. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25381. * @param fallback defines the fallback internal texture if any
  25382. * @param isBase64 defines whether the texture is encoded as a base64
  25383. * @param isBuffer defines whether the texture data are stored as a buffer
  25384. * @returns true if the loader can load the specified file
  25385. */
  25386. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  25387. /**
  25388. * Transform the url before loading if required.
  25389. * @param rootUrl the url of the texture
  25390. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25391. * @returns the transformed texture
  25392. */
  25393. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  25394. /**
  25395. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  25396. * @param rootUrl the url of the texture
  25397. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25398. * @returns the fallback texture
  25399. */
  25400. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  25401. /**
  25402. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  25403. * @param data contains the texture data
  25404. * @param texture defines the BabylonJS internal texture
  25405. * @param createPolynomials will be true if polynomials have been requested
  25406. * @param onLoad defines the callback to trigger once the texture is ready
  25407. * @param onError defines the callback to trigger in case of error
  25408. */
  25409. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  25410. /**
  25411. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  25412. * @param data contains the texture data
  25413. * @param texture defines the BabylonJS internal texture
  25414. * @param callback defines the method to call once ready to upload
  25415. */
  25416. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  25417. }
  25418. }
  25419. declare module BABYLON {
  25420. /**
  25421. * Creation options of the multi render target texture.
  25422. */
  25423. export interface IMultiRenderTargetOptions {
  25424. /**
  25425. * Define if the texture needs to create mip maps after render.
  25426. */
  25427. generateMipMaps?: boolean;
  25428. /**
  25429. * Define the types of all the draw buffers we want to create
  25430. */
  25431. types?: number[];
  25432. /**
  25433. * Define the sampling modes of all the draw buffers we want to create
  25434. */
  25435. samplingModes?: number[];
  25436. /**
  25437. * Define if a depth buffer is required
  25438. */
  25439. generateDepthBuffer?: boolean;
  25440. /**
  25441. * Define if a stencil buffer is required
  25442. */
  25443. generateStencilBuffer?: boolean;
  25444. /**
  25445. * Define if a depth texture is required instead of a depth buffer
  25446. */
  25447. generateDepthTexture?: boolean;
  25448. /**
  25449. * Define the number of desired draw buffers
  25450. */
  25451. textureCount?: number;
  25452. /**
  25453. * Define if aspect ratio should be adapted to the texture or stay the scene one
  25454. */
  25455. doNotChangeAspectRatio?: boolean;
  25456. /**
  25457. * Define the default type of the buffers we are creating
  25458. */
  25459. defaultType?: number;
  25460. }
  25461. /**
  25462. * A multi render target, like a render target provides the ability to render to a texture.
  25463. * Unlike the render target, it can render to several draw buffers in one draw.
  25464. * This is specially interesting in deferred rendering or for any effects requiring more than
  25465. * just one color from a single pass.
  25466. */
  25467. export class MultiRenderTarget extends RenderTargetTexture {
  25468. private _internalTextures;
  25469. private _textures;
  25470. private _multiRenderTargetOptions;
  25471. /**
  25472. * Get if draw buffers are currently supported by the used hardware and browser.
  25473. */
  25474. readonly isSupported: boolean;
  25475. /**
  25476. * Get the list of textures generated by the multi render target.
  25477. */
  25478. readonly textures: Texture[];
  25479. /**
  25480. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  25481. */
  25482. readonly depthTexture: Texture;
  25483. /**
  25484. * Set the wrapping mode on U of all the textures we are rendering to.
  25485. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25486. */
  25487. wrapU: number;
  25488. /**
  25489. * Set the wrapping mode on V of all the textures we are rendering to.
  25490. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25491. */
  25492. wrapV: number;
  25493. /**
  25494. * Instantiate a new multi render target texture.
  25495. * A multi render target, like a render target provides the ability to render to a texture.
  25496. * Unlike the render target, it can render to several draw buffers in one draw.
  25497. * This is specially interesting in deferred rendering or for any effects requiring more than
  25498. * just one color from a single pass.
  25499. * @param name Define the name of the texture
  25500. * @param size Define the size of the buffers to render to
  25501. * @param count Define the number of target we are rendering into
  25502. * @param scene Define the scene the texture belongs to
  25503. * @param options Define the options used to create the multi render target
  25504. */
  25505. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  25506. /** @hidden */
  25507. _rebuild(): void;
  25508. private _createInternalTextures;
  25509. private _createTextures;
  25510. /**
  25511. * Define the number of samples used if MSAA is enabled.
  25512. */
  25513. samples: number;
  25514. /**
  25515. * Resize all the textures in the multi render target.
  25516. * Be carrefull as it will recreate all the data in the new texture.
  25517. * @param size Define the new size
  25518. */
  25519. resize(size: any): void;
  25520. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  25521. /**
  25522. * Dispose the render targets and their associated resources
  25523. */
  25524. dispose(): void;
  25525. /**
  25526. * Release all the underlying texture used as draw buffers.
  25527. */
  25528. releaseInternalTextures(): void;
  25529. }
  25530. }
  25531. declare module BABYLON {
  25532. /**
  25533. * Class used to work with sound analyzer using fast fourier transform (FFT)
  25534. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25535. */
  25536. export class Analyser {
  25537. /**
  25538. * Gets or sets the smoothing
  25539. * @ignorenaming
  25540. */
  25541. SMOOTHING: number;
  25542. /**
  25543. * Gets or sets the FFT table size
  25544. * @ignorenaming
  25545. */
  25546. FFT_SIZE: number;
  25547. /**
  25548. * Gets or sets the bar graph amplitude
  25549. * @ignorenaming
  25550. */
  25551. BARGRAPHAMPLITUDE: number;
  25552. /**
  25553. * Gets or sets the position of the debug canvas
  25554. * @ignorenaming
  25555. */
  25556. DEBUGCANVASPOS: {
  25557. x: number;
  25558. y: number;
  25559. };
  25560. /**
  25561. * Gets or sets the debug canvas size
  25562. * @ignorenaming
  25563. */
  25564. DEBUGCANVASSIZE: {
  25565. width: number;
  25566. height: number;
  25567. };
  25568. private _byteFreqs;
  25569. private _byteTime;
  25570. private _floatFreqs;
  25571. private _webAudioAnalyser;
  25572. private _debugCanvas;
  25573. private _debugCanvasContext;
  25574. private _scene;
  25575. private _registerFunc;
  25576. private _audioEngine;
  25577. /**
  25578. * Creates a new analyser
  25579. * @param scene defines hosting scene
  25580. */
  25581. constructor(scene: Scene);
  25582. /**
  25583. * Get the number of data values you will have to play with for the visualization
  25584. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  25585. * @returns a number
  25586. */
  25587. getFrequencyBinCount(): number;
  25588. /**
  25589. * Gets the current frequency data as a byte array
  25590. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25591. * @returns a Uint8Array
  25592. */
  25593. getByteFrequencyData(): Uint8Array;
  25594. /**
  25595. * Gets the current waveform as a byte array
  25596. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  25597. * @returns a Uint8Array
  25598. */
  25599. getByteTimeDomainData(): Uint8Array;
  25600. /**
  25601. * Gets the current frequency data as a float array
  25602. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25603. * @returns a Float32Array
  25604. */
  25605. getFloatFrequencyData(): Float32Array;
  25606. /**
  25607. * Renders the debug canvas
  25608. */
  25609. drawDebugCanvas(): void;
  25610. /**
  25611. * Stops rendering the debug canvas and removes it
  25612. */
  25613. stopDebugCanvas(): void;
  25614. /**
  25615. * Connects two audio nodes
  25616. * @param inputAudioNode defines first node to connect
  25617. * @param outputAudioNode defines second node to connect
  25618. */
  25619. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  25620. /**
  25621. * Releases all associated resources
  25622. */
  25623. dispose(): void;
  25624. }
  25625. }
  25626. declare module BABYLON {
  25627. /**
  25628. * This represents an audio engine and it is responsible
  25629. * to play, synchronize and analyse sounds throughout the application.
  25630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25631. */
  25632. export interface IAudioEngine extends IDisposable {
  25633. /**
  25634. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  25635. */
  25636. readonly canUseWebAudio: boolean;
  25637. /**
  25638. * Gets the current AudioContext if available.
  25639. */
  25640. readonly audioContext: Nullable<AudioContext>;
  25641. /**
  25642. * The master gain node defines the global audio volume of your audio engine.
  25643. */
  25644. readonly masterGain: GainNode;
  25645. /**
  25646. * Gets whether or not mp3 are supported by your browser.
  25647. */
  25648. readonly isMP3supported: boolean;
  25649. /**
  25650. * Gets whether or not ogg are supported by your browser.
  25651. */
  25652. readonly isOGGsupported: boolean;
  25653. /**
  25654. * Defines if Babylon should emit a warning if WebAudio is not supported.
  25655. * @ignoreNaming
  25656. */
  25657. WarnedWebAudioUnsupported: boolean;
  25658. /**
  25659. * Defines if the audio engine relies on a custom unlocked button.
  25660. * In this case, the embedded button will not be displayed.
  25661. */
  25662. useCustomUnlockedButton: boolean;
  25663. /**
  25664. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  25665. */
  25666. readonly unlocked: boolean;
  25667. /**
  25668. * Event raised when audio has been unlocked on the browser.
  25669. */
  25670. onAudioUnlockedObservable: Observable<AudioEngine>;
  25671. /**
  25672. * Event raised when audio has been locked on the browser.
  25673. */
  25674. onAudioLockedObservable: Observable<AudioEngine>;
  25675. /**
  25676. * Flags the audio engine in Locked state.
  25677. * This happens due to new browser policies preventing audio to autoplay.
  25678. */
  25679. lock(): void;
  25680. /**
  25681. * Unlocks the audio engine once a user action has been done on the dom.
  25682. * This is helpful to resume play once browser policies have been satisfied.
  25683. */
  25684. unlock(): void;
  25685. }
  25686. /**
  25687. * This represents the default audio engine used in babylon.
  25688. * It is responsible to play, synchronize and analyse sounds throughout the application.
  25689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25690. */
  25691. export class AudioEngine implements IAudioEngine {
  25692. private _audioContext;
  25693. private _audioContextInitialized;
  25694. private _muteButton;
  25695. private _hostElement;
  25696. /**
  25697. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  25698. */
  25699. canUseWebAudio: boolean;
  25700. /**
  25701. * The master gain node defines the global audio volume of your audio engine.
  25702. */
  25703. masterGain: GainNode;
  25704. /**
  25705. * Defines if Babylon should emit a warning if WebAudio is not supported.
  25706. * @ignoreNaming
  25707. */
  25708. WarnedWebAudioUnsupported: boolean;
  25709. /**
  25710. * Gets whether or not mp3 are supported by your browser.
  25711. */
  25712. isMP3supported: boolean;
  25713. /**
  25714. * Gets whether or not ogg are supported by your browser.
  25715. */
  25716. isOGGsupported: boolean;
  25717. /**
  25718. * Gets whether audio has been unlocked on the device.
  25719. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  25720. * a user interaction has happened.
  25721. */
  25722. unlocked: boolean;
  25723. /**
  25724. * Defines if the audio engine relies on a custom unlocked button.
  25725. * In this case, the embedded button will not be displayed.
  25726. */
  25727. useCustomUnlockedButton: boolean;
  25728. /**
  25729. * Event raised when audio has been unlocked on the browser.
  25730. */
  25731. onAudioUnlockedObservable: Observable<AudioEngine>;
  25732. /**
  25733. * Event raised when audio has been locked on the browser.
  25734. */
  25735. onAudioLockedObservable: Observable<AudioEngine>;
  25736. /**
  25737. * Gets the current AudioContext if available.
  25738. */
  25739. readonly audioContext: Nullable<AudioContext>;
  25740. private _connectedAnalyser;
  25741. /**
  25742. * Instantiates a new audio engine.
  25743. *
  25744. * There should be only one per page as some browsers restrict the number
  25745. * of audio contexts you can create.
  25746. * @param hostElement defines the host element where to display the mute icon if necessary
  25747. */
  25748. constructor(hostElement?: Nullable<HTMLElement>);
  25749. /**
  25750. * Flags the audio engine in Locked state.
  25751. * This happens due to new browser policies preventing audio to autoplay.
  25752. */
  25753. lock(): void;
  25754. /**
  25755. * Unlocks the audio engine once a user action has been done on the dom.
  25756. * This is helpful to resume play once browser policies have been satisfied.
  25757. */
  25758. unlock(): void;
  25759. private _resumeAudioContext;
  25760. private _initializeAudioContext;
  25761. private _tryToRun;
  25762. private _triggerRunningState;
  25763. private _triggerSuspendedState;
  25764. private _displayMuteButton;
  25765. private _moveButtonToTopLeft;
  25766. private _onResize;
  25767. private _hideMuteButton;
  25768. /**
  25769. * Destroy and release the resources associated with the audio ccontext.
  25770. */
  25771. dispose(): void;
  25772. /**
  25773. * Gets the global volume sets on the master gain.
  25774. * @returns the global volume if set or -1 otherwise
  25775. */
  25776. getGlobalVolume(): number;
  25777. /**
  25778. * Sets the global volume of your experience (sets on the master gain).
  25779. * @param newVolume Defines the new global volume of the application
  25780. */
  25781. setGlobalVolume(newVolume: number): void;
  25782. /**
  25783. * Connect the audio engine to an audio analyser allowing some amazing
  25784. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  25785. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  25786. * @param analyser The analyser to connect to the engine
  25787. */
  25788. connectToAnalyser(analyser: Analyser): void;
  25789. }
  25790. }
  25791. declare module BABYLON {
  25792. /**
  25793. * Interface used to present a loading screen while loading a scene
  25794. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  25795. */
  25796. export interface ILoadingScreen {
  25797. /**
  25798. * Function called to display the loading screen
  25799. */
  25800. displayLoadingUI: () => void;
  25801. /**
  25802. * Function called to hide the loading screen
  25803. */
  25804. hideLoadingUI: () => void;
  25805. /**
  25806. * Gets or sets the color to use for the background
  25807. */
  25808. loadingUIBackgroundColor: string;
  25809. /**
  25810. * Gets or sets the text to display while loading
  25811. */
  25812. loadingUIText: string;
  25813. }
  25814. /**
  25815. * Class used for the default loading screen
  25816. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  25817. */
  25818. export class DefaultLoadingScreen implements ILoadingScreen {
  25819. private _renderingCanvas;
  25820. private _loadingText;
  25821. private _loadingDivBackgroundColor;
  25822. private _loadingDiv;
  25823. private _loadingTextDiv;
  25824. /**
  25825. * Creates a new default loading screen
  25826. * @param _renderingCanvas defines the canvas used to render the scene
  25827. * @param _loadingText defines the default text to display
  25828. * @param _loadingDivBackgroundColor defines the default background color
  25829. */
  25830. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  25831. /**
  25832. * Function called to display the loading screen
  25833. */
  25834. displayLoadingUI(): void;
  25835. /**
  25836. * Function called to hide the loading screen
  25837. */
  25838. hideLoadingUI(): void;
  25839. /**
  25840. * Gets or sets the text to display while loading
  25841. */
  25842. loadingUIText: string;
  25843. /**
  25844. * Gets or sets the color to use for the background
  25845. */
  25846. loadingUIBackgroundColor: string;
  25847. private _resizeLoadingUI;
  25848. }
  25849. }
  25850. declare module BABYLON {
  25851. /**
  25852. * Settings for finer control over video usage
  25853. */
  25854. export interface VideoTextureSettings {
  25855. /**
  25856. * Applies `autoplay` to video, if specified
  25857. */
  25858. autoPlay?: boolean;
  25859. /**
  25860. * Applies `loop` to video, if specified
  25861. */
  25862. loop?: boolean;
  25863. /**
  25864. * Automatically updates internal texture from video at every frame in the render loop
  25865. */
  25866. autoUpdateTexture: boolean;
  25867. /**
  25868. * Image src displayed during the video loading or until the user interacts with the video.
  25869. */
  25870. poster?: string;
  25871. }
  25872. /**
  25873. * If you want to display a video in your scene, this is the special texture for that.
  25874. * This special texture works similar to other textures, with the exception of a few parameters.
  25875. * @see https://doc.babylonjs.com/how_to/video_texture
  25876. */
  25877. export class VideoTexture extends Texture {
  25878. /**
  25879. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  25880. */
  25881. readonly autoUpdateTexture: boolean;
  25882. /**
  25883. * The video instance used by the texture internally
  25884. */
  25885. readonly video: HTMLVideoElement;
  25886. private _onUserActionRequestedObservable;
  25887. /**
  25888. * Event triggerd when a dom action is required by the user to play the video.
  25889. * This happens due to recent changes in browser policies preventing video to auto start.
  25890. */
  25891. readonly onUserActionRequestedObservable: Observable<Texture>;
  25892. private _generateMipMaps;
  25893. private _engine;
  25894. private _stillImageCaptured;
  25895. private _displayingPosterTexture;
  25896. private _settings;
  25897. private _createInternalTextureOnEvent;
  25898. /**
  25899. * Creates a video texture.
  25900. * If you want to display a video in your scene, this is the special texture for that.
  25901. * This special texture works similar to other textures, with the exception of a few parameters.
  25902. * @see https://doc.babylonjs.com/how_to/video_texture
  25903. * @param name optional name, will detect from video source, if not defined
  25904. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  25905. * @param scene is obviously the current scene.
  25906. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  25907. * @param invertY is false by default but can be used to invert video on Y axis
  25908. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  25909. * @param settings allows finer control over video usage
  25910. */
  25911. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  25912. private _getName;
  25913. private _getVideo;
  25914. private _createInternalTexture;
  25915. private reset;
  25916. /**
  25917. * @hidden Internal method to initiate `update`.
  25918. */
  25919. _rebuild(): void;
  25920. /**
  25921. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  25922. */
  25923. update(): void;
  25924. /**
  25925. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  25926. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  25927. */
  25928. updateTexture(isVisible: boolean): void;
  25929. protected _updateInternalTexture: () => void;
  25930. /**
  25931. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  25932. * @param url New url.
  25933. */
  25934. updateURL(url: string): void;
  25935. /**
  25936. * Dispose the texture and release its associated resources.
  25937. */
  25938. dispose(): void;
  25939. /**
  25940. * Creates a video texture straight from your WebCam video feed.
  25941. * @param scene Define the scene the texture should be created in
  25942. * @param onReady Define a callback to triggered once the texture will be ready
  25943. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  25944. */
  25945. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  25946. minWidth: number;
  25947. maxWidth: number;
  25948. minHeight: number;
  25949. maxHeight: number;
  25950. deviceId: string;
  25951. }): void;
  25952. }
  25953. }
  25954. declare module BABYLON {
  25955. /**
  25956. * Interface for attribute information associated with buffer instanciation
  25957. */
  25958. export class InstancingAttributeInfo {
  25959. /**
  25960. * Index/offset of the attribute in the vertex shader
  25961. */
  25962. index: number;
  25963. /**
  25964. * size of the attribute, 1, 2, 3 or 4
  25965. */
  25966. attributeSize: number;
  25967. /**
  25968. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  25969. * default is FLOAT
  25970. */
  25971. attribyteType: number;
  25972. /**
  25973. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  25974. */
  25975. normalized: boolean;
  25976. /**
  25977. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  25978. */
  25979. offset: number;
  25980. /**
  25981. * Name of the GLSL attribute, for debugging purpose only
  25982. */
  25983. attributeName: string;
  25984. }
  25985. /**
  25986. * Define options used to create a depth texture
  25987. */
  25988. export class DepthTextureCreationOptions {
  25989. /** Specifies whether or not a stencil should be allocated in the texture */
  25990. generateStencil?: boolean;
  25991. /** Specifies whether or not bilinear filtering is enable on the texture */
  25992. bilinearFiltering?: boolean;
  25993. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  25994. comparisonFunction?: number;
  25995. /** Specifies if the created texture is a cube texture */
  25996. isCube?: boolean;
  25997. }
  25998. /**
  25999. * Class used to describe the capabilities of the engine relatively to the current browser
  26000. */
  26001. export class EngineCapabilities {
  26002. /** Maximum textures units per fragment shader */
  26003. maxTexturesImageUnits: number;
  26004. /** Maximum texture units per vertex shader */
  26005. maxVertexTextureImageUnits: number;
  26006. /** Maximum textures units in the entire pipeline */
  26007. maxCombinedTexturesImageUnits: number;
  26008. /** Maximum texture size */
  26009. maxTextureSize: number;
  26010. /** Maximum cube texture size */
  26011. maxCubemapTextureSize: number;
  26012. /** Maximum render texture size */
  26013. maxRenderTextureSize: number;
  26014. /** Maximum number of vertex attributes */
  26015. maxVertexAttribs: number;
  26016. /** Maximum number of varyings */
  26017. maxVaryingVectors: number;
  26018. /** Maximum number of uniforms per vertex shader */
  26019. maxVertexUniformVectors: number;
  26020. /** Maximum number of uniforms per fragment shader */
  26021. maxFragmentUniformVectors: number;
  26022. /** Defines if standard derivates (dx/dy) are supported */
  26023. standardDerivatives: boolean;
  26024. /** Defines if s3tc texture compression is supported */
  26025. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26026. /** Defines if pvrtc texture compression is supported */
  26027. pvrtc: any;
  26028. /** Defines if etc1 texture compression is supported */
  26029. etc1: any;
  26030. /** Defines if etc2 texture compression is supported */
  26031. etc2: any;
  26032. /** Defines if astc texture compression is supported */
  26033. astc: any;
  26034. /** Defines if float textures are supported */
  26035. textureFloat: boolean;
  26036. /** Defines if vertex array objects are supported */
  26037. vertexArrayObject: boolean;
  26038. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26039. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26040. /** Gets the maximum level of anisotropy supported */
  26041. maxAnisotropy: number;
  26042. /** Defines if instancing is supported */
  26043. instancedArrays: boolean;
  26044. /** Defines if 32 bits indices are supported */
  26045. uintIndices: boolean;
  26046. /** Defines if high precision shaders are supported */
  26047. highPrecisionShaderSupported: boolean;
  26048. /** Defines if depth reading in the fragment shader is supported */
  26049. fragmentDepthSupported: boolean;
  26050. /** Defines if float texture linear filtering is supported*/
  26051. textureFloatLinearFiltering: boolean;
  26052. /** Defines if rendering to float textures is supported */
  26053. textureFloatRender: boolean;
  26054. /** Defines if half float textures are supported*/
  26055. textureHalfFloat: boolean;
  26056. /** Defines if half float texture linear filtering is supported*/
  26057. textureHalfFloatLinearFiltering: boolean;
  26058. /** Defines if rendering to half float textures is supported */
  26059. textureHalfFloatRender: boolean;
  26060. /** Defines if textureLOD shader command is supported */
  26061. textureLOD: boolean;
  26062. /** Defines if draw buffers extension is supported */
  26063. drawBuffersExtension: boolean;
  26064. /** Defines if depth textures are supported */
  26065. depthTextureExtension: boolean;
  26066. /** Defines if float color buffer are supported */
  26067. colorBufferFloat: boolean;
  26068. /** Gets disjoint timer query extension (null if not supported) */
  26069. timerQuery: EXT_disjoint_timer_query;
  26070. /** Defines if timestamp can be used with timer query */
  26071. canUseTimestampForTimerQuery: boolean;
  26072. /** Function used to let the system compiles shaders in background */
  26073. parallelShaderCompile: {
  26074. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26075. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26076. COMPLETION_STATUS_KHR: number;
  26077. };
  26078. }
  26079. /** Interface defining initialization parameters for Engine class */
  26080. export interface EngineOptions extends WebGLContextAttributes {
  26081. /**
  26082. * Defines if the engine should no exceed a specified device ratio
  26083. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26084. */
  26085. limitDeviceRatio?: number;
  26086. /**
  26087. * Defines if webvr should be enabled automatically
  26088. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26089. */
  26090. autoEnableWebVR?: boolean;
  26091. /**
  26092. * Defines if webgl2 should be turned off even if supported
  26093. * @see http://doc.babylonjs.com/features/webgl2
  26094. */
  26095. disableWebGL2Support?: boolean;
  26096. /**
  26097. * Defines if webaudio should be initialized as well
  26098. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26099. */
  26100. audioEngine?: boolean;
  26101. /**
  26102. * Defines if animations should run using a deterministic lock step
  26103. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26104. */
  26105. deterministicLockstep?: boolean;
  26106. /** Defines the maximum steps to use with deterministic lock step mode */
  26107. lockstepMaxSteps?: number;
  26108. /**
  26109. * Defines that engine should ignore context lost events
  26110. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26111. */
  26112. doNotHandleContextLost?: boolean;
  26113. /**
  26114. * Defines that engine should ignore modifying touch action attribute and style
  26115. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26116. */
  26117. doNotHandleTouchAction?: boolean;
  26118. }
  26119. /**
  26120. * Defines the interface used by display changed events
  26121. */
  26122. export interface IDisplayChangedEventArgs {
  26123. /** Gets the vrDisplay object (if any) */
  26124. vrDisplay: Nullable<any>;
  26125. /** Gets a boolean indicating if webVR is supported */
  26126. vrSupported: boolean;
  26127. }
  26128. /**
  26129. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26130. */
  26131. export class Engine {
  26132. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26133. static ExceptionList: ({
  26134. key: string;
  26135. capture: string;
  26136. captureConstraint: number;
  26137. targets: string[];
  26138. } | {
  26139. key: string;
  26140. capture: null;
  26141. captureConstraint: null;
  26142. targets: string[];
  26143. })[];
  26144. /** Gets the list of created engines */
  26145. static readonly Instances: Engine[];
  26146. /**
  26147. * Gets the latest created engine
  26148. */
  26149. static readonly LastCreatedEngine: Nullable<Engine>;
  26150. /**
  26151. * Gets the latest created scene
  26152. */
  26153. static readonly LastCreatedScene: Nullable<Scene>;
  26154. /**
  26155. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26156. * @param flag defines which part of the materials must be marked as dirty
  26157. * @param predicate defines a predicate used to filter which materials should be affected
  26158. */
  26159. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26160. /**
  26161. * Hidden
  26162. */
  26163. static _TextureLoaders: IInternalTextureLoader[];
  26164. /** Defines that alpha blending is disabled */
  26165. static readonly ALPHA_DISABLE: number;
  26166. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26167. static readonly ALPHA_ADD: number;
  26168. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26169. static readonly ALPHA_COMBINE: number;
  26170. /** Defines that alpha blending to DEST - SRC * DEST */
  26171. static readonly ALPHA_SUBTRACT: number;
  26172. /** Defines that alpha blending to SRC * DEST */
  26173. static readonly ALPHA_MULTIPLY: number;
  26174. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26175. static readonly ALPHA_MAXIMIZED: number;
  26176. /** Defines that alpha blending to SRC + DEST */
  26177. static readonly ALPHA_ONEONE: number;
  26178. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26179. static readonly ALPHA_PREMULTIPLIED: number;
  26180. /**
  26181. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26182. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26183. */
  26184. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26185. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26186. static readonly ALPHA_INTERPOLATE: number;
  26187. /**
  26188. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26189. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26190. */
  26191. static readonly ALPHA_SCREENMODE: number;
  26192. /** Defines that the ressource is not delayed*/
  26193. static readonly DELAYLOADSTATE_NONE: number;
  26194. /** Defines that the ressource was successfully delay loaded */
  26195. static readonly DELAYLOADSTATE_LOADED: number;
  26196. /** Defines that the ressource is currently delay loading */
  26197. static readonly DELAYLOADSTATE_LOADING: number;
  26198. /** Defines that the ressource is delayed and has not started loading */
  26199. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26200. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26201. static readonly NEVER: number;
  26202. /** 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 */
  26203. static readonly ALWAYS: number;
  26204. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26205. static readonly LESS: number;
  26206. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26207. static readonly EQUAL: number;
  26208. /** 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 */
  26209. static readonly LEQUAL: number;
  26210. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26211. static readonly GREATER: number;
  26212. /** 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 */
  26213. static readonly GEQUAL: number;
  26214. /** 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 */
  26215. static readonly NOTEQUAL: number;
  26216. /** Passed to stencilOperation to specify that stencil value must be kept */
  26217. static readonly KEEP: number;
  26218. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26219. static readonly REPLACE: number;
  26220. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26221. static readonly INCR: number;
  26222. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26223. static readonly DECR: number;
  26224. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26225. static readonly INVERT: number;
  26226. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26227. static readonly INCR_WRAP: number;
  26228. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26229. static readonly DECR_WRAP: number;
  26230. /** Texture is not repeating outside of 0..1 UVs */
  26231. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26232. /** Texture is repeating outside of 0..1 UVs */
  26233. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26234. /** Texture is repeating and mirrored */
  26235. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26236. /** ALPHA */
  26237. static readonly TEXTUREFORMAT_ALPHA: number;
  26238. /** LUMINANCE */
  26239. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26240. /** LUMINANCE_ALPHA */
  26241. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26242. /** RGB */
  26243. static readonly TEXTUREFORMAT_RGB: number;
  26244. /** RGBA */
  26245. static readonly TEXTUREFORMAT_RGBA: number;
  26246. /** RED */
  26247. static readonly TEXTUREFORMAT_RED: number;
  26248. /** RED (2nd reference) */
  26249. static readonly TEXTUREFORMAT_R: number;
  26250. /** RG */
  26251. static readonly TEXTUREFORMAT_RG: number;
  26252. /** RED_INTEGER */
  26253. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26254. /** RED_INTEGER (2nd reference) */
  26255. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26256. /** RG_INTEGER */
  26257. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26258. /** RGB_INTEGER */
  26259. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26260. /** RGBA_INTEGER */
  26261. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26262. /** UNSIGNED_BYTE */
  26263. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26264. /** UNSIGNED_BYTE (2nd reference) */
  26265. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26266. /** FLOAT */
  26267. static readonly TEXTURETYPE_FLOAT: number;
  26268. /** HALF_FLOAT */
  26269. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26270. /** BYTE */
  26271. static readonly TEXTURETYPE_BYTE: number;
  26272. /** SHORT */
  26273. static readonly TEXTURETYPE_SHORT: number;
  26274. /** UNSIGNED_SHORT */
  26275. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26276. /** INT */
  26277. static readonly TEXTURETYPE_INT: number;
  26278. /** UNSIGNED_INT */
  26279. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26280. /** UNSIGNED_SHORT_4_4_4_4 */
  26281. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26282. /** UNSIGNED_SHORT_5_5_5_1 */
  26283. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26284. /** UNSIGNED_SHORT_5_6_5 */
  26285. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26286. /** UNSIGNED_INT_2_10_10_10_REV */
  26287. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26288. /** UNSIGNED_INT_24_8 */
  26289. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26290. /** UNSIGNED_INT_10F_11F_11F_REV */
  26291. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  26292. /** UNSIGNED_INT_5_9_9_9_REV */
  26293. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  26294. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26295. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  26296. /** nearest is mag = nearest and min = nearest and mip = linear */
  26297. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  26298. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26299. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  26300. /** Trilinear is mag = linear and min = linear and mip = linear */
  26301. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  26302. /** nearest is mag = nearest and min = nearest and mip = linear */
  26303. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  26304. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26305. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  26306. /** Trilinear is mag = linear and min = linear and mip = linear */
  26307. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  26308. /** mag = nearest and min = nearest and mip = nearest */
  26309. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  26310. /** mag = nearest and min = linear and mip = nearest */
  26311. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  26312. /** mag = nearest and min = linear and mip = linear */
  26313. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  26314. /** mag = nearest and min = linear and mip = none */
  26315. static readonly TEXTURE_NEAREST_LINEAR: number;
  26316. /** mag = nearest and min = nearest and mip = none */
  26317. static readonly TEXTURE_NEAREST_NEAREST: number;
  26318. /** mag = linear and min = nearest and mip = nearest */
  26319. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  26320. /** mag = linear and min = nearest and mip = linear */
  26321. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  26322. /** mag = linear and min = linear and mip = none */
  26323. static readonly TEXTURE_LINEAR_LINEAR: number;
  26324. /** mag = linear and min = nearest and mip = none */
  26325. static readonly TEXTURE_LINEAR_NEAREST: number;
  26326. /** Explicit coordinates mode */
  26327. static readonly TEXTURE_EXPLICIT_MODE: number;
  26328. /** Spherical coordinates mode */
  26329. static readonly TEXTURE_SPHERICAL_MODE: number;
  26330. /** Planar coordinates mode */
  26331. static readonly TEXTURE_PLANAR_MODE: number;
  26332. /** Cubic coordinates mode */
  26333. static readonly TEXTURE_CUBIC_MODE: number;
  26334. /** Projection coordinates mode */
  26335. static readonly TEXTURE_PROJECTION_MODE: number;
  26336. /** Skybox coordinates mode */
  26337. static readonly TEXTURE_SKYBOX_MODE: number;
  26338. /** Inverse Cubic coordinates mode */
  26339. static readonly TEXTURE_INVCUBIC_MODE: number;
  26340. /** Equirectangular coordinates mode */
  26341. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  26342. /** Equirectangular Fixed coordinates mode */
  26343. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  26344. /** Equirectangular Fixed Mirrored coordinates mode */
  26345. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  26346. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  26347. static readonly SCALEMODE_FLOOR: number;
  26348. /** Defines that texture rescaling will look for the nearest power of 2 size */
  26349. static readonly SCALEMODE_NEAREST: number;
  26350. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  26351. static readonly SCALEMODE_CEILING: number;
  26352. /**
  26353. * Returns the current version of the framework
  26354. */
  26355. static readonly Version: string;
  26356. /**
  26357. * Returns a string describing the current engine
  26358. */
  26359. readonly description: string;
  26360. /**
  26361. * Gets or sets the epsilon value used by collision engine
  26362. */
  26363. static CollisionsEpsilon: number;
  26364. /**
  26365. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  26366. */
  26367. static ShadersRepository: string;
  26368. /**
  26369. * Method called to create the default loading screen.
  26370. * This can be overriden in your own app.
  26371. * @param canvas The rendering canvas element
  26372. * @returns The loading screen
  26373. */
  26374. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  26375. /**
  26376. * Method called to create the default rescale post process on each engine.
  26377. */
  26378. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  26379. /**
  26380. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  26381. */
  26382. forcePOTTextures: boolean;
  26383. /**
  26384. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  26385. */
  26386. isFullscreen: boolean;
  26387. /**
  26388. * Gets a boolean indicating if the pointer is currently locked
  26389. */
  26390. isPointerLock: boolean;
  26391. /**
  26392. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  26393. */
  26394. cullBackFaces: boolean;
  26395. /**
  26396. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  26397. */
  26398. renderEvenInBackground: boolean;
  26399. /**
  26400. * Gets or sets a boolean indicating that cache can be kept between frames
  26401. */
  26402. preventCacheWipeBetweenFrames: boolean;
  26403. /**
  26404. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  26405. **/
  26406. enableOfflineSupport: boolean;
  26407. /**
  26408. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (js will always consider the database is up to date)
  26409. **/
  26410. disableManifestCheck: boolean;
  26411. /**
  26412. * Gets the list of created scenes
  26413. */
  26414. scenes: Scene[];
  26415. /**
  26416. * Event raised when a new scene is created
  26417. */
  26418. onNewSceneAddedObservable: Observable<Scene>;
  26419. /**
  26420. * Gets the list of created postprocesses
  26421. */
  26422. postProcesses: PostProcess[];
  26423. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  26424. validateShaderPrograms: boolean;
  26425. /**
  26426. * Observable event triggered each time the rendering canvas is resized
  26427. */
  26428. onResizeObservable: Observable<Engine>;
  26429. /**
  26430. * Observable event triggered each time the canvas loses focus
  26431. */
  26432. onCanvasBlurObservable: Observable<Engine>;
  26433. /**
  26434. * Observable event triggered each time the canvas gains focus
  26435. */
  26436. onCanvasFocusObservable: Observable<Engine>;
  26437. /**
  26438. * Observable event triggered each time the canvas receives pointerout event
  26439. */
  26440. onCanvasPointerOutObservable: Observable<PointerEvent>;
  26441. /**
  26442. * Observable event triggered before each texture is initialized
  26443. */
  26444. onBeforeTextureInitObservable: Observable<Texture>;
  26445. private _vrDisplay;
  26446. private _vrSupported;
  26447. private _oldSize;
  26448. private _oldHardwareScaleFactor;
  26449. private _vrExclusivePointerMode;
  26450. private _webVRInitPromise;
  26451. /**
  26452. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  26453. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  26454. */
  26455. readonly isInVRExclusivePointerMode: boolean;
  26456. /**
  26457. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  26458. */
  26459. disableUniformBuffers: boolean;
  26460. /** @hidden */
  26461. _uniformBuffers: UniformBuffer[];
  26462. /**
  26463. * Gets a boolean indicating that the engine supports uniform buffers
  26464. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  26465. */
  26466. readonly supportsUniformBuffers: boolean;
  26467. /**
  26468. * Observable raised when the engine begins a new frame
  26469. */
  26470. onBeginFrameObservable: Observable<Engine>;
  26471. /**
  26472. * If set, will be used to request the next animation frame for the render loop
  26473. */
  26474. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  26475. /**
  26476. * Observable raised when the engine ends the current frame
  26477. */
  26478. onEndFrameObservable: Observable<Engine>;
  26479. /**
  26480. * Observable raised when the engine is about to compile a shader
  26481. */
  26482. onBeforeShaderCompilationObservable: Observable<Engine>;
  26483. /**
  26484. * Observable raised when the engine has jsut compiled a shader
  26485. */
  26486. onAfterShaderCompilationObservable: Observable<Engine>;
  26487. /** @hidden */
  26488. _gl: WebGLRenderingContext;
  26489. private _renderingCanvas;
  26490. private _windowIsBackground;
  26491. private _webGLVersion;
  26492. /**
  26493. * Gets a boolean indicating that only power of 2 textures are supported
  26494. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  26495. */
  26496. readonly needPOTTextures: boolean;
  26497. /** @hidden */
  26498. _badOS: boolean;
  26499. /** @hidden */
  26500. _badDesktopOS: boolean;
  26501. /**
  26502. * Gets or sets a value indicating if we want to disable texture binding optimization.
  26503. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  26504. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  26505. */
  26506. disableTextureBindingOptimization: boolean;
  26507. /**
  26508. * Gets the audio engine
  26509. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26510. * @ignorenaming
  26511. */
  26512. static audioEngine: IAudioEngine;
  26513. /**
  26514. * Default AudioEngine factory responsible of creating the Audio Engine.
  26515. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  26516. */
  26517. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  26518. /**
  26519. * Default offline support factory responsible of creating a tool used to store data locally.
  26520. * By default, this will create a Database object if the workload has been embedded.
  26521. */
  26522. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  26523. private _onFocus;
  26524. private _onBlur;
  26525. private _onCanvasPointerOut;
  26526. private _onCanvasBlur;
  26527. private _onCanvasFocus;
  26528. private _onFullscreenChange;
  26529. private _onPointerLockChange;
  26530. private _onVRDisplayPointerRestricted;
  26531. private _onVRDisplayPointerUnrestricted;
  26532. private _onVrDisplayConnect;
  26533. private _onVrDisplayDisconnect;
  26534. private _onVrDisplayPresentChange;
  26535. /**
  26536. * Observable signaled when VR display mode changes
  26537. */
  26538. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  26539. /**
  26540. * Observable signaled when VR request present is complete
  26541. */
  26542. onVRRequestPresentComplete: Observable<boolean>;
  26543. /**
  26544. * Observable signaled when VR request present starts
  26545. */
  26546. onVRRequestPresentStart: Observable<Engine>;
  26547. private _hardwareScalingLevel;
  26548. /** @hidden */
  26549. protected _caps: EngineCapabilities;
  26550. private _pointerLockRequested;
  26551. private _isStencilEnable;
  26552. private _colorWrite;
  26553. private _loadingScreen;
  26554. /** @hidden */
  26555. _drawCalls: PerfCounter;
  26556. /** @hidden */
  26557. _textureCollisions: PerfCounter;
  26558. private _glVersion;
  26559. private _glRenderer;
  26560. private _glVendor;
  26561. private _videoTextureSupported;
  26562. private _renderingQueueLaunched;
  26563. private _activeRenderLoops;
  26564. private _deterministicLockstep;
  26565. private _lockstepMaxSteps;
  26566. /**
  26567. * Observable signaled when a context lost event is raised
  26568. */
  26569. onContextLostObservable: Observable<Engine>;
  26570. /**
  26571. * Observable signaled when a context restored event is raised
  26572. */
  26573. onContextRestoredObservable: Observable<Engine>;
  26574. private _onContextLost;
  26575. private _onContextRestored;
  26576. private _contextWasLost;
  26577. private _doNotHandleContextLost;
  26578. /**
  26579. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  26580. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  26581. */
  26582. doNotHandleContextLost: boolean;
  26583. private _performanceMonitor;
  26584. private _fps;
  26585. private _deltaTime;
  26586. /**
  26587. * Turn this value on if you want to pause FPS computation when in background
  26588. */
  26589. disablePerformanceMonitorInBackground: boolean;
  26590. /**
  26591. * Gets the performance monitor attached to this engine
  26592. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  26593. */
  26594. readonly performanceMonitor: PerformanceMonitor;
  26595. /** @hidden */
  26596. protected _depthCullingState: _DepthCullingState;
  26597. /** @hidden */
  26598. protected _stencilState: _StencilState;
  26599. /** @hidden */
  26600. protected _alphaState: _AlphaState;
  26601. /** @hidden */
  26602. protected _alphaMode: number;
  26603. protected _internalTexturesCache: InternalTexture[];
  26604. /** @hidden */
  26605. protected _activeChannel: number;
  26606. private _currentTextureChannel;
  26607. /** @hidden */
  26608. protected _boundTexturesCache: {
  26609. [key: string]: Nullable<InternalTexture>;
  26610. };
  26611. /** @hidden */
  26612. protected _currentEffect: Nullable<Effect>;
  26613. /** @hidden */
  26614. protected _currentProgram: Nullable<WebGLProgram>;
  26615. private _compiledEffects;
  26616. private _vertexAttribArraysEnabled;
  26617. /** @hidden */
  26618. protected _cachedViewport: Nullable<Viewport>;
  26619. private _cachedVertexArrayObject;
  26620. /** @hidden */
  26621. protected _cachedVertexBuffers: any;
  26622. /** @hidden */
  26623. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  26624. /** @hidden */
  26625. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  26626. /** @hidden */
  26627. protected _currentRenderTarget: Nullable<InternalTexture>;
  26628. private _uintIndicesCurrentlySet;
  26629. private _currentBoundBuffer;
  26630. /** @hidden */
  26631. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  26632. private _currentBufferPointers;
  26633. private _currentInstanceLocations;
  26634. private _currentInstanceBuffers;
  26635. private _textureUnits;
  26636. private _firstBoundInternalTextureTracker;
  26637. private _lastBoundInternalTextureTracker;
  26638. private _workingCanvas;
  26639. private _workingContext;
  26640. private _rescalePostProcess;
  26641. private _dummyFramebuffer;
  26642. private _externalData;
  26643. private _bindedRenderFunction;
  26644. private _vaoRecordInProgress;
  26645. private _mustWipeVertexAttributes;
  26646. private _emptyTexture;
  26647. private _emptyCubeTexture;
  26648. private _emptyTexture3D;
  26649. /** @hidden */
  26650. _frameHandler: number;
  26651. private _nextFreeTextureSlots;
  26652. private _maxSimultaneousTextures;
  26653. private _activeRequests;
  26654. private _texturesSupported;
  26655. private _textureFormatInUse;
  26656. /**
  26657. * Gets the list of texture formats supported
  26658. */
  26659. readonly texturesSupported: Array<string>;
  26660. /**
  26661. * Gets the list of texture formats in use
  26662. */
  26663. readonly textureFormatInUse: Nullable<string>;
  26664. /**
  26665. * Gets the current viewport
  26666. */
  26667. readonly currentViewport: Nullable<Viewport>;
  26668. /**
  26669. * Gets the default empty texture
  26670. */
  26671. readonly emptyTexture: InternalTexture;
  26672. /**
  26673. * Gets the default empty 3D texture
  26674. */
  26675. readonly emptyTexture3D: InternalTexture;
  26676. /**
  26677. * Gets the default empty cube texture
  26678. */
  26679. readonly emptyCubeTexture: InternalTexture;
  26680. /**
  26681. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  26682. */
  26683. readonly premultipliedAlpha: boolean;
  26684. /**
  26685. * Creates a new engine
  26686. * @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
  26687. * @param antialias defines enable antialiasing (default: false)
  26688. * @param options defines further options to be sent to the getContext() function
  26689. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  26690. */
  26691. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  26692. private _disableTouchAction;
  26693. private _rebuildInternalTextures;
  26694. private _rebuildEffects;
  26695. /**
  26696. * Gets a boolean indicating if all created effects are ready
  26697. * @returns true if all effects are ready
  26698. */
  26699. areAllEffectsReady(): boolean;
  26700. private _rebuildBuffers;
  26701. private _initGLContext;
  26702. /**
  26703. * Gets version of the current webGL context
  26704. */
  26705. readonly webGLVersion: number;
  26706. /**
  26707. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  26708. */
  26709. readonly isStencilEnable: boolean;
  26710. private _prepareWorkingCanvas;
  26711. /**
  26712. * Reset the texture cache to empty state
  26713. */
  26714. resetTextureCache(): void;
  26715. /**
  26716. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  26717. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26718. * @returns true if engine is in deterministic lock step mode
  26719. */
  26720. isDeterministicLockStep(): boolean;
  26721. /**
  26722. * Gets the max steps when engine is running in deterministic lock step
  26723. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26724. * @returns the max steps
  26725. */
  26726. getLockstepMaxSteps(): number;
  26727. /**
  26728. * Gets an object containing information about the current webGL context
  26729. * @returns an object containing the vender, the renderer and the version of the current webGL context
  26730. */
  26731. getGlInfo(): {
  26732. vendor: string;
  26733. renderer: string;
  26734. version: string;
  26735. };
  26736. /**
  26737. * Gets current aspect ratio
  26738. * @param camera defines the camera to use to get the aspect ratio
  26739. * @param useScreen defines if screen size must be used (or the current render target if any)
  26740. * @returns a number defining the aspect ratio
  26741. */
  26742. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  26743. /**
  26744. * Gets current screen aspect ratio
  26745. * @returns a number defining the aspect ratio
  26746. */
  26747. getScreenAspectRatio(): number;
  26748. /**
  26749. * Gets the current render width
  26750. * @param useScreen defines if screen size must be used (or the current render target if any)
  26751. * @returns a number defining the current render width
  26752. */
  26753. getRenderWidth(useScreen?: boolean): number;
  26754. /**
  26755. * Gets the current render height
  26756. * @param useScreen defines if screen size must be used (or the current render target if any)
  26757. * @returns a number defining the current render height
  26758. */
  26759. getRenderHeight(useScreen?: boolean): number;
  26760. /**
  26761. * Gets the HTML canvas attached with the current webGL context
  26762. * @returns a HTML canvas
  26763. */
  26764. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  26765. /**
  26766. * Gets the client rect of the HTML canvas attached with the current webGL context
  26767. * @returns a client rectanglee
  26768. */
  26769. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  26770. /**
  26771. * Defines the hardware scaling level.
  26772. * By default the hardware scaling level is computed from the window device ratio.
  26773. * 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.
  26774. * @param level defines the level to use
  26775. */
  26776. setHardwareScalingLevel(level: number): void;
  26777. /**
  26778. * Gets the current hardware scaling level.
  26779. * By default the hardware scaling level is computed from the window device ratio.
  26780. * 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.
  26781. * @returns a number indicating the current hardware scaling level
  26782. */
  26783. getHardwareScalingLevel(): number;
  26784. /**
  26785. * Gets the list of loaded textures
  26786. * @returns an array containing all loaded textures
  26787. */
  26788. getLoadedTexturesCache(): InternalTexture[];
  26789. /**
  26790. * Gets the object containing all engine capabilities
  26791. * @returns the EngineCapabilities object
  26792. */
  26793. getCaps(): EngineCapabilities;
  26794. /**
  26795. * Gets the current depth function
  26796. * @returns a number defining the depth function
  26797. */
  26798. getDepthFunction(): Nullable<number>;
  26799. /**
  26800. * Sets the current depth function
  26801. * @param depthFunc defines the function to use
  26802. */
  26803. setDepthFunction(depthFunc: number): void;
  26804. /**
  26805. * Sets the current depth function to GREATER
  26806. */
  26807. setDepthFunctionToGreater(): void;
  26808. /**
  26809. * Sets the current depth function to GEQUAL
  26810. */
  26811. setDepthFunctionToGreaterOrEqual(): void;
  26812. /**
  26813. * Sets the current depth function to LESS
  26814. */
  26815. setDepthFunctionToLess(): void;
  26816. /**
  26817. * Sets the current depth function to LEQUAL
  26818. */
  26819. setDepthFunctionToLessOrEqual(): void;
  26820. /**
  26821. * Gets a boolean indicating if stencil buffer is enabled
  26822. * @returns the current stencil buffer state
  26823. */
  26824. getStencilBuffer(): boolean;
  26825. /**
  26826. * Enable or disable the stencil buffer
  26827. * @param enable defines if the stencil buffer must be enabled or disabled
  26828. */
  26829. setStencilBuffer(enable: boolean): void;
  26830. /**
  26831. * Gets the current stencil mask
  26832. * @returns a number defining the new stencil mask to use
  26833. */
  26834. getStencilMask(): number;
  26835. /**
  26836. * Sets the current stencil mask
  26837. * @param mask defines the new stencil mask to use
  26838. */
  26839. setStencilMask(mask: number): void;
  26840. /**
  26841. * Gets the current stencil function
  26842. * @returns a number defining the stencil function to use
  26843. */
  26844. getStencilFunction(): number;
  26845. /**
  26846. * Gets the current stencil reference value
  26847. * @returns a number defining the stencil reference value to use
  26848. */
  26849. getStencilFunctionReference(): number;
  26850. /**
  26851. * Gets the current stencil mask
  26852. * @returns a number defining the stencil mask to use
  26853. */
  26854. getStencilFunctionMask(): number;
  26855. /**
  26856. * Sets the current stencil function
  26857. * @param stencilFunc defines the new stencil function to use
  26858. */
  26859. setStencilFunction(stencilFunc: number): void;
  26860. /**
  26861. * Sets the current stencil reference
  26862. * @param reference defines the new stencil reference to use
  26863. */
  26864. setStencilFunctionReference(reference: number): void;
  26865. /**
  26866. * Sets the current stencil mask
  26867. * @param mask defines the new stencil mask to use
  26868. */
  26869. setStencilFunctionMask(mask: number): void;
  26870. /**
  26871. * Gets the current stencil operation when stencil fails
  26872. * @returns a number defining stencil operation to use when stencil fails
  26873. */
  26874. getStencilOperationFail(): number;
  26875. /**
  26876. * Gets the current stencil operation when depth fails
  26877. * @returns a number defining stencil operation to use when depth fails
  26878. */
  26879. getStencilOperationDepthFail(): number;
  26880. /**
  26881. * Gets the current stencil operation when stencil passes
  26882. * @returns a number defining stencil operation to use when stencil passes
  26883. */
  26884. getStencilOperationPass(): number;
  26885. /**
  26886. * Sets the stencil operation to use when stencil fails
  26887. * @param operation defines the stencil operation to use when stencil fails
  26888. */
  26889. setStencilOperationFail(operation: number): void;
  26890. /**
  26891. * Sets the stencil operation to use when depth fails
  26892. * @param operation defines the stencil operation to use when depth fails
  26893. */
  26894. setStencilOperationDepthFail(operation: number): void;
  26895. /**
  26896. * Sets the stencil operation to use when stencil passes
  26897. * @param operation defines the stencil operation to use when stencil passes
  26898. */
  26899. setStencilOperationPass(operation: number): void;
  26900. /**
  26901. * Sets a boolean indicating if the dithering state is enabled or disabled
  26902. * @param value defines the dithering state
  26903. */
  26904. setDitheringState(value: boolean): void;
  26905. /**
  26906. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  26907. * @param value defines the rasterizer state
  26908. */
  26909. setRasterizerState(value: boolean): void;
  26910. /**
  26911. * stop executing a render loop function and remove it from the execution array
  26912. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  26913. */
  26914. stopRenderLoop(renderFunction?: () => void): void;
  26915. /** @hidden */
  26916. _renderLoop(): void;
  26917. /**
  26918. * Register and execute a render loop. The engine can have more than one render function
  26919. * @param renderFunction defines the function to continuously execute
  26920. */
  26921. runRenderLoop(renderFunction: () => void): void;
  26922. /**
  26923. * Toggle full screen mode
  26924. * @param requestPointerLock defines if a pointer lock should be requested from the user
  26925. */
  26926. switchFullscreen(requestPointerLock: boolean): void;
  26927. /**
  26928. * Clear the current render buffer or the current render target (if any is set up)
  26929. * @param color defines the color to use
  26930. * @param backBuffer defines if the back buffer must be cleared
  26931. * @param depth defines if the depth buffer must be cleared
  26932. * @param stencil defines if the stencil buffer must be cleared
  26933. */
  26934. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  26935. /**
  26936. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  26937. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  26938. * @param y defines the y-coordinate of the corner of the clear rectangle
  26939. * @param width defines the width of the clear rectangle
  26940. * @param height defines the height of the clear rectangle
  26941. * @param clearColor defines the clear color
  26942. */
  26943. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  26944. /**
  26945. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  26946. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  26947. * @param y defines the y-coordinate of the corner of the clear rectangle
  26948. * @param width defines the width of the clear rectangle
  26949. * @param height defines the height of the clear rectangle
  26950. */
  26951. enableScissor(x: number, y: number, width: number, height: number): void;
  26952. /**
  26953. * Disable previously set scissor test rectangle
  26954. */
  26955. disableScissor(): void;
  26956. private _viewportCached;
  26957. /** @hidden */
  26958. _viewport(x: number, y: number, width: number, height: number): void;
  26959. /**
  26960. * Set the WebGL's viewport
  26961. * @param viewport defines the viewport element to be used
  26962. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  26963. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  26964. */
  26965. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  26966. /**
  26967. * Directly set the WebGL Viewport
  26968. * @param x defines the x coordinate of the viewport (in screen space)
  26969. * @param y defines the y coordinate of the viewport (in screen space)
  26970. * @param width defines the width of the viewport (in screen space)
  26971. * @param height defines the height of the viewport (in screen space)
  26972. * @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
  26973. */
  26974. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  26975. /**
  26976. * Begin a new frame
  26977. */
  26978. beginFrame(): void;
  26979. /**
  26980. * Enf the current frame
  26981. */
  26982. endFrame(): void;
  26983. /**
  26984. * Resize the view according to the canvas' size
  26985. */
  26986. resize(): void;
  26987. /**
  26988. * Force a specific size of the canvas
  26989. * @param width defines the new canvas' width
  26990. * @param height defines the new canvas' height
  26991. */
  26992. setSize(width: number, height: number): void;
  26993. /**
  26994. * Gets a boolean indicating if a webVR device was detected
  26995. * @returns true if a webVR device was detected
  26996. */
  26997. isVRDevicePresent(): boolean;
  26998. /**
  26999. * Gets the current webVR device
  27000. * @returns the current webVR device (or null)
  27001. */
  27002. getVRDevice(): any;
  27003. /**
  27004. * Initializes a webVR display and starts listening to display change events
  27005. * The onVRDisplayChangedObservable will be notified upon these changes
  27006. * @returns The onVRDisplayChangedObservable
  27007. */
  27008. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27009. /**
  27010. * Initializes a webVR display and starts listening to display change events
  27011. * The onVRDisplayChangedObservable will be notified upon these changes
  27012. * @returns A promise containing a VRDisplay and if vr is supported
  27013. */
  27014. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27015. /**
  27016. * Call this function to switch to webVR mode
  27017. * Will do nothing if webVR is not supported or if there is no webVR device
  27018. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27019. */
  27020. enableVR(): void;
  27021. /**
  27022. * Call this function to leave webVR mode
  27023. * Will do nothing if webVR is not supported or if there is no webVR device
  27024. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27025. */
  27026. disableVR(): void;
  27027. private _onVRFullScreenTriggered;
  27028. private _getVRDisplaysAsync;
  27029. /**
  27030. * Binds the frame buffer to the specified texture.
  27031. * @param texture The texture to render to or null for the default canvas
  27032. * @param faceIndex The face of the texture to render to in case of cube texture
  27033. * @param requiredWidth The width of the target to render to
  27034. * @param requiredHeight The height of the target to render to
  27035. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27036. * @param depthStencilTexture The depth stencil texture to use to render
  27037. * @param lodLevel defines le lod level to bind to the frame buffer
  27038. */
  27039. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27040. private bindUnboundFramebuffer;
  27041. /**
  27042. * Unbind the current render target texture from the webGL context
  27043. * @param texture defines the render target texture to unbind
  27044. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27045. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27046. */
  27047. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27048. /**
  27049. * Unbind a list of render target textures from the webGL context
  27050. * This is used only when drawBuffer extension or webGL2 are active
  27051. * @param textures defines the render target textures to unbind
  27052. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27053. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27054. */
  27055. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27056. /**
  27057. * Force the mipmap generation for the given render target texture
  27058. * @param texture defines the render target texture to use
  27059. */
  27060. generateMipMapsForCubemap(texture: InternalTexture): void;
  27061. /**
  27062. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27063. */
  27064. flushFramebuffer(): void;
  27065. /**
  27066. * Unbind the current render target and bind the default framebuffer
  27067. */
  27068. restoreDefaultFramebuffer(): void;
  27069. /**
  27070. * Create an uniform buffer
  27071. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27072. * @param elements defines the content of the uniform buffer
  27073. * @returns the webGL uniform buffer
  27074. */
  27075. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27076. /**
  27077. * Create a dynamic uniform buffer
  27078. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27079. * @param elements defines the content of the uniform buffer
  27080. * @returns the webGL uniform buffer
  27081. */
  27082. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27083. /**
  27084. * Update an existing uniform buffer
  27085. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27086. * @param uniformBuffer defines the target uniform buffer
  27087. * @param elements defines the content to update
  27088. * @param offset defines the offset in the uniform buffer where update should start
  27089. * @param count defines the size of the data to update
  27090. */
  27091. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27092. private _resetVertexBufferBinding;
  27093. /**
  27094. * Creates a vertex buffer
  27095. * @param data the data for the vertex buffer
  27096. * @returns the new WebGL static buffer
  27097. */
  27098. createVertexBuffer(data: DataArray): WebGLBuffer;
  27099. /**
  27100. * Creates a dynamic vertex buffer
  27101. * @param data the data for the dynamic vertex buffer
  27102. * @returns the new WebGL dynamic buffer
  27103. */
  27104. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27105. /**
  27106. * Update a dynamic index buffer
  27107. * @param indexBuffer defines the target index buffer
  27108. * @param indices defines the data to update
  27109. * @param offset defines the offset in the target index buffer where update should start
  27110. */
  27111. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27112. /**
  27113. * Updates a dynamic vertex buffer.
  27114. * @param vertexBuffer the vertex buffer to update
  27115. * @param data the data used to update the vertex buffer
  27116. * @param byteOffset the byte offset of the data
  27117. * @param byteLength the byte length of the data
  27118. */
  27119. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27120. private _resetIndexBufferBinding;
  27121. /**
  27122. * Creates a new index buffer
  27123. * @param indices defines the content of the index buffer
  27124. * @param updatable defines if the index buffer must be updatable
  27125. * @returns a new webGL buffer
  27126. */
  27127. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27128. /**
  27129. * Bind a webGL buffer to the webGL context
  27130. * @param buffer defines the buffer to bind
  27131. */
  27132. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27133. /**
  27134. * Bind an uniform buffer to the current webGL context
  27135. * @param buffer defines the buffer to bind
  27136. */
  27137. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27138. /**
  27139. * Bind a buffer to the current webGL context at a given location
  27140. * @param buffer defines the buffer to bind
  27141. * @param location defines the index where to bind the buffer
  27142. */
  27143. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27144. /**
  27145. * Bind a specific block at a given index in a specific shader program
  27146. * @param shaderProgram defines the shader program
  27147. * @param blockName defines the block name
  27148. * @param index defines the index where to bind the block
  27149. */
  27150. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27151. private bindIndexBuffer;
  27152. private bindBuffer;
  27153. /**
  27154. * update the bound buffer with the given data
  27155. * @param data defines the data to update
  27156. */
  27157. updateArrayBuffer(data: Float32Array): void;
  27158. private _vertexAttribPointer;
  27159. private _bindIndexBufferWithCache;
  27160. private _bindVertexBuffersAttributes;
  27161. /**
  27162. * Records a vertex array object
  27163. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27164. * @param vertexBuffers defines the list of vertex buffers to store
  27165. * @param indexBuffer defines the index buffer to store
  27166. * @param effect defines the effect to store
  27167. * @returns the new vertex array object
  27168. */
  27169. recordVertexArrayObject(vertexBuffers: {
  27170. [key: string]: VertexBuffer;
  27171. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27172. /**
  27173. * Bind a specific vertex array object
  27174. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27175. * @param vertexArrayObject defines the vertex array object to bind
  27176. * @param indexBuffer defines the index buffer to bind
  27177. */
  27178. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27179. /**
  27180. * Bind webGl buffers directly to the webGL context
  27181. * @param vertexBuffer defines the vertex buffer to bind
  27182. * @param indexBuffer defines the index buffer to bind
  27183. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27184. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27185. * @param effect defines the effect associated with the vertex buffer
  27186. */
  27187. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27188. private _unbindVertexArrayObject;
  27189. /**
  27190. * Bind a list of vertex buffers to the webGL context
  27191. * @param vertexBuffers defines the list of vertex buffers to bind
  27192. * @param indexBuffer defines the index buffer to bind
  27193. * @param effect defines the effect associated with the vertex buffers
  27194. */
  27195. bindBuffers(vertexBuffers: {
  27196. [key: string]: Nullable<VertexBuffer>;
  27197. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27198. /**
  27199. * Unbind all instance attributes
  27200. */
  27201. unbindInstanceAttributes(): void;
  27202. /**
  27203. * Release and free the memory of a vertex array object
  27204. * @param vao defines the vertex array object to delete
  27205. */
  27206. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27207. /** @hidden */
  27208. _releaseBuffer(buffer: WebGLBuffer): boolean;
  27209. /**
  27210. * Creates a webGL buffer to use with instanciation
  27211. * @param capacity defines the size of the buffer
  27212. * @returns the webGL buffer
  27213. */
  27214. createInstancesBuffer(capacity: number): WebGLBuffer;
  27215. /**
  27216. * Delete a webGL buffer used with instanciation
  27217. * @param buffer defines the webGL buffer to delete
  27218. */
  27219. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27220. /**
  27221. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27222. * @param instancesBuffer defines the webGL buffer to update and bind
  27223. * @param data defines the data to store in the buffer
  27224. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27225. */
  27226. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27227. /**
  27228. * Apply all cached states (depth, culling, stencil and alpha)
  27229. */
  27230. applyStates(): void;
  27231. /**
  27232. * Send a draw order
  27233. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27234. * @param indexStart defines the starting index
  27235. * @param indexCount defines the number of index to draw
  27236. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27237. */
  27238. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27239. /**
  27240. * Draw a list of points
  27241. * @param verticesStart defines the index of first vertex to draw
  27242. * @param verticesCount defines the count of vertices to draw
  27243. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27244. */
  27245. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27246. /**
  27247. * Draw a list of unindexed primitives
  27248. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27249. * @param verticesStart defines the index of first vertex to draw
  27250. * @param verticesCount defines the count of vertices to draw
  27251. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27252. */
  27253. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27254. /**
  27255. * Draw a list of indexed primitives
  27256. * @param fillMode defines the primitive to use
  27257. * @param indexStart defines the starting index
  27258. * @param indexCount defines the number of index to draw
  27259. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27260. */
  27261. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27262. /**
  27263. * Draw a list of unindexed primitives
  27264. * @param fillMode defines the primitive to use
  27265. * @param verticesStart defines the index of first vertex to draw
  27266. * @param verticesCount defines the count of vertices to draw
  27267. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27268. */
  27269. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27270. private _drawMode;
  27271. /** @hidden */
  27272. _releaseEffect(effect: Effect): void;
  27273. /** @hidden */
  27274. _deleteProgram(program: WebGLProgram): void;
  27275. /**
  27276. * Create a new effect (used to store vertex/fragment shaders)
  27277. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27278. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27279. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27280. * @param samplers defines an array of string used to represent textures
  27281. * @param defines defines the string containing the defines to use to compile the shaders
  27282. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  27283. * @param onCompiled defines a function to call when the effect creation is successful
  27284. * @param onError defines a function to call when the effect creation has failed
  27285. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  27286. * @returns the new Effect
  27287. */
  27288. 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;
  27289. private _compileShader;
  27290. private _compileRawShader;
  27291. /**
  27292. * Directly creates a webGL program
  27293. * @param vertexCode defines the vertex shader code to use
  27294. * @param fragmentCode defines the fragment shader code to use
  27295. * @param context defines the webGL context to use (if not set, the current one will be used)
  27296. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27297. * @returns the new webGL program
  27298. */
  27299. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27300. /**
  27301. * Creates a webGL program
  27302. * @param vertexCode defines the vertex shader code to use
  27303. * @param fragmentCode defines the fragment shader code to use
  27304. * @param defines defines the string containing the defines to use to compile the shaders
  27305. * @param context defines the webGL context to use (if not set, the current one will be used)
  27306. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27307. * @returns the new webGL program
  27308. */
  27309. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27310. private _createShaderProgram;
  27311. private _finalizeProgram;
  27312. /** @hidden */
  27313. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  27314. /** @hidden */
  27315. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  27316. /**
  27317. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  27318. * @param shaderProgram defines the webGL program to use
  27319. * @param uniformsNames defines the list of uniform names
  27320. * @returns an array of webGL uniform locations
  27321. */
  27322. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  27323. /**
  27324. * Gets the lsit of active attributes for a given webGL program
  27325. * @param shaderProgram defines the webGL program to use
  27326. * @param attributesNames defines the list of attribute names to get
  27327. * @returns an array of indices indicating the offset of each attribute
  27328. */
  27329. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  27330. /**
  27331. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  27332. * @param effect defines the effect to activate
  27333. */
  27334. enableEffect(effect: Nullable<Effect>): void;
  27335. /**
  27336. * Set the value of an uniform to an array of int32
  27337. * @param uniform defines the webGL uniform location where to store the value
  27338. * @param array defines the array of int32 to store
  27339. */
  27340. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27341. /**
  27342. * Set the value of an uniform to an array of int32 (stored as vec2)
  27343. * @param uniform defines the webGL uniform location where to store the value
  27344. * @param array defines the array of int32 to store
  27345. */
  27346. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27347. /**
  27348. * Set the value of an uniform to an array of int32 (stored as vec3)
  27349. * @param uniform defines the webGL uniform location where to store the value
  27350. * @param array defines the array of int32 to store
  27351. */
  27352. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27353. /**
  27354. * Set the value of an uniform to an array of int32 (stored as vec4)
  27355. * @param uniform defines the webGL uniform location where to store the value
  27356. * @param array defines the array of int32 to store
  27357. */
  27358. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27359. /**
  27360. * Set the value of an uniform to an array of float32
  27361. * @param uniform defines the webGL uniform location where to store the value
  27362. * @param array defines the array of float32 to store
  27363. */
  27364. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27365. /**
  27366. * Set the value of an uniform to an array of float32 (stored as vec2)
  27367. * @param uniform defines the webGL uniform location where to store the value
  27368. * @param array defines the array of float32 to store
  27369. */
  27370. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27371. /**
  27372. * Set the value of an uniform to an array of float32 (stored as vec3)
  27373. * @param uniform defines the webGL uniform location where to store the value
  27374. * @param array defines the array of float32 to store
  27375. */
  27376. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27377. /**
  27378. * Set the value of an uniform to an array of float32 (stored as vec4)
  27379. * @param uniform defines the webGL uniform location where to store the value
  27380. * @param array defines the array of float32 to store
  27381. */
  27382. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27383. /**
  27384. * Set the value of an uniform to an array of number
  27385. * @param uniform defines the webGL uniform location where to store the value
  27386. * @param array defines the array of number to store
  27387. */
  27388. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27389. /**
  27390. * Set the value of an uniform to an array of number (stored as vec2)
  27391. * @param uniform defines the webGL uniform location where to store the value
  27392. * @param array defines the array of number to store
  27393. */
  27394. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27395. /**
  27396. * Set the value of an uniform to an array of number (stored as vec3)
  27397. * @param uniform defines the webGL uniform location where to store the value
  27398. * @param array defines the array of number to store
  27399. */
  27400. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27401. /**
  27402. * Set the value of an uniform to an array of number (stored as vec4)
  27403. * @param uniform defines the webGL uniform location where to store the value
  27404. * @param array defines the array of number to store
  27405. */
  27406. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27407. /**
  27408. * Set the value of an uniform to an array of float32 (stored as matrices)
  27409. * @param uniform defines the webGL uniform location where to store the value
  27410. * @param matrices defines the array of float32 to store
  27411. */
  27412. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  27413. /**
  27414. * Set the value of an uniform to a matrix
  27415. * @param uniform defines the webGL uniform location where to store the value
  27416. * @param matrix defines the matrix to store
  27417. */
  27418. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  27419. /**
  27420. * Set the value of an uniform to a matrix (3x3)
  27421. * @param uniform defines the webGL uniform location where to store the value
  27422. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  27423. */
  27424. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27425. /**
  27426. * Set the value of an uniform to a matrix (2x2)
  27427. * @param uniform defines the webGL uniform location where to store the value
  27428. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  27429. */
  27430. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27431. /**
  27432. * Set the value of an uniform to a number (int)
  27433. * @param uniform defines the webGL uniform location where to store the value
  27434. * @param value defines the int number to store
  27435. */
  27436. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27437. /**
  27438. * Set the value of an uniform to a number (float)
  27439. * @param uniform defines the webGL uniform location where to store the value
  27440. * @param value defines the float number to store
  27441. */
  27442. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27443. /**
  27444. * Set the value of an uniform to a vec2
  27445. * @param uniform defines the webGL uniform location where to store the value
  27446. * @param x defines the 1st component of the value
  27447. * @param y defines the 2nd component of the value
  27448. */
  27449. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  27450. /**
  27451. * Set the value of an uniform to a vec3
  27452. * @param uniform defines the webGL uniform location where to store the value
  27453. * @param x defines the 1st component of the value
  27454. * @param y defines the 2nd component of the value
  27455. * @param z defines the 3rd component of the value
  27456. */
  27457. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  27458. /**
  27459. * Set the value of an uniform to a boolean
  27460. * @param uniform defines the webGL uniform location where to store the value
  27461. * @param bool defines the boolean to store
  27462. */
  27463. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  27464. /**
  27465. * Set the value of an uniform to a vec4
  27466. * @param uniform defines the webGL uniform location where to store the value
  27467. * @param x defines the 1st component of the value
  27468. * @param y defines the 2nd component of the value
  27469. * @param z defines the 3rd component of the value
  27470. * @param w defines the 4th component of the value
  27471. */
  27472. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  27473. /**
  27474. * Set the value of an uniform to a Color3
  27475. * @param uniform defines the webGL uniform location where to store the value
  27476. * @param color3 defines the color to store
  27477. */
  27478. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  27479. /**
  27480. * Set the value of an uniform to a Color3 and an alpha value
  27481. * @param uniform defines the webGL uniform location where to store the value
  27482. * @param color3 defines the color to store
  27483. * @param alpha defines the alpha component to store
  27484. */
  27485. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  27486. /**
  27487. * Sets a Color4 on a uniform variable
  27488. * @param uniform defines the uniform location
  27489. * @param color4 defines the value to be set
  27490. */
  27491. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  27492. /**
  27493. * Set various states to the webGL context
  27494. * @param culling defines backface culling state
  27495. * @param zOffset defines the value to apply to zOffset (0 by default)
  27496. * @param force defines if states must be applied even if cache is up to date
  27497. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  27498. */
  27499. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  27500. /**
  27501. * Set the z offset to apply to current rendering
  27502. * @param value defines the offset to apply
  27503. */
  27504. setZOffset(value: number): void;
  27505. /**
  27506. * Gets the current value of the zOffset
  27507. * @returns the current zOffset state
  27508. */
  27509. getZOffset(): number;
  27510. /**
  27511. * Enable or disable depth buffering
  27512. * @param enable defines the state to set
  27513. */
  27514. setDepthBuffer(enable: boolean): void;
  27515. /**
  27516. * Gets a boolean indicating if depth writing is enabled
  27517. * @returns the current depth writing state
  27518. */
  27519. getDepthWrite(): boolean;
  27520. /**
  27521. * Enable or disable depth writing
  27522. * @param enable defines the state to set
  27523. */
  27524. setDepthWrite(enable: boolean): void;
  27525. /**
  27526. * Enable or disable color writing
  27527. * @param enable defines the state to set
  27528. */
  27529. setColorWrite(enable: boolean): void;
  27530. /**
  27531. * Gets a boolean indicating if color writing is enabled
  27532. * @returns the current color writing state
  27533. */
  27534. getColorWrite(): boolean;
  27535. /**
  27536. * Sets alpha constants used by some alpha blending modes
  27537. * @param r defines the red component
  27538. * @param g defines the green component
  27539. * @param b defines the blue component
  27540. * @param a defines the alpha component
  27541. */
  27542. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  27543. /**
  27544. * Sets the current alpha mode
  27545. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  27546. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  27547. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27548. */
  27549. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  27550. /**
  27551. * Gets the current alpha mode
  27552. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27553. * @returns the current alpha mode
  27554. */
  27555. getAlphaMode(): number;
  27556. /**
  27557. * Clears the list of texture accessible through engine.
  27558. * This can help preventing texture load conflict due to name collision.
  27559. */
  27560. clearInternalTexturesCache(): void;
  27561. /**
  27562. * Force the entire cache to be cleared
  27563. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  27564. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  27565. */
  27566. wipeCaches(bruteForce?: boolean): void;
  27567. /**
  27568. * Set the compressed texture format to use, based on the formats you have, and the formats
  27569. * supported by the hardware / browser.
  27570. *
  27571. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  27572. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  27573. * to API arguments needed to compressed textures. This puts the burden on the container
  27574. * generator to house the arcane code for determining these for current & future formats.
  27575. *
  27576. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  27577. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  27578. *
  27579. * Note: The result of this call is not taken into account when a texture is base64.
  27580. *
  27581. * @param formatsAvailable defines the list of those format families you have created
  27582. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  27583. *
  27584. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  27585. * @returns The extension selected.
  27586. */
  27587. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  27588. private _getSamplingParameters;
  27589. private _partialLoadImg;
  27590. private _cascadeLoadImgs;
  27591. /** @hidden */
  27592. _createTexture(): WebGLTexture;
  27593. /**
  27594. * Usually called from Texture.ts.
  27595. * Passed information to create a WebGLTexture
  27596. * @param urlArg defines a value which contains one of the following:
  27597. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  27598. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  27599. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  27600. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  27601. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  27602. * @param scene needed for loading to the correct scene
  27603. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  27604. * @param onLoad optional callback to be called upon successful completion
  27605. * @param onError optional callback to be called upon failure
  27606. * @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
  27607. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  27608. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  27609. * @param forcedExtension defines the extension to use to pick the right loader
  27610. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  27611. * @returns a InternalTexture for assignment back into BABYLON.Texture
  27612. */
  27613. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  27614. private _rescaleTexture;
  27615. /**
  27616. * Update a raw texture
  27617. * @param texture defines the texture to update
  27618. * @param data defines the data to store in the texture
  27619. * @param format defines the format of the data
  27620. * @param invertY defines if data must be stored with Y axis inverted
  27621. * @param compression defines the compression used (null by default)
  27622. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27623. */
  27624. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  27625. /**
  27626. * Creates a raw texture
  27627. * @param data defines the data to store in the texture
  27628. * @param width defines the width of the texture
  27629. * @param height defines the height of the texture
  27630. * @param format defines the format of the data
  27631. * @param generateMipMaps defines if the engine should generate the mip levels
  27632. * @param invertY defines if data must be stored with Y axis inverted
  27633. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  27634. * @param compression defines the compression used (null by default)
  27635. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27636. * @returns the raw texture inside an InternalTexture
  27637. */
  27638. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  27639. private _unpackFlipYCached;
  27640. /**
  27641. * In case you are sharing the context with other applications, it might
  27642. * be interested to not cache the unpack flip y state to ensure a consistent
  27643. * value would be set.
  27644. */
  27645. enableUnpackFlipYCached: boolean;
  27646. /** @hidden */
  27647. _unpackFlipY(value: boolean): void;
  27648. /** @hidden */
  27649. _getUnpackAlignement(): number;
  27650. /**
  27651. * Creates a dynamic texture
  27652. * @param width defines the width of the texture
  27653. * @param height defines the height of the texture
  27654. * @param generateMipMaps defines if the engine should generate the mip levels
  27655. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  27656. * @returns the dynamic texture inside an InternalTexture
  27657. */
  27658. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  27659. /**
  27660. * Update the sampling mode of a given texture
  27661. * @param samplingMode defines the required sampling mode
  27662. * @param texture defines the texture to update
  27663. */
  27664. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  27665. /**
  27666. * Update the content of a dynamic texture
  27667. * @param texture defines the texture to update
  27668. * @param canvas defines the canvas containing the source
  27669. * @param invertY defines if data must be stored with Y axis inverted
  27670. * @param premulAlpha defines if alpha is stored as premultiplied
  27671. * @param format defines the format of the data
  27672. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  27673. */
  27674. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  27675. /**
  27676. * Update a video texture
  27677. * @param texture defines the texture to update
  27678. * @param video defines the video element to use
  27679. * @param invertY defines if data must be stored with Y axis inverted
  27680. */
  27681. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  27682. /**
  27683. * Updates a depth texture Comparison Mode and Function.
  27684. * If the comparison Function is equal to 0, the mode will be set to none.
  27685. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  27686. * @param texture The texture to set the comparison function for
  27687. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  27688. */
  27689. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  27690. private _setupDepthStencilTexture;
  27691. /**
  27692. * Creates a depth stencil texture.
  27693. * This is only available in WebGL 2 or with the depth texture extension available.
  27694. * @param size The size of face edge in the texture.
  27695. * @param options The options defining the texture.
  27696. * @returns The texture
  27697. */
  27698. createDepthStencilTexture(size: number | {
  27699. width: number;
  27700. height: number;
  27701. }, options: DepthTextureCreationOptions): InternalTexture;
  27702. /**
  27703. * Creates a depth stencil texture.
  27704. * This is only available in WebGL 2 or with the depth texture extension available.
  27705. * @param size The size of face edge in the texture.
  27706. * @param options The options defining the texture.
  27707. * @returns The texture
  27708. */
  27709. private _createDepthStencilTexture;
  27710. /**
  27711. * Creates a depth stencil cube texture.
  27712. * This is only available in WebGL 2.
  27713. * @param size The size of face edge in the cube texture.
  27714. * @param options The options defining the cube texture.
  27715. * @returns The cube texture
  27716. */
  27717. private _createDepthStencilCubeTexture;
  27718. /**
  27719. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  27720. * @param renderTarget The render target to set the frame buffer for
  27721. */
  27722. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  27723. /**
  27724. * Creates a new render target texture
  27725. * @param size defines the size of the texture
  27726. * @param options defines the options used to create the texture
  27727. * @returns a new render target texture stored in an InternalTexture
  27728. */
  27729. createRenderTargetTexture(size: number | {
  27730. width: number;
  27731. height: number;
  27732. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  27733. /**
  27734. * Create a multi render target texture
  27735. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  27736. * @param size defines the size of the texture
  27737. * @param options defines the creation options
  27738. * @returns the cube texture as an InternalTexture
  27739. */
  27740. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  27741. private _setupFramebufferDepthAttachments;
  27742. /**
  27743. * Updates the sample count of a render target texture
  27744. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  27745. * @param texture defines the texture to update
  27746. * @param samples defines the sample count to set
  27747. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  27748. */
  27749. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  27750. /**
  27751. * Update the sample count for a given multiple render target texture
  27752. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  27753. * @param textures defines the textures to update
  27754. * @param samples defines the sample count to set
  27755. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  27756. */
  27757. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  27758. /** @hidden */
  27759. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  27760. /** @hidden */
  27761. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  27762. /** @hidden */
  27763. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  27764. /** @hidden */
  27765. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  27766. /**
  27767. * Creates a new render target cube texture
  27768. * @param size defines the size of the texture
  27769. * @param options defines the options used to create the texture
  27770. * @returns a new render target cube texture stored in an InternalTexture
  27771. */
  27772. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  27773. /**
  27774. * Creates a cube texture
  27775. * @param rootUrl defines the url where the files to load is located
  27776. * @param scene defines the current scene
  27777. * @param files defines the list of files to load (1 per face)
  27778. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  27779. * @param onLoad defines an optional callback raised when the texture is loaded
  27780. * @param onError defines an optional callback raised if there is an issue to load the texture
  27781. * @param format defines the format of the data
  27782. * @param forcedExtension defines the extension to use to pick the right loader
  27783. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  27784. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  27785. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  27786. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  27787. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  27788. * @returns the cube texture as an InternalTexture
  27789. */
  27790. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  27791. /**
  27792. * @hidden
  27793. */
  27794. _setCubeMapTextureParams(loadMipmap: boolean): void;
  27795. /**
  27796. * Update a raw cube texture
  27797. * @param texture defines the texture to udpdate
  27798. * @param data defines the data to store
  27799. * @param format defines the data format
  27800. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27801. * @param invertY defines if data must be stored with Y axis inverted
  27802. * @param compression defines the compression used (null by default)
  27803. * @param level defines which level of the texture to update
  27804. */
  27805. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  27806. /**
  27807. * Creates a new raw cube texture
  27808. * @param data defines the array of data to use to create each face
  27809. * @param size defines the size of the textures
  27810. * @param format defines the format of the data
  27811. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  27812. * @param generateMipMaps defines if the engine should generate the mip levels
  27813. * @param invertY defines if data must be stored with Y axis inverted
  27814. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  27815. * @param compression defines the compression used (null by default)
  27816. * @returns the cube texture as an InternalTexture
  27817. */
  27818. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  27819. /**
  27820. * Creates a new raw cube texture from a specified url
  27821. * @param url defines the url where the data is located
  27822. * @param scene defines the current scene
  27823. * @param size defines the size of the textures
  27824. * @param format defines the format of the data
  27825. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  27826. * @param noMipmap defines if the engine should avoid generating the mip levels
  27827. * @param callback defines a callback used to extract texture data from loaded data
  27828. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  27829. * @param onLoad defines a callback called when texture is loaded
  27830. * @param onError defines a callback called if there is an error
  27831. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  27832. * @param invertY defines if data must be stored with Y axis inverted
  27833. * @returns the cube texture as an InternalTexture
  27834. */
  27835. 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;
  27836. /**
  27837. * Update a raw 3D texture
  27838. * @param texture defines the texture to update
  27839. * @param data defines the data to store
  27840. * @param format defines the data format
  27841. * @param invertY defines if data must be stored with Y axis inverted
  27842. * @param compression defines the used compression (can be null)
  27843. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  27844. */
  27845. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  27846. /**
  27847. * Creates a new raw 3D texture
  27848. * @param data defines the data used to create the texture
  27849. * @param width defines the width of the texture
  27850. * @param height defines the height of the texture
  27851. * @param depth defines the depth of the texture
  27852. * @param format defines the format of the texture
  27853. * @param generateMipMaps defines if the engine must generate mip levels
  27854. * @param invertY defines if data must be stored with Y axis inverted
  27855. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  27856. * @param compression defines the compressed used (can be null)
  27857. * @param textureType defines the compressed used (can be null)
  27858. * @returns a new raw 3D texture (stored in an InternalTexture)
  27859. */
  27860. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  27861. private _prepareWebGLTextureContinuation;
  27862. private _prepareWebGLTexture;
  27863. private _convertRGBtoRGBATextureData;
  27864. /** @hidden */
  27865. _releaseFramebufferObjects(texture: InternalTexture): void;
  27866. /** @hidden */
  27867. _releaseTexture(texture: InternalTexture): void;
  27868. private setProgram;
  27869. private _boundUniforms;
  27870. /**
  27871. * Binds an effect to the webGL context
  27872. * @param effect defines the effect to bind
  27873. */
  27874. bindSamplers(effect: Effect): void;
  27875. private _moveBoundTextureOnTop;
  27876. private _getCorrectTextureChannel;
  27877. private _linkTrackers;
  27878. private _removeDesignatedSlot;
  27879. private _activateCurrentTexture;
  27880. /** @hidden */
  27881. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  27882. /** @hidden */
  27883. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  27884. /**
  27885. * Sets a texture to the webGL context from a postprocess
  27886. * @param channel defines the channel to use
  27887. * @param postProcess defines the source postprocess
  27888. */
  27889. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  27890. /**
  27891. * Binds the output of the passed in post process to the texture channel specified
  27892. * @param channel The channel the texture should be bound to
  27893. * @param postProcess The post process which's output should be bound
  27894. */
  27895. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  27896. /**
  27897. * Unbind all textures from the webGL context
  27898. */
  27899. unbindAllTextures(): void;
  27900. /**
  27901. * Sets a texture to the according uniform.
  27902. * @param channel The texture channel
  27903. * @param uniform The uniform to set
  27904. * @param texture The texture to apply
  27905. */
  27906. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  27907. /**
  27908. * Sets a depth stencil texture from a render target to the according uniform.
  27909. * @param channel The texture channel
  27910. * @param uniform The uniform to set
  27911. * @param texture The render target texture containing the depth stencil texture to apply
  27912. */
  27913. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  27914. private _bindSamplerUniformToChannel;
  27915. private _getTextureWrapMode;
  27916. private _setTexture;
  27917. /**
  27918. * Sets an array of texture to the webGL context
  27919. * @param channel defines the channel where the texture array must be set
  27920. * @param uniform defines the associated uniform location
  27921. * @param textures defines the array of textures to bind
  27922. */
  27923. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  27924. /** @hidden */
  27925. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  27926. private _setTextureParameterFloat;
  27927. private _setTextureParameterInteger;
  27928. /**
  27929. * Reads pixels from the current frame buffer. Please note that this function can be slow
  27930. * @param x defines the x coordinate of the rectangle where pixels must be read
  27931. * @param y defines the y coordinate of the rectangle where pixels must be read
  27932. * @param width defines the width of the rectangle where pixels must be read
  27933. * @param height defines the height of the rectangle where pixels must be read
  27934. * @returns a Uint8Array containing RGBA colors
  27935. */
  27936. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  27937. /**
  27938. * Add an externaly attached data from its key.
  27939. * This method call will fail and return false, if such key already exists.
  27940. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  27941. * @param key the unique key that identifies the data
  27942. * @param data the data object to associate to the key for this Engine instance
  27943. * @return true if no such key were already present and the data was added successfully, false otherwise
  27944. */
  27945. addExternalData<T>(key: string, data: T): boolean;
  27946. /**
  27947. * Get an externaly attached data from its key
  27948. * @param key the unique key that identifies the data
  27949. * @return the associated data, if present (can be null), or undefined if not present
  27950. */
  27951. getExternalData<T>(key: string): T;
  27952. /**
  27953. * Get an externaly attached data from its key, create it using a factory if it's not already present
  27954. * @param key the unique key that identifies the data
  27955. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  27956. * @return the associated data, can be null if the factory returned null.
  27957. */
  27958. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  27959. /**
  27960. * Remove an externaly attached data from the Engine instance
  27961. * @param key the unique key that identifies the data
  27962. * @return true if the data was successfully removed, false if it doesn't exist
  27963. */
  27964. removeExternalData(key: string): boolean;
  27965. /**
  27966. * Unbind all vertex attributes from the webGL context
  27967. */
  27968. unbindAllAttributes(): void;
  27969. /**
  27970. * 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
  27971. */
  27972. releaseEffects(): void;
  27973. /**
  27974. * Dispose and release all associated resources
  27975. */
  27976. dispose(): void;
  27977. /**
  27978. * Display the loading screen
  27979. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27980. */
  27981. displayLoadingUI(): void;
  27982. /**
  27983. * Hide the loading screen
  27984. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27985. */
  27986. hideLoadingUI(): void;
  27987. /**
  27988. * Gets the current loading screen object
  27989. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27990. */
  27991. /**
  27992. * Sets the current loading screen object
  27993. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27994. */
  27995. loadingScreen: ILoadingScreen;
  27996. /**
  27997. * Sets the current loading screen text
  27998. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27999. */
  28000. loadingUIText: string;
  28001. /**
  28002. * Sets the current loading screen background color
  28003. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28004. */
  28005. loadingUIBackgroundColor: string;
  28006. /**
  28007. * Attach a new callback raised when context lost event is fired
  28008. * @param callback defines the callback to call
  28009. */
  28010. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28011. /**
  28012. * Attach a new callback raised when context restored event is fired
  28013. * @param callback defines the callback to call
  28014. */
  28015. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28016. /**
  28017. * Gets the source code of the vertex shader associated with a specific webGL program
  28018. * @param program defines the program to use
  28019. * @returns a string containing the source code of the vertex shader associated with the program
  28020. */
  28021. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28022. /**
  28023. * Gets the source code of the fragment shader associated with a specific webGL program
  28024. * @param program defines the program to use
  28025. * @returns a string containing the source code of the fragment shader associated with the program
  28026. */
  28027. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28028. /**
  28029. * Get the current error code of the webGL context
  28030. * @returns the error code
  28031. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28032. */
  28033. getError(): number;
  28034. /**
  28035. * Gets the current framerate
  28036. * @returns a number representing the framerate
  28037. */
  28038. getFps(): number;
  28039. /**
  28040. * Gets the time spent between current and previous frame
  28041. * @returns a number representing the delta time in ms
  28042. */
  28043. getDeltaTime(): number;
  28044. private _measureFps;
  28045. /** @hidden */
  28046. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28047. private _canRenderToFloatFramebuffer;
  28048. private _canRenderToHalfFloatFramebuffer;
  28049. private _canRenderToFramebuffer;
  28050. /** @hidden */
  28051. _getWebGLTextureType(type: number): number;
  28052. private _getInternalFormat;
  28053. /** @hidden */
  28054. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28055. /** @hidden */
  28056. _getRGBAMultiSampleBufferFormat(type: number): number;
  28057. /** @hidden */
  28058. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  28059. /** @hidden */
  28060. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28061. private _partialLoadFile;
  28062. private _cascadeLoadFiles;
  28063. /**
  28064. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28065. * @returns true if the engine can be created
  28066. * @ignorenaming
  28067. */
  28068. static isSupported(): boolean;
  28069. }
  28070. }
  28071. declare module BABYLON {
  28072. /**
  28073. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28074. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28075. */
  28076. export class EffectFallbacks {
  28077. private _defines;
  28078. private _currentRank;
  28079. private _maxRank;
  28080. private _mesh;
  28081. /**
  28082. * Removes the fallback from the bound mesh.
  28083. */
  28084. unBindMesh(): void;
  28085. /**
  28086. * Adds a fallback on the specified property.
  28087. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28088. * @param define The name of the define in the shader
  28089. */
  28090. addFallback(rank: number, define: string): void;
  28091. /**
  28092. * Sets the mesh to use CPU skinning when needing to fallback.
  28093. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28094. * @param mesh The mesh to use the fallbacks.
  28095. */
  28096. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28097. /**
  28098. * Checks to see if more fallbacks are still availible.
  28099. */
  28100. readonly isMoreFallbacks: boolean;
  28101. /**
  28102. * Removes the defines that shoould be removed when falling back.
  28103. * @param currentDefines defines the current define statements for the shader.
  28104. * @param effect defines the current effect we try to compile
  28105. * @returns The resulting defines with defines of the current rank removed.
  28106. */
  28107. reduce(currentDefines: string, effect: Effect): string;
  28108. }
  28109. /**
  28110. * Options to be used when creating an effect.
  28111. */
  28112. export class EffectCreationOptions {
  28113. /**
  28114. * Atrributes that will be used in the shader.
  28115. */
  28116. attributes: string[];
  28117. /**
  28118. * Uniform varible names that will be set in the shader.
  28119. */
  28120. uniformsNames: string[];
  28121. /**
  28122. * Uniform buffer varible names that will be set in the shader.
  28123. */
  28124. uniformBuffersNames: string[];
  28125. /**
  28126. * Sampler texture variable names that will be set in the shader.
  28127. */
  28128. samplers: string[];
  28129. /**
  28130. * Define statements that will be set in the shader.
  28131. */
  28132. defines: any;
  28133. /**
  28134. * Possible fallbacks for this effect to improve performance when needed.
  28135. */
  28136. fallbacks: Nullable<EffectFallbacks>;
  28137. /**
  28138. * Callback that will be called when the shader is compiled.
  28139. */
  28140. onCompiled: Nullable<(effect: Effect) => void>;
  28141. /**
  28142. * Callback that will be called if an error occurs during shader compilation.
  28143. */
  28144. onError: Nullable<(effect: Effect, errors: string) => void>;
  28145. /**
  28146. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28147. */
  28148. indexParameters: any;
  28149. /**
  28150. * Max number of lights that can be used in the shader.
  28151. */
  28152. maxSimultaneousLights: number;
  28153. /**
  28154. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28155. */
  28156. transformFeedbackVaryings: Nullable<string[]>;
  28157. }
  28158. /**
  28159. * Effect containing vertex and fragment shader that can be executed on an object.
  28160. */
  28161. export class Effect {
  28162. /**
  28163. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28164. */
  28165. static ShadersRepository: string;
  28166. /**
  28167. * Name of the effect.
  28168. */
  28169. name: any;
  28170. /**
  28171. * String container all the define statements that should be set on the shader.
  28172. */
  28173. defines: string;
  28174. /**
  28175. * Callback that will be called when the shader is compiled.
  28176. */
  28177. onCompiled: Nullable<(effect: Effect) => void>;
  28178. /**
  28179. * Callback that will be called if an error occurs during shader compilation.
  28180. */
  28181. onError: Nullable<(effect: Effect, errors: string) => void>;
  28182. /**
  28183. * Callback that will be called when effect is bound.
  28184. */
  28185. onBind: Nullable<(effect: Effect) => void>;
  28186. /**
  28187. * Unique ID of the effect.
  28188. */
  28189. uniqueId: number;
  28190. /**
  28191. * Observable that will be called when the shader is compiled.
  28192. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28193. */
  28194. onCompileObservable: Observable<Effect>;
  28195. /**
  28196. * Observable that will be called if an error occurs during shader compilation.
  28197. */
  28198. onErrorObservable: Observable<Effect>;
  28199. /** @hidden */
  28200. _onBindObservable: Nullable<Observable<Effect>>;
  28201. /**
  28202. * Observable that will be called when effect is bound.
  28203. */
  28204. readonly onBindObservable: Observable<Effect>;
  28205. /** @hidden */
  28206. _bonesComputationForcedToCPU: boolean;
  28207. private static _uniqueIdSeed;
  28208. private _engine;
  28209. private _uniformBuffersNames;
  28210. private _uniformsNames;
  28211. private _samplers;
  28212. private _isReady;
  28213. private _compilationError;
  28214. private _attributesNames;
  28215. private _attributes;
  28216. private _uniforms;
  28217. /**
  28218. * Key for the effect.
  28219. * @hidden
  28220. */
  28221. _key: string;
  28222. private _indexParameters;
  28223. private _fallbacks;
  28224. private _vertexSourceCode;
  28225. private _fragmentSourceCode;
  28226. private _vertexSourceCodeOverride;
  28227. private _fragmentSourceCodeOverride;
  28228. private _transformFeedbackVaryings;
  28229. /**
  28230. * Compiled shader to webGL program.
  28231. * @hidden
  28232. */
  28233. _program: WebGLProgram;
  28234. private _valueCache;
  28235. private static _baseCache;
  28236. /**
  28237. * Instantiates an effect.
  28238. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28239. * @param baseName Name of the effect.
  28240. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28241. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28242. * @param samplers List of sampler variables that will be passed to the shader.
  28243. * @param engine Engine to be used to render the effect
  28244. * @param defines Define statements to be added to the shader.
  28245. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28246. * @param onCompiled Callback that will be called when the shader is compiled.
  28247. * @param onError Callback that will be called if an error occurs during shader compilation.
  28248. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28249. */
  28250. 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);
  28251. /**
  28252. * Unique key for this effect
  28253. */
  28254. readonly key: string;
  28255. /**
  28256. * If the effect has been compiled and prepared.
  28257. * @returns if the effect is compiled and prepared.
  28258. */
  28259. isReady(): boolean;
  28260. /**
  28261. * The engine the effect was initialized with.
  28262. * @returns the engine.
  28263. */
  28264. getEngine(): Engine;
  28265. /**
  28266. * The compiled webGL program for the effect
  28267. * @returns the webGL program.
  28268. */
  28269. getProgram(): WebGLProgram;
  28270. /**
  28271. * The set of names of attribute variables for the shader.
  28272. * @returns An array of attribute names.
  28273. */
  28274. getAttributesNames(): string[];
  28275. /**
  28276. * Returns the attribute at the given index.
  28277. * @param index The index of the attribute.
  28278. * @returns The location of the attribute.
  28279. */
  28280. getAttributeLocation(index: number): number;
  28281. /**
  28282. * Returns the attribute based on the name of the variable.
  28283. * @param name of the attribute to look up.
  28284. * @returns the attribute location.
  28285. */
  28286. getAttributeLocationByName(name: string): number;
  28287. /**
  28288. * The number of attributes.
  28289. * @returns the numnber of attributes.
  28290. */
  28291. getAttributesCount(): number;
  28292. /**
  28293. * Gets the index of a uniform variable.
  28294. * @param uniformName of the uniform to look up.
  28295. * @returns the index.
  28296. */
  28297. getUniformIndex(uniformName: string): number;
  28298. /**
  28299. * Returns the attribute based on the name of the variable.
  28300. * @param uniformName of the uniform to look up.
  28301. * @returns the location of the uniform.
  28302. */
  28303. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28304. /**
  28305. * Returns an array of sampler variable names
  28306. * @returns The array of sampler variable neames.
  28307. */
  28308. getSamplers(): string[];
  28309. /**
  28310. * The error from the last compilation.
  28311. * @returns the error string.
  28312. */
  28313. getCompilationError(): string;
  28314. /**
  28315. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28316. * @param func The callback to be used.
  28317. */
  28318. executeWhenCompiled(func: (effect: Effect) => void): void;
  28319. private _checkIsReady;
  28320. /** @hidden */
  28321. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28322. /** @hidden */
  28323. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28324. /** @hidden */
  28325. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28326. private _processShaderConversion;
  28327. private _processIncludes;
  28328. private _processPrecision;
  28329. /**
  28330. * Recompiles the webGL program
  28331. * @param vertexSourceCode The source code for the vertex shader.
  28332. * @param fragmentSourceCode The source code for the fragment shader.
  28333. * @param onCompiled Callback called when completed.
  28334. * @param onError Callback called on error.
  28335. * @hidden
  28336. */
  28337. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  28338. /**
  28339. * Gets the uniform locations of the the specified variable names
  28340. * @param names THe names of the variables to lookup.
  28341. * @returns Array of locations in the same order as variable names.
  28342. */
  28343. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  28344. /**
  28345. * Prepares the effect
  28346. * @hidden
  28347. */
  28348. _prepareEffect(): void;
  28349. /**
  28350. * Checks if the effect is supported. (Must be called after compilation)
  28351. */
  28352. readonly isSupported: boolean;
  28353. /**
  28354. * Binds a texture to the engine to be used as output of the shader.
  28355. * @param channel Name of the output variable.
  28356. * @param texture Texture to bind.
  28357. * @hidden
  28358. */
  28359. _bindTexture(channel: string, texture: InternalTexture): void;
  28360. /**
  28361. * Sets a texture on the engine to be used in the shader.
  28362. * @param channel Name of the sampler variable.
  28363. * @param texture Texture to set.
  28364. */
  28365. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28366. /**
  28367. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28368. * @param channel Name of the sampler variable.
  28369. * @param texture Texture to set.
  28370. */
  28371. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28372. /**
  28373. * Sets an array of textures on the engine to be used in the shader.
  28374. * @param channel Name of the variable.
  28375. * @param textures Textures to set.
  28376. */
  28377. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28378. /**
  28379. * 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)
  28380. * @param channel Name of the sampler variable.
  28381. * @param postProcess Post process to get the input texture from.
  28382. */
  28383. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28384. /**
  28385. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28386. * 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)
  28387. * @param channel Name of the sampler variable.
  28388. * @param postProcess Post process to get the output texture from.
  28389. */
  28390. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28391. /** @hidden */
  28392. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  28393. /** @hidden */
  28394. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28395. /** @hidden */
  28396. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28397. /** @hidden */
  28398. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28399. /**
  28400. * Binds a buffer to a uniform.
  28401. * @param buffer Buffer to bind.
  28402. * @param name Name of the uniform variable to bind to.
  28403. */
  28404. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  28405. /**
  28406. * Binds block to a uniform.
  28407. * @param blockName Name of the block to bind.
  28408. * @param index Index to bind.
  28409. */
  28410. bindUniformBlock(blockName: string, index: number): void;
  28411. /**
  28412. * Sets an interger value on a uniform variable.
  28413. * @param uniformName Name of the variable.
  28414. * @param value Value to be set.
  28415. * @returns this effect.
  28416. */
  28417. setInt(uniformName: string, value: number): Effect;
  28418. /**
  28419. * Sets an int array on a uniform variable.
  28420. * @param uniformName Name of the variable.
  28421. * @param array array to be set.
  28422. * @returns this effect.
  28423. */
  28424. setIntArray(uniformName: string, array: Int32Array): Effect;
  28425. /**
  28426. * 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)
  28427. * @param uniformName Name of the variable.
  28428. * @param array array to be set.
  28429. * @returns this effect.
  28430. */
  28431. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28432. /**
  28433. * 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)
  28434. * @param uniformName Name of the variable.
  28435. * @param array array to be set.
  28436. * @returns this effect.
  28437. */
  28438. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28439. /**
  28440. * 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)
  28441. * @param uniformName Name of the variable.
  28442. * @param array array to be set.
  28443. * @returns this effect.
  28444. */
  28445. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28446. /**
  28447. * Sets an float array on a uniform variable.
  28448. * @param uniformName Name of the variable.
  28449. * @param array array to be set.
  28450. * @returns this effect.
  28451. */
  28452. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28453. /**
  28454. * 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)
  28455. * @param uniformName Name of the variable.
  28456. * @param array array to be set.
  28457. * @returns this effect.
  28458. */
  28459. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28460. /**
  28461. * 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)
  28462. * @param uniformName Name of the variable.
  28463. * @param array array to be set.
  28464. * @returns this effect.
  28465. */
  28466. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28467. /**
  28468. * 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)
  28469. * @param uniformName Name of the variable.
  28470. * @param array array to be set.
  28471. * @returns this effect.
  28472. */
  28473. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28474. /**
  28475. * Sets an array on a uniform variable.
  28476. * @param uniformName Name of the variable.
  28477. * @param array array to be set.
  28478. * @returns this effect.
  28479. */
  28480. setArray(uniformName: string, array: number[]): Effect;
  28481. /**
  28482. * 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)
  28483. * @param uniformName Name of the variable.
  28484. * @param array array to be set.
  28485. * @returns this effect.
  28486. */
  28487. setArray2(uniformName: string, array: number[]): Effect;
  28488. /**
  28489. * 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)
  28490. * @param uniformName Name of the variable.
  28491. * @param array array to be set.
  28492. * @returns this effect.
  28493. */
  28494. setArray3(uniformName: string, array: number[]): Effect;
  28495. /**
  28496. * 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)
  28497. * @param uniformName Name of the variable.
  28498. * @param array array to be set.
  28499. * @returns this effect.
  28500. */
  28501. setArray4(uniformName: string, array: number[]): Effect;
  28502. /**
  28503. * Sets matrices on a uniform variable.
  28504. * @param uniformName Name of the variable.
  28505. * @param matrices matrices to be set.
  28506. * @returns this effect.
  28507. */
  28508. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28509. /**
  28510. * Sets matrix on a uniform variable.
  28511. * @param uniformName Name of the variable.
  28512. * @param matrix matrix to be set.
  28513. * @returns this effect.
  28514. */
  28515. setMatrix(uniformName: string, matrix: Matrix): Effect;
  28516. /**
  28517. * 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)
  28518. * @param uniformName Name of the variable.
  28519. * @param matrix matrix to be set.
  28520. * @returns this effect.
  28521. */
  28522. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28523. /**
  28524. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28525. * @param uniformName Name of the variable.
  28526. * @param matrix matrix to be set.
  28527. * @returns this effect.
  28528. */
  28529. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28530. /**
  28531. * Sets a float on a uniform variable.
  28532. * @param uniformName Name of the variable.
  28533. * @param value value to be set.
  28534. * @returns this effect.
  28535. */
  28536. setFloat(uniformName: string, value: number): Effect;
  28537. /**
  28538. * Sets a boolean on a uniform variable.
  28539. * @param uniformName Name of the variable.
  28540. * @param bool value to be set.
  28541. * @returns this effect.
  28542. */
  28543. setBool(uniformName: string, bool: boolean): Effect;
  28544. /**
  28545. * Sets a Vector2 on a uniform variable.
  28546. * @param uniformName Name of the variable.
  28547. * @param vector2 vector2 to be set.
  28548. * @returns this effect.
  28549. */
  28550. setVector2(uniformName: string, vector2: Vector2): Effect;
  28551. /**
  28552. * Sets a float2 on a uniform variable.
  28553. * @param uniformName Name of the variable.
  28554. * @param x First float in float2.
  28555. * @param y Second float in float2.
  28556. * @returns this effect.
  28557. */
  28558. setFloat2(uniformName: string, x: number, y: number): Effect;
  28559. /**
  28560. * Sets a Vector3 on a uniform variable.
  28561. * @param uniformName Name of the variable.
  28562. * @param vector3 Value to be set.
  28563. * @returns this effect.
  28564. */
  28565. setVector3(uniformName: string, vector3: Vector3): Effect;
  28566. /**
  28567. * Sets a float3 on a uniform variable.
  28568. * @param uniformName Name of the variable.
  28569. * @param x First float in float3.
  28570. * @param y Second float in float3.
  28571. * @param z Third float in float3.
  28572. * @returns this effect.
  28573. */
  28574. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28575. /**
  28576. * Sets a Vector4 on a uniform variable.
  28577. * @param uniformName Name of the variable.
  28578. * @param vector4 Value to be set.
  28579. * @returns this effect.
  28580. */
  28581. setVector4(uniformName: string, vector4: Vector4): Effect;
  28582. /**
  28583. * Sets a float4 on a uniform variable.
  28584. * @param uniformName Name of the variable.
  28585. * @param x First float in float4.
  28586. * @param y Second float in float4.
  28587. * @param z Third float in float4.
  28588. * @param w Fourth float in float4.
  28589. * @returns this effect.
  28590. */
  28591. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28592. /**
  28593. * Sets a Color3 on a uniform variable.
  28594. * @param uniformName Name of the variable.
  28595. * @param color3 Value to be set.
  28596. * @returns this effect.
  28597. */
  28598. setColor3(uniformName: string, color3: Color3): Effect;
  28599. /**
  28600. * Sets a Color4 on a uniform variable.
  28601. * @param uniformName Name of the variable.
  28602. * @param color3 Value to be set.
  28603. * @param alpha Alpha value to be set.
  28604. * @returns this effect.
  28605. */
  28606. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  28607. /**
  28608. * Sets a Color4 on a uniform variable
  28609. * @param uniformName defines the name of the variable
  28610. * @param color4 defines the value to be set
  28611. * @returns this effect.
  28612. */
  28613. setDirectColor4(uniformName: string, color4: Color4): Effect;
  28614. /**
  28615. * This function will add a new shader to the shader store
  28616. * @param name the name of the shader
  28617. * @param pixelShader optional pixel shader content
  28618. * @param vertexShader optional vertex shader content
  28619. */
  28620. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28621. /**
  28622. * Store of each shader (The can be looked up using effect.key)
  28623. */
  28624. static ShadersStore: {
  28625. [key: string]: string;
  28626. };
  28627. /**
  28628. * Store of each included file for a shader (The can be looked up using effect.key)
  28629. */
  28630. static IncludesShadersStore: {
  28631. [key: string]: string;
  28632. };
  28633. /**
  28634. * Resets the cache of effects.
  28635. */
  28636. static ResetCache(): void;
  28637. }
  28638. }
  28639. declare module BABYLON {
  28640. /**
  28641. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28642. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28643. * 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;
  28644. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28645. */
  28646. export class ColorCurves {
  28647. private _dirty;
  28648. private _tempColor;
  28649. private _globalCurve;
  28650. private _highlightsCurve;
  28651. private _midtonesCurve;
  28652. private _shadowsCurve;
  28653. private _positiveCurve;
  28654. private _negativeCurve;
  28655. private _globalHue;
  28656. private _globalDensity;
  28657. private _globalSaturation;
  28658. private _globalExposure;
  28659. /**
  28660. * Gets the global Hue value.
  28661. * 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).
  28662. */
  28663. /**
  28664. * Sets the global Hue value.
  28665. * 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).
  28666. */
  28667. globalHue: number;
  28668. /**
  28669. * Gets the global Density value.
  28670. * 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.
  28671. * Values less than zero provide a filter of opposite hue.
  28672. */
  28673. /**
  28674. * Sets the global Density value.
  28675. * 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.
  28676. * Values less than zero provide a filter of opposite hue.
  28677. */
  28678. globalDensity: number;
  28679. /**
  28680. * Gets the global Saturation value.
  28681. * 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.
  28682. */
  28683. /**
  28684. * Sets the global Saturation value.
  28685. * 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.
  28686. */
  28687. globalSaturation: number;
  28688. /**
  28689. * Gets the global Exposure value.
  28690. * 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.
  28691. */
  28692. /**
  28693. * Sets the global Exposure value.
  28694. * 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.
  28695. */
  28696. globalExposure: number;
  28697. private _highlightsHue;
  28698. private _highlightsDensity;
  28699. private _highlightsSaturation;
  28700. private _highlightsExposure;
  28701. /**
  28702. * Gets the highlights Hue value.
  28703. * 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).
  28704. */
  28705. /**
  28706. * Sets the highlights Hue value.
  28707. * 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).
  28708. */
  28709. highlightsHue: number;
  28710. /**
  28711. * Gets the highlights Density value.
  28712. * 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.
  28713. * Values less than zero provide a filter of opposite hue.
  28714. */
  28715. /**
  28716. * Sets the highlights Density value.
  28717. * 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.
  28718. * Values less than zero provide a filter of opposite hue.
  28719. */
  28720. highlightsDensity: number;
  28721. /**
  28722. * Gets the highlights Saturation value.
  28723. * 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.
  28724. */
  28725. /**
  28726. * Sets the highlights Saturation value.
  28727. * 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.
  28728. */
  28729. highlightsSaturation: number;
  28730. /**
  28731. * Gets the highlights Exposure value.
  28732. * 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.
  28733. */
  28734. /**
  28735. * Sets the highlights Exposure value.
  28736. * 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.
  28737. */
  28738. highlightsExposure: number;
  28739. private _midtonesHue;
  28740. private _midtonesDensity;
  28741. private _midtonesSaturation;
  28742. private _midtonesExposure;
  28743. /**
  28744. * Gets the midtones Hue value.
  28745. * 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).
  28746. */
  28747. /**
  28748. * Sets the midtones Hue value.
  28749. * 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).
  28750. */
  28751. midtonesHue: number;
  28752. /**
  28753. * Gets the midtones Density value.
  28754. * 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.
  28755. * Values less than zero provide a filter of opposite hue.
  28756. */
  28757. /**
  28758. * Sets the midtones Density value.
  28759. * 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.
  28760. * Values less than zero provide a filter of opposite hue.
  28761. */
  28762. midtonesDensity: number;
  28763. /**
  28764. * Gets the midtones Saturation value.
  28765. * 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.
  28766. */
  28767. /**
  28768. * Sets the midtones Saturation value.
  28769. * 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.
  28770. */
  28771. midtonesSaturation: number;
  28772. /**
  28773. * Gets the midtones Exposure value.
  28774. * 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.
  28775. */
  28776. /**
  28777. * Sets the midtones Exposure value.
  28778. * 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.
  28779. */
  28780. midtonesExposure: number;
  28781. private _shadowsHue;
  28782. private _shadowsDensity;
  28783. private _shadowsSaturation;
  28784. private _shadowsExposure;
  28785. /**
  28786. * Gets the shadows Hue value.
  28787. * 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).
  28788. */
  28789. /**
  28790. * Sets the shadows Hue value.
  28791. * 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).
  28792. */
  28793. shadowsHue: number;
  28794. /**
  28795. * Gets the shadows Density value.
  28796. * 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.
  28797. * Values less than zero provide a filter of opposite hue.
  28798. */
  28799. /**
  28800. * Sets the shadows Density value.
  28801. * 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.
  28802. * Values less than zero provide a filter of opposite hue.
  28803. */
  28804. shadowsDensity: number;
  28805. /**
  28806. * Gets the shadows Saturation value.
  28807. * 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.
  28808. */
  28809. /**
  28810. * Sets the shadows Saturation value.
  28811. * 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.
  28812. */
  28813. shadowsSaturation: number;
  28814. /**
  28815. * Gets the shadows Exposure value.
  28816. * 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.
  28817. */
  28818. /**
  28819. * Sets the shadows Exposure value.
  28820. * 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.
  28821. */
  28822. shadowsExposure: number;
  28823. /**
  28824. * Returns the class name
  28825. * @returns The class name
  28826. */
  28827. getClassName(): string;
  28828. /**
  28829. * Binds the color curves to the shader.
  28830. * @param colorCurves The color curve to bind
  28831. * @param effect The effect to bind to
  28832. * @param positiveUniform The positive uniform shader parameter
  28833. * @param neutralUniform The neutral uniform shader parameter
  28834. * @param negativeUniform The negative uniform shader parameter
  28835. */
  28836. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  28837. /**
  28838. * Prepare the list of uniforms associated with the ColorCurves effects.
  28839. * @param uniformsList The list of uniforms used in the effect
  28840. */
  28841. static PrepareUniforms(uniformsList: string[]): void;
  28842. /**
  28843. * Returns color grading data based on a hue, density, saturation and exposure value.
  28844. * @param filterHue The hue of the color filter.
  28845. * @param filterDensity The density of the color filter.
  28846. * @param saturation The saturation.
  28847. * @param exposure The exposure.
  28848. * @param result The result data container.
  28849. */
  28850. private getColorGradingDataToRef;
  28851. /**
  28852. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  28853. * @param value The input slider value in range [-100,100].
  28854. * @returns Adjusted value.
  28855. */
  28856. private static applyColorGradingSliderNonlinear;
  28857. /**
  28858. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  28859. * @param hue The hue (H) input.
  28860. * @param saturation The saturation (S) input.
  28861. * @param brightness The brightness (B) input.
  28862. * @result An RGBA color represented as Vector4.
  28863. */
  28864. private static fromHSBToRef;
  28865. /**
  28866. * Returns a value clamped between min and max
  28867. * @param value The value to clamp
  28868. * @param min The minimum of value
  28869. * @param max The maximum of value
  28870. * @returns The clamped value.
  28871. */
  28872. private static clamp;
  28873. /**
  28874. * Clones the current color curve instance.
  28875. * @return The cloned curves
  28876. */
  28877. clone(): ColorCurves;
  28878. /**
  28879. * Serializes the current color curve instance to a json representation.
  28880. * @return a JSON representation
  28881. */
  28882. serialize(): any;
  28883. /**
  28884. * Parses the color curve from a json representation.
  28885. * @param source the JSON source to parse
  28886. * @return The parsed curves
  28887. */
  28888. static Parse(source: any): ColorCurves;
  28889. }
  28890. }
  28891. declare module BABYLON {
  28892. /**
  28893. * Interface to follow in your material defines to integrate easily the
  28894. * Image proccessing functions.
  28895. * @hidden
  28896. */
  28897. export interface IImageProcessingConfigurationDefines {
  28898. IMAGEPROCESSING: boolean;
  28899. VIGNETTE: boolean;
  28900. VIGNETTEBLENDMODEMULTIPLY: boolean;
  28901. VIGNETTEBLENDMODEOPAQUE: boolean;
  28902. TONEMAPPING: boolean;
  28903. TONEMAPPING_ACES: boolean;
  28904. CONTRAST: boolean;
  28905. EXPOSURE: boolean;
  28906. COLORCURVES: boolean;
  28907. COLORGRADING: boolean;
  28908. COLORGRADING3D: boolean;
  28909. SAMPLER3DGREENDEPTH: boolean;
  28910. SAMPLER3DBGRMAP: boolean;
  28911. IMAGEPROCESSINGPOSTPROCESS: boolean;
  28912. }
  28913. /**
  28914. * @hidden
  28915. */
  28916. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  28917. IMAGEPROCESSING: boolean;
  28918. VIGNETTE: boolean;
  28919. VIGNETTEBLENDMODEMULTIPLY: boolean;
  28920. VIGNETTEBLENDMODEOPAQUE: boolean;
  28921. TONEMAPPING: boolean;
  28922. TONEMAPPING_ACES: boolean;
  28923. CONTRAST: boolean;
  28924. COLORCURVES: boolean;
  28925. COLORGRADING: boolean;
  28926. COLORGRADING3D: boolean;
  28927. SAMPLER3DGREENDEPTH: boolean;
  28928. SAMPLER3DBGRMAP: boolean;
  28929. IMAGEPROCESSINGPOSTPROCESS: boolean;
  28930. EXPOSURE: boolean;
  28931. constructor();
  28932. }
  28933. /**
  28934. * This groups together the common properties used for image processing either in direct forward pass
  28935. * or through post processing effect depending on the use of the image processing pipeline in your scene
  28936. * or not.
  28937. */
  28938. export class ImageProcessingConfiguration {
  28939. /**
  28940. * Default tone mapping applied in BabylonJS.
  28941. */
  28942. static readonly TONEMAPPING_STANDARD: number;
  28943. /**
  28944. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  28945. * to other engines rendering to increase portability.
  28946. */
  28947. static readonly TONEMAPPING_ACES: number;
  28948. /**
  28949. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  28950. */
  28951. colorCurves: Nullable<ColorCurves>;
  28952. private _colorCurvesEnabled;
  28953. /**
  28954. * Gets wether the color curves effect is enabled.
  28955. */
  28956. /**
  28957. * Sets wether the color curves effect is enabled.
  28958. */
  28959. colorCurvesEnabled: boolean;
  28960. private _colorGradingTexture;
  28961. /**
  28962. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  28963. */
  28964. /**
  28965. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  28966. */
  28967. colorGradingTexture: Nullable<BaseTexture>;
  28968. private _colorGradingEnabled;
  28969. /**
  28970. * Gets wether the color grading effect is enabled.
  28971. */
  28972. /**
  28973. * Sets wether the color grading effect is enabled.
  28974. */
  28975. colorGradingEnabled: boolean;
  28976. private _colorGradingWithGreenDepth;
  28977. /**
  28978. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  28979. */
  28980. /**
  28981. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  28982. */
  28983. colorGradingWithGreenDepth: boolean;
  28984. private _colorGradingBGR;
  28985. /**
  28986. * Gets wether the color grading texture contains BGR values.
  28987. */
  28988. /**
  28989. * Sets wether the color grading texture contains BGR values.
  28990. */
  28991. colorGradingBGR: boolean;
  28992. /** @hidden */
  28993. _exposure: number;
  28994. /**
  28995. * Gets the Exposure used in the effect.
  28996. */
  28997. /**
  28998. * Sets the Exposure used in the effect.
  28999. */
  29000. exposure: number;
  29001. private _toneMappingEnabled;
  29002. /**
  29003. * Gets wether the tone mapping effect is enabled.
  29004. */
  29005. /**
  29006. * Sets wether the tone mapping effect is enabled.
  29007. */
  29008. toneMappingEnabled: boolean;
  29009. private _toneMappingType;
  29010. /**
  29011. * Gets the type of tone mapping effect.
  29012. */
  29013. /**
  29014. * Sets the type of tone mapping effect used in BabylonJS.
  29015. */
  29016. toneMappingType: number;
  29017. protected _contrast: number;
  29018. /**
  29019. * Gets the contrast used in the effect.
  29020. */
  29021. /**
  29022. * Sets the contrast used in the effect.
  29023. */
  29024. contrast: number;
  29025. /**
  29026. * Vignette stretch size.
  29027. */
  29028. vignetteStretch: number;
  29029. /**
  29030. * Vignette centre X Offset.
  29031. */
  29032. vignetteCentreX: number;
  29033. /**
  29034. * Vignette centre Y Offset.
  29035. */
  29036. vignetteCentreY: number;
  29037. /**
  29038. * Vignette weight or intensity of the vignette effect.
  29039. */
  29040. vignetteWeight: number;
  29041. /**
  29042. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29043. * if vignetteEnabled is set to true.
  29044. */
  29045. vignetteColor: Color4;
  29046. /**
  29047. * Camera field of view used by the Vignette effect.
  29048. */
  29049. vignetteCameraFov: number;
  29050. private _vignetteBlendMode;
  29051. /**
  29052. * Gets the vignette blend mode allowing different kind of effect.
  29053. */
  29054. /**
  29055. * Sets the vignette blend mode allowing different kind of effect.
  29056. */
  29057. vignetteBlendMode: number;
  29058. private _vignetteEnabled;
  29059. /**
  29060. * Gets wether the vignette effect is enabled.
  29061. */
  29062. /**
  29063. * Sets wether the vignette effect is enabled.
  29064. */
  29065. vignetteEnabled: boolean;
  29066. private _applyByPostProcess;
  29067. /**
  29068. * Gets wether the image processing is applied through a post process or not.
  29069. */
  29070. /**
  29071. * Sets wether the image processing is applied through a post process or not.
  29072. */
  29073. applyByPostProcess: boolean;
  29074. private _isEnabled;
  29075. /**
  29076. * Gets wether the image processing is enabled or not.
  29077. */
  29078. /**
  29079. * Sets wether the image processing is enabled or not.
  29080. */
  29081. isEnabled: boolean;
  29082. /**
  29083. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29084. */
  29085. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29086. /**
  29087. * Method called each time the image processing information changes requires to recompile the effect.
  29088. */
  29089. protected _updateParameters(): void;
  29090. /**
  29091. * Gets the current class name.
  29092. * @return "ImageProcessingConfiguration"
  29093. */
  29094. getClassName(): string;
  29095. /**
  29096. * Prepare the list of uniforms associated with the Image Processing effects.
  29097. * @param uniforms The list of uniforms used in the effect
  29098. * @param defines the list of defines currently in use
  29099. */
  29100. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29101. /**
  29102. * Prepare the list of samplers associated with the Image Processing effects.
  29103. * @param samplersList The list of uniforms used in the effect
  29104. * @param defines the list of defines currently in use
  29105. */
  29106. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29107. /**
  29108. * Prepare the list of defines associated to the shader.
  29109. * @param defines the list of defines to complete
  29110. * @param forPostProcess Define if we are currently in post process mode or not
  29111. */
  29112. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29113. /**
  29114. * Returns true if all the image processing information are ready.
  29115. * @returns True if ready, otherwise, false
  29116. */
  29117. isReady(): boolean;
  29118. /**
  29119. * Binds the image processing to the shader.
  29120. * @param effect The effect to bind to
  29121. * @param aspectRatio Define the current aspect ratio of the effect
  29122. */
  29123. bind(effect: Effect, aspectRatio?: number): void;
  29124. /**
  29125. * Clones the current image processing instance.
  29126. * @return The cloned image processing
  29127. */
  29128. clone(): ImageProcessingConfiguration;
  29129. /**
  29130. * Serializes the current image processing instance to a json representation.
  29131. * @return a JSON representation
  29132. */
  29133. serialize(): any;
  29134. /**
  29135. * Parses the image processing from a json representation.
  29136. * @param source the JSON source to parse
  29137. * @return The parsed image processing
  29138. */
  29139. static Parse(source: any): ImageProcessingConfiguration;
  29140. private static _VIGNETTEMODE_MULTIPLY;
  29141. private static _VIGNETTEMODE_OPAQUE;
  29142. /**
  29143. * Used to apply the vignette as a mix with the pixel color.
  29144. */
  29145. static readonly VIGNETTEMODE_MULTIPLY: number;
  29146. /**
  29147. * Used to apply the vignette as a replacement of the pixel color.
  29148. */
  29149. static readonly VIGNETTEMODE_OPAQUE: number;
  29150. }
  29151. }
  29152. declare module BABYLON {
  29153. /**
  29154. * This represents all the required information to add a fresnel effect on a material:
  29155. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29156. */
  29157. export class FresnelParameters {
  29158. private _isEnabled;
  29159. /**
  29160. * Define if the fresnel effect is enable or not.
  29161. */
  29162. isEnabled: boolean;
  29163. /**
  29164. * Define the color used on edges (grazing angle)
  29165. */
  29166. leftColor: Color3;
  29167. /**
  29168. * Define the color used on center
  29169. */
  29170. rightColor: Color3;
  29171. /**
  29172. * Define bias applied to computed fresnel term
  29173. */
  29174. bias: number;
  29175. /**
  29176. * Defined the power exponent applied to fresnel term
  29177. */
  29178. power: number;
  29179. /**
  29180. * Clones the current fresnel and its valuues
  29181. * @returns a clone fresnel configuration
  29182. */
  29183. clone(): FresnelParameters;
  29184. /**
  29185. * Serializes the current fresnel parameters to a JSON representation.
  29186. * @return the JSON serialization
  29187. */
  29188. serialize(): any;
  29189. /**
  29190. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29191. * @param parsedFresnelParameters Define the JSON representation
  29192. * @returns the parsed parameters
  29193. */
  29194. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29195. }
  29196. }
  29197. declare module BABYLON {
  29198. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29199. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29200. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29201. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29202. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29203. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29204. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29205. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29206. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29207. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29208. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29209. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29210. /**
  29211. * Decorator used to define property that can be serialized as reference to a camera
  29212. * @param sourceName defines the name of the property to decorate
  29213. */
  29214. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29215. /**
  29216. * Class used to help serialization objects
  29217. */
  29218. export class SerializationHelper {
  29219. /** hidden */
  29220. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29221. /** hidden */
  29222. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29223. /** hidden */
  29224. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29225. /** hidden */
  29226. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29227. /**
  29228. * Appends the serialized animations from the source animations
  29229. * @param source Source containing the animations
  29230. * @param destination Target to store the animations
  29231. */
  29232. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29233. /**
  29234. * Static function used to serialized a specific entity
  29235. * @param entity defines the entity to serialize
  29236. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29237. * @returns a JSON compatible object representing the serialization of the entity
  29238. */
  29239. static Serialize<T>(entity: T, serializationObject?: any): any;
  29240. /**
  29241. * Creates a new entity from a serialization data object
  29242. * @param creationFunction defines a function used to instanciated the new entity
  29243. * @param source defines the source serialization data
  29244. * @param scene defines the hosting scene
  29245. * @param rootUrl defines the root url for resources
  29246. * @returns a new entity
  29247. */
  29248. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29249. /**
  29250. * Clones an object
  29251. * @param creationFunction defines the function used to instanciate the new object
  29252. * @param source defines the source object
  29253. * @returns the cloned object
  29254. */
  29255. static Clone<T>(creationFunction: () => T, source: T): T;
  29256. /**
  29257. * Instanciates a new object based on a source one (some data will be shared between both object)
  29258. * @param creationFunction defines the function used to instanciate the new object
  29259. * @param source defines the source object
  29260. * @returns the new object
  29261. */
  29262. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29263. }
  29264. }
  29265. declare module BABYLON {
  29266. /**
  29267. * This is the base class of all the camera used in the application.
  29268. * @see http://doc.babylonjs.com/features/cameras
  29269. */
  29270. export class Camera extends Node {
  29271. /** @hidden */
  29272. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29273. /**
  29274. * This is the default projection mode used by the cameras.
  29275. * It helps recreating a feeling of perspective and better appreciate depth.
  29276. * This is the best way to simulate real life cameras.
  29277. */
  29278. static readonly PERSPECTIVE_CAMERA: number;
  29279. /**
  29280. * This helps creating camera with an orthographic mode.
  29281. * 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.
  29282. */
  29283. static readonly ORTHOGRAPHIC_CAMERA: number;
  29284. /**
  29285. * This is the default FOV mode for perspective cameras.
  29286. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29287. */
  29288. static readonly FOVMODE_VERTICAL_FIXED: number;
  29289. /**
  29290. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29291. */
  29292. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29293. /**
  29294. * This specifies ther is no need for a camera rig.
  29295. * Basically only one eye is rendered corresponding to the camera.
  29296. */
  29297. static readonly RIG_MODE_NONE: number;
  29298. /**
  29299. * Simulates a camera Rig with one blue eye and one red eye.
  29300. * This can be use with 3d blue and red glasses.
  29301. */
  29302. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29303. /**
  29304. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29305. */
  29306. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29307. /**
  29308. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29309. */
  29310. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29311. /**
  29312. * Defines that both eyes of the camera will be rendered over under each other.
  29313. */
  29314. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29315. /**
  29316. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29317. */
  29318. static readonly RIG_MODE_VR: number;
  29319. /**
  29320. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29321. */
  29322. static readonly RIG_MODE_WEBVR: number;
  29323. /**
  29324. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29325. */
  29326. static readonly RIG_MODE_CUSTOM: number;
  29327. /**
  29328. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29329. */
  29330. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29331. /**
  29332. * @hidden
  29333. * Might be removed once multiview will be a thing
  29334. */
  29335. static UseAlternateWebVRRendering: boolean;
  29336. /**
  29337. * Define the input manager associated with the camera.
  29338. */
  29339. inputs: CameraInputsManager<Camera>;
  29340. /**
  29341. * Define the current local position of the camera in the scene
  29342. */
  29343. position: Vector3;
  29344. /**
  29345. * The vector the camera should consider as up.
  29346. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29347. */
  29348. upVector: Vector3;
  29349. /**
  29350. * Define the current limit on the left side for an orthographic camera
  29351. * In scene unit
  29352. */
  29353. orthoLeft: Nullable<number>;
  29354. /**
  29355. * Define the current limit on the right side for an orthographic camera
  29356. * In scene unit
  29357. */
  29358. orthoRight: Nullable<number>;
  29359. /**
  29360. * Define the current limit on the bottom side for an orthographic camera
  29361. * In scene unit
  29362. */
  29363. orthoBottom: Nullable<number>;
  29364. /**
  29365. * Define the current limit on the top side for an orthographic camera
  29366. * In scene unit
  29367. */
  29368. orthoTop: Nullable<number>;
  29369. /**
  29370. * Field Of View is set in Radians. (default is 0.8)
  29371. */
  29372. fov: number;
  29373. /**
  29374. * Define the minimum distance the camera can see from.
  29375. * This is important to note that the depth buffer are not infinite and the closer it starts
  29376. * the more your scene might encounter depth fighting issue.
  29377. */
  29378. minZ: number;
  29379. /**
  29380. * Define the maximum distance the camera can see to.
  29381. * This is important to note that the depth buffer are not infinite and the further it end
  29382. * the more your scene might encounter depth fighting issue.
  29383. */
  29384. maxZ: number;
  29385. /**
  29386. * Define the default inertia of the camera.
  29387. * This helps giving a smooth feeling to the camera movement.
  29388. */
  29389. inertia: number;
  29390. /**
  29391. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  29392. */
  29393. mode: number;
  29394. /**
  29395. * Define wether the camera is intermediate.
  29396. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29397. */
  29398. isIntermediate: boolean;
  29399. /**
  29400. * Define the viewport of the camera.
  29401. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29402. */
  29403. viewport: Viewport;
  29404. /**
  29405. * Restricts the camera to viewing objects with the same layerMask.
  29406. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29407. */
  29408. layerMask: number;
  29409. /**
  29410. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29411. */
  29412. fovMode: number;
  29413. /**
  29414. * Rig mode of the camera.
  29415. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29416. * This is normally controlled byt the camera themselves as internal use.
  29417. */
  29418. cameraRigMode: number;
  29419. /**
  29420. * Defines the distance between both "eyes" in case of a RIG
  29421. */
  29422. interaxialDistance: number;
  29423. /**
  29424. * Defines if stereoscopic rendering is done side by side or over under.
  29425. */
  29426. isStereoscopicSideBySide: boolean;
  29427. /**
  29428. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  29429. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29430. * else in the scene.
  29431. */
  29432. customRenderTargets: RenderTargetTexture[];
  29433. /**
  29434. * When set, the camera will render to this render target instead of the default canvas
  29435. */
  29436. outputRenderTarget: Nullable<RenderTargetTexture>;
  29437. /**
  29438. * Observable triggered when the camera view matrix has changed.
  29439. */
  29440. onViewMatrixChangedObservable: Observable<Camera>;
  29441. /**
  29442. * Observable triggered when the camera Projection matrix has changed.
  29443. */
  29444. onProjectionMatrixChangedObservable: Observable<Camera>;
  29445. /**
  29446. * Observable triggered when the inputs have been processed.
  29447. */
  29448. onAfterCheckInputsObservable: Observable<Camera>;
  29449. /**
  29450. * Observable triggered when reset has been called and applied to the camera.
  29451. */
  29452. onRestoreStateObservable: Observable<Camera>;
  29453. /** @hidden */
  29454. _cameraRigParams: any;
  29455. /** @hidden */
  29456. _rigCameras: Camera[];
  29457. /** @hidden */
  29458. _rigPostProcess: Nullable<PostProcess>;
  29459. protected _webvrViewMatrix: Matrix;
  29460. /** @hidden */
  29461. _skipRendering: boolean;
  29462. /** @hidden */
  29463. _alternateCamera: Camera;
  29464. /** @hidden */
  29465. _projectionMatrix: Matrix;
  29466. /** @hidden */
  29467. _postProcesses: Nullable<PostProcess>[];
  29468. /** @hidden */
  29469. _activeMeshes: SmartArray<AbstractMesh>;
  29470. protected _globalPosition: Vector3;
  29471. /** hidden */
  29472. _computedViewMatrix: Matrix;
  29473. private _doNotComputeProjectionMatrix;
  29474. private _transformMatrix;
  29475. private _frustumPlanes;
  29476. private _refreshFrustumPlanes;
  29477. private _storedFov;
  29478. private _stateStored;
  29479. /**
  29480. * Instantiates a new camera object.
  29481. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29482. * @see http://doc.babylonjs.com/features/cameras
  29483. * @param name Defines the name of the camera in the scene
  29484. * @param position Defines the position of the camera
  29485. * @param scene Defines the scene the camera belongs too
  29486. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29487. */
  29488. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29489. /**
  29490. * Store current camera state (fov, position, etc..)
  29491. * @returns the camera
  29492. */
  29493. storeState(): Camera;
  29494. /**
  29495. * Restores the camera state values if it has been stored. You must call storeState() first
  29496. */
  29497. protected _restoreStateValues(): boolean;
  29498. /**
  29499. * Restored camera state. You must call storeState() first.
  29500. * @returns true if restored and false otherwise
  29501. */
  29502. restoreState(): boolean;
  29503. /**
  29504. * Gets the class name of the camera.
  29505. * @returns the class name
  29506. */
  29507. getClassName(): string;
  29508. /** @hidden */
  29509. readonly _isCamera: boolean;
  29510. /**
  29511. * Gets a string representation of the camera useful for debug purpose.
  29512. * @param fullDetails Defines that a more verboe level of logging is required
  29513. * @returns the string representation
  29514. */
  29515. toString(fullDetails?: boolean): string;
  29516. /**
  29517. * Gets the current world space position of the camera.
  29518. */
  29519. readonly globalPosition: Vector3;
  29520. /**
  29521. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29522. * @returns the active meshe list
  29523. */
  29524. getActiveMeshes(): SmartArray<AbstractMesh>;
  29525. /**
  29526. * Check wether a mesh is part of the current active mesh list of the camera
  29527. * @param mesh Defines the mesh to check
  29528. * @returns true if active, false otherwise
  29529. */
  29530. isActiveMesh(mesh: Mesh): boolean;
  29531. /**
  29532. * Is this camera ready to be used/rendered
  29533. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29534. * @return true if the camera is ready
  29535. */
  29536. isReady(completeCheck?: boolean): boolean;
  29537. /** @hidden */
  29538. _initCache(): void;
  29539. /** @hidden */
  29540. _updateCache(ignoreParentClass?: boolean): void;
  29541. /** @hidden */
  29542. _isSynchronized(): boolean;
  29543. /** @hidden */
  29544. _isSynchronizedViewMatrix(): boolean;
  29545. /** @hidden */
  29546. _isSynchronizedProjectionMatrix(): boolean;
  29547. /**
  29548. * Attach the input controls to a specific dom element to get the input from.
  29549. * @param element Defines the element the controls should be listened from
  29550. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29551. */
  29552. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29553. /**
  29554. * Detach the current controls from the specified dom element.
  29555. * @param element Defines the element to stop listening the inputs from
  29556. */
  29557. detachControl(element: HTMLElement): void;
  29558. /**
  29559. * Update the camera state according to the different inputs gathered during the frame.
  29560. */
  29561. update(): void;
  29562. /** @hidden */
  29563. _checkInputs(): void;
  29564. /** @hidden */
  29565. readonly rigCameras: Camera[];
  29566. /**
  29567. * Gets the post process used by the rig cameras
  29568. */
  29569. readonly rigPostProcess: Nullable<PostProcess>;
  29570. /**
  29571. * Internal, gets the first post proces.
  29572. * @returns the first post process to be run on this camera.
  29573. */
  29574. _getFirstPostProcess(): Nullable<PostProcess>;
  29575. private _cascadePostProcessesToRigCams;
  29576. /**
  29577. * Attach a post process to the camera.
  29578. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29579. * @param postProcess The post process to attach to the camera
  29580. * @param insertAt The position of the post process in case several of them are in use in the scene
  29581. * @returns the position the post process has been inserted at
  29582. */
  29583. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29584. /**
  29585. * Detach a post process to the camera.
  29586. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29587. * @param postProcess The post process to detach from the camera
  29588. */
  29589. detachPostProcess(postProcess: PostProcess): void;
  29590. /**
  29591. * Gets the current world matrix of the camera
  29592. */
  29593. getWorldMatrix(): Matrix;
  29594. /** @hidden */
  29595. _getViewMatrix(): Matrix;
  29596. /**
  29597. * Gets the current view matrix of the camera.
  29598. * @param force forces the camera to recompute the matrix without looking at the cached state
  29599. * @returns the view matrix
  29600. */
  29601. getViewMatrix(force?: boolean): Matrix;
  29602. /**
  29603. * Freeze the projection matrix.
  29604. * It will prevent the cache check of the camera projection compute and can speed up perf
  29605. * if no parameter of the camera are meant to change
  29606. * @param projection Defines manually a projection if necessary
  29607. */
  29608. freezeProjectionMatrix(projection?: Matrix): void;
  29609. /**
  29610. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29611. */
  29612. unfreezeProjectionMatrix(): void;
  29613. /**
  29614. * Gets the current projection matrix of the camera.
  29615. * @param force forces the camera to recompute the matrix without looking at the cached state
  29616. * @returns the projection matrix
  29617. */
  29618. getProjectionMatrix(force?: boolean): Matrix;
  29619. /**
  29620. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29621. * @returns a Matrix
  29622. */
  29623. getTransformationMatrix(): Matrix;
  29624. private _updateFrustumPlanes;
  29625. /**
  29626. * Checks if a cullable object (mesh...) is in the camera frustum
  29627. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29628. * @param target The object to check
  29629. * @returns true if the object is in frustum otherwise false
  29630. */
  29631. isInFrustum(target: ICullable): boolean;
  29632. /**
  29633. * Checks if a cullable object (mesh...) is in the camera frustum
  29634. * Unlike isInFrustum this cheks the full bounding box
  29635. * @param target The object to check
  29636. * @returns true if the object is in frustum otherwise false
  29637. */
  29638. isCompletelyInFrustum(target: ICullable): boolean;
  29639. /**
  29640. * Gets a ray in the forward direction from the camera.
  29641. * @param length Defines the length of the ray to create
  29642. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29643. * @param origin Defines the start point of the ray which defaults to the camera position
  29644. * @returns the forward ray
  29645. */
  29646. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29647. /**
  29648. * Releases resources associated with this node.
  29649. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29650. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29651. */
  29652. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29653. /**
  29654. * Gets the left camera of a rig setup in case of Rigged Camera
  29655. */
  29656. readonly leftCamera: Nullable<FreeCamera>;
  29657. /**
  29658. * Gets the right camera of a rig setup in case of Rigged Camera
  29659. */
  29660. readonly rightCamera: Nullable<FreeCamera>;
  29661. /**
  29662. * Gets the left camera target of a rig setup in case of Rigged Camera
  29663. * @returns the target position
  29664. */
  29665. getLeftTarget(): Nullable<Vector3>;
  29666. /**
  29667. * Gets the right camera target of a rig setup in case of Rigged Camera
  29668. * @returns the target position
  29669. */
  29670. getRightTarget(): Nullable<Vector3>;
  29671. /**
  29672. * @hidden
  29673. */
  29674. setCameraRigMode(mode: number, rigParams: any): void;
  29675. /** @hidden */
  29676. static _setStereoscopicRigMode(camera: Camera): void;
  29677. /** @hidden */
  29678. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29679. /** @hidden */
  29680. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29681. /** @hidden */
  29682. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29683. /** @hidden */
  29684. _getVRProjectionMatrix(): Matrix;
  29685. protected _updateCameraRotationMatrix(): void;
  29686. protected _updateWebVRCameraRotationMatrix(): void;
  29687. /**
  29688. * This function MUST be overwritten by the different WebVR cameras available.
  29689. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29690. * @hidden
  29691. */
  29692. _getWebVRProjectionMatrix(): Matrix;
  29693. /**
  29694. * This function MUST be overwritten by the different WebVR cameras available.
  29695. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29696. * @hidden
  29697. */
  29698. _getWebVRViewMatrix(): Matrix;
  29699. /** @hidden */
  29700. setCameraRigParameter(name: string, value: any): void;
  29701. /**
  29702. * needs to be overridden by children so sub has required properties to be copied
  29703. * @hidden
  29704. */
  29705. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29706. /**
  29707. * May need to be overridden by children
  29708. * @hidden
  29709. */
  29710. _updateRigCameras(): void;
  29711. /** @hidden */
  29712. _setupInputs(): void;
  29713. /**
  29714. * Serialiaze the camera setup to a json represention
  29715. * @returns the JSON representation
  29716. */
  29717. serialize(): any;
  29718. /**
  29719. * Clones the current camera.
  29720. * @param name The cloned camera name
  29721. * @returns the cloned camera
  29722. */
  29723. clone(name: string): Camera;
  29724. /**
  29725. * Gets the direction of the camera relative to a given local axis.
  29726. * @param localAxis Defines the reference axis to provide a relative direction.
  29727. * @return the direction
  29728. */
  29729. getDirection(localAxis: Vector3): Vector3;
  29730. /**
  29731. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29732. * @param localAxis Defines the reference axis to provide a relative direction.
  29733. * @param result Defines the vector to store the result in
  29734. */
  29735. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29736. /**
  29737. * Gets a camera constructor for a given camera type
  29738. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29739. * @param name The name of the camera the result will be able to instantiate
  29740. * @param scene The scene the result will construct the camera in
  29741. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29742. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29743. * @returns a factory method to construc the camera
  29744. */
  29745. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29746. /**
  29747. * Compute the world matrix of the camera.
  29748. * @returns the camera workd matrix
  29749. */
  29750. computeWorldMatrix(): Matrix;
  29751. /**
  29752. * Parse a JSON and creates the camera from the parsed information
  29753. * @param parsedCamera The JSON to parse
  29754. * @param scene The scene to instantiate the camera in
  29755. * @returns the newly constructed camera
  29756. */
  29757. static Parse(parsedCamera: any, scene: Scene): Camera;
  29758. }
  29759. }
  29760. declare module BABYLON {
  29761. /**
  29762. * Interface for any object that can request an animation frame
  29763. */
  29764. export interface ICustomAnimationFrameRequester {
  29765. /**
  29766. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29767. */
  29768. renderFunction?: Function;
  29769. /**
  29770. * Called to request the next frame to render to
  29771. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29772. */
  29773. requestAnimationFrame: Function;
  29774. /**
  29775. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29776. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29777. */
  29778. requestID?: number;
  29779. }
  29780. /**
  29781. * Interface containing an array of animations
  29782. */
  29783. export interface IAnimatable {
  29784. /**
  29785. * Array of animations
  29786. */
  29787. animations: Array<Animation>;
  29788. }
  29789. /** Interface used by value gradients (color, factor, ...) */
  29790. export interface IValueGradient {
  29791. /**
  29792. * Gets or sets the gradient value (between 0 and 1)
  29793. */
  29794. gradient: number;
  29795. }
  29796. /** Class used to store color4 gradient */
  29797. export class ColorGradient implements IValueGradient {
  29798. /**
  29799. * Gets or sets the gradient value (between 0 and 1)
  29800. */
  29801. gradient: number;
  29802. /**
  29803. * Gets or sets first associated color
  29804. */
  29805. color1: Color4;
  29806. /**
  29807. * Gets or sets second associated color
  29808. */
  29809. color2?: Color4;
  29810. /**
  29811. * Will get a color picked randomly between color1 and color2.
  29812. * If color2 is undefined then color1 will be used
  29813. * @param result defines the target Color4 to store the result in
  29814. */
  29815. getColorToRef(result: Color4): void;
  29816. }
  29817. /** Class used to store color 3 gradient */
  29818. export class Color3Gradient implements IValueGradient {
  29819. /**
  29820. * Gets or sets the gradient value (between 0 and 1)
  29821. */
  29822. gradient: number;
  29823. /**
  29824. * Gets or sets the associated color
  29825. */
  29826. color: Color3;
  29827. }
  29828. /** Class used to store factor gradient */
  29829. export class FactorGradient implements IValueGradient {
  29830. /**
  29831. * Gets or sets the gradient value (between 0 and 1)
  29832. */
  29833. gradient: number;
  29834. /**
  29835. * Gets or sets first associated factor
  29836. */
  29837. factor1: number;
  29838. /**
  29839. * Gets or sets second associated factor
  29840. */
  29841. factor2?: number;
  29842. /**
  29843. * Will get a number picked randomly between factor1 and factor2.
  29844. * If factor2 is undefined then factor1 will be used
  29845. * @returns the picked number
  29846. */
  29847. getFactor(): number;
  29848. }
  29849. /**
  29850. * @ignore
  29851. * Application error to support additional information when loading a file
  29852. */
  29853. export class LoadFileError extends Error {
  29854. /** defines the optional XHR request */
  29855. request?: XMLHttpRequest | undefined;
  29856. private static _setPrototypeOf;
  29857. /**
  29858. * Creates a new LoadFileError
  29859. * @param message defines the message of the error
  29860. * @param request defines the optional XHR request
  29861. */
  29862. constructor(message: string,
  29863. /** defines the optional XHR request */
  29864. request?: XMLHttpRequest | undefined);
  29865. }
  29866. /**
  29867. * Class used to define a retry strategy when error happens while loading assets
  29868. */
  29869. export class RetryStrategy {
  29870. /**
  29871. * Function used to defines an exponential back off strategy
  29872. * @param maxRetries defines the maximum number of retries (3 by default)
  29873. * @param baseInterval defines the interval between retries
  29874. * @returns the strategy function to use
  29875. */
  29876. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29877. }
  29878. /**
  29879. * File request interface
  29880. */
  29881. export interface IFileRequest {
  29882. /**
  29883. * Raised when the request is complete (success or error).
  29884. */
  29885. onCompleteObservable: Observable<IFileRequest>;
  29886. /**
  29887. * Aborts the request for a file.
  29888. */
  29889. abort: () => void;
  29890. }
  29891. /**
  29892. * Class containing a set of static utilities functions
  29893. */
  29894. export class Tools {
  29895. /**
  29896. * Gets or sets the base URL to use to load assets
  29897. */
  29898. static BaseUrl: string;
  29899. /**
  29900. * Enable/Disable Custom HTTP Request Headers globally.
  29901. * default = false
  29902. * @see CustomRequestHeaders
  29903. */
  29904. static UseCustomRequestHeaders: boolean;
  29905. /**
  29906. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  29907. * i.e. when loading files, where the server/service expects an Authorization header.
  29908. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  29909. */
  29910. static CustomRequestHeaders: {
  29911. [key: string]: string;
  29912. };
  29913. /**
  29914. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  29915. */
  29916. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29917. /**
  29918. * Default behaviour for cors in the application.
  29919. * It can be a string if the expected behavior is identical in the entire app.
  29920. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  29921. */
  29922. static CorsBehavior: string | ((url: string | string[]) => string);
  29923. /**
  29924. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  29925. * @ignorenaming
  29926. */
  29927. static UseFallbackTexture: boolean;
  29928. /**
  29929. * Use this object to register external classes like custom textures or material
  29930. * to allow the laoders to instantiate them
  29931. */
  29932. static RegisteredExternalClasses: {
  29933. [key: string]: Object;
  29934. };
  29935. /**
  29936. * Texture content used if a texture cannot loaded
  29937. * @ignorenaming
  29938. */
  29939. static fallbackTexture: string;
  29940. /**
  29941. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  29942. * @param u defines the coordinate on X axis
  29943. * @param v defines the coordinate on Y axis
  29944. * @param width defines the width of the source data
  29945. * @param height defines the height of the source data
  29946. * @param pixels defines the source byte array
  29947. * @param color defines the output color
  29948. */
  29949. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  29950. /**
  29951. * Interpolates between a and b via alpha
  29952. * @param a The lower value (returned when alpha = 0)
  29953. * @param b The upper value (returned when alpha = 1)
  29954. * @param alpha The interpolation-factor
  29955. * @return The mixed value
  29956. */
  29957. static Mix(a: number, b: number, alpha: number): number;
  29958. /**
  29959. * Tries to instantiate a new object from a given class name
  29960. * @param className defines the class name to instantiate
  29961. * @returns the new object or null if the system was not able to do the instantiation
  29962. */
  29963. static Instantiate(className: string): any;
  29964. /**
  29965. * Provides a slice function that will work even on IE
  29966. * @param data defines the array to slice
  29967. * @param start defines the start of the data (optional)
  29968. * @param end defines the end of the data (optional)
  29969. * @returns the new sliced array
  29970. */
  29971. static Slice<T>(data: T, start?: number, end?: number): T;
  29972. /**
  29973. * Polyfill for setImmediate
  29974. * @param action defines the action to execute after the current execution block
  29975. */
  29976. static SetImmediate(action: () => void): void;
  29977. /**
  29978. * Function indicating if a number is an exponent of 2
  29979. * @param value defines the value to test
  29980. * @returns true if the value is an exponent of 2
  29981. */
  29982. static IsExponentOfTwo(value: number): boolean;
  29983. private static _tmpFloatArray;
  29984. /**
  29985. * Returns the nearest 32-bit single precision float representation of a Number
  29986. * @param value A Number. If the parameter is of a different type, it will get converted
  29987. * to a number or to NaN if it cannot be converted
  29988. * @returns number
  29989. */
  29990. static FloatRound(value: number): number;
  29991. /**
  29992. * Find the next highest power of two.
  29993. * @param x Number to start search from.
  29994. * @return Next highest power of two.
  29995. */
  29996. static CeilingPOT(x: number): number;
  29997. /**
  29998. * Find the next lowest power of two.
  29999. * @param x Number to start search from.
  30000. * @return Next lowest power of two.
  30001. */
  30002. static FloorPOT(x: number): number;
  30003. /**
  30004. * Find the nearest power of two.
  30005. * @param x Number to start search from.
  30006. * @return Next nearest power of two.
  30007. */
  30008. static NearestPOT(x: number): number;
  30009. /**
  30010. * Get the closest exponent of two
  30011. * @param value defines the value to approximate
  30012. * @param max defines the maximum value to return
  30013. * @param mode defines how to define the closest value
  30014. * @returns closest exponent of two of the given value
  30015. */
  30016. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30017. /**
  30018. * Extracts the filename from a path
  30019. * @param path defines the path to use
  30020. * @returns the filename
  30021. */
  30022. static GetFilename(path: string): string;
  30023. /**
  30024. * Extracts the "folder" part of a path (everything before the filename).
  30025. * @param uri The URI to extract the info from
  30026. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30027. * @returns The "folder" part of the path
  30028. */
  30029. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30030. /**
  30031. * Extracts text content from a DOM element hierarchy
  30032. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30033. */
  30034. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30035. /**
  30036. * Convert an angle in radians to degrees
  30037. * @param angle defines the angle to convert
  30038. * @returns the angle in degrees
  30039. */
  30040. static ToDegrees(angle: number): number;
  30041. /**
  30042. * Convert an angle in degrees to radians
  30043. * @param angle defines the angle to convert
  30044. * @returns the angle in radians
  30045. */
  30046. static ToRadians(angle: number): number;
  30047. /**
  30048. * Encode a buffer to a base64 string
  30049. * @param buffer defines the buffer to encode
  30050. * @returns the encoded string
  30051. */
  30052. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30053. /**
  30054. * Extracts minimum and maximum values from a list of indexed positions
  30055. * @param positions defines the positions to use
  30056. * @param indices defines the indices to the positions
  30057. * @param indexStart defines the start index
  30058. * @param indexCount defines the end index
  30059. * @param bias defines bias value to add to the result
  30060. * @return minimum and maximum values
  30061. */
  30062. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30063. minimum: Vector3;
  30064. maximum: Vector3;
  30065. };
  30066. /**
  30067. * Extracts minimum and maximum values from a list of positions
  30068. * @param positions defines the positions to use
  30069. * @param start defines the start index in the positions array
  30070. * @param count defines the number of positions to handle
  30071. * @param bias defines bias value to add to the result
  30072. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30073. * @return minimum and maximum values
  30074. */
  30075. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30076. minimum: Vector3;
  30077. maximum: Vector3;
  30078. };
  30079. /**
  30080. * Returns an array if obj is not an array
  30081. * @param obj defines the object to evaluate as an array
  30082. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30083. * @returns either obj directly if obj is an array or a new array containing obj
  30084. */
  30085. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30086. /**
  30087. * Gets the pointer prefix to use
  30088. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30089. */
  30090. static GetPointerPrefix(): string;
  30091. /**
  30092. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30093. * @param func - the function to be called
  30094. * @param requester - the object that will request the next frame. Falls back to window.
  30095. * @returns frame number
  30096. */
  30097. static QueueNewFrame(func: () => void, requester?: any): number;
  30098. /**
  30099. * Ask the browser to promote the current element to fullscreen rendering mode
  30100. * @param element defines the DOM element to promote
  30101. */
  30102. static RequestFullscreen(element: HTMLElement): void;
  30103. /**
  30104. * Asks the browser to exit fullscreen mode
  30105. */
  30106. static ExitFullscreen(): void;
  30107. /**
  30108. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30109. * @param url define the url we are trying
  30110. * @param element define the dom element where to configure the cors policy
  30111. */
  30112. static SetCorsBehavior(url: string | string[], element: {
  30113. crossOrigin: string | null;
  30114. }): void;
  30115. /**
  30116. * Removes unwanted characters from an url
  30117. * @param url defines the url to clean
  30118. * @returns the cleaned url
  30119. */
  30120. static CleanUrl(url: string): string;
  30121. /**
  30122. * Gets or sets a function used to pre-process url before using them to load assets
  30123. */
  30124. static PreprocessUrl: (url: string) => string;
  30125. /**
  30126. * Loads an image as an HTMLImageElement.
  30127. * @param input url string, ArrayBuffer, or Blob to load
  30128. * @param onLoad callback called when the image successfully loads
  30129. * @param onError callback called when the image fails to load
  30130. * @param offlineProvider offline provider for caching
  30131. * @returns the HTMLImageElement of the loaded image
  30132. */
  30133. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30134. /**
  30135. * Loads a file
  30136. * @param url url string, ArrayBuffer, or Blob to load
  30137. * @param onSuccess callback called when the file successfully loads
  30138. * @param onProgress callback called while file is loading (if the server supports this mode)
  30139. * @param offlineProvider defines the offline provider for caching
  30140. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30141. * @param onError callback called when the file fails to load
  30142. * @returns a file request object
  30143. */
  30144. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  30145. /**
  30146. * Load a script (identified by an url). When the url returns, the
  30147. * content of this file is added into a new script element, attached to the DOM (body element)
  30148. * @param scriptUrl defines the url of the script to laod
  30149. * @param onSuccess defines the callback called when the script is loaded
  30150. * @param onError defines the callback to call if an error occurs
  30151. */
  30152. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  30153. /**
  30154. * Loads a file from a blob
  30155. * @param fileToLoad defines the blob to use
  30156. * @param callback defines the callback to call when data is loaded
  30157. * @param progressCallback defines the callback to call during loading process
  30158. * @returns a file request object
  30159. */
  30160. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30161. /**
  30162. * Loads a file
  30163. * @param fileToLoad defines the file to load
  30164. * @param callback defines the callback to call when data is loaded
  30165. * @param progressCallBack defines the callback to call during loading process
  30166. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30167. * @returns a file request object
  30168. */
  30169. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30170. /**
  30171. * Creates a data url from a given string content
  30172. * @param content defines the content to convert
  30173. * @returns the new data url link
  30174. */
  30175. static FileAsURL(content: string): string;
  30176. /**
  30177. * Format the given number to a specific decimal format
  30178. * @param value defines the number to format
  30179. * @param decimals defines the number of decimals to use
  30180. * @returns the formatted string
  30181. */
  30182. static Format(value: number, decimals?: number): string;
  30183. /**
  30184. * Checks if a given vector is inside a specific range
  30185. * @param v defines the vector to test
  30186. * @param min defines the minimum range
  30187. * @param max defines the maximum range
  30188. */
  30189. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30190. /**
  30191. * Tries to copy an object by duplicating every property
  30192. * @param source defines the source object
  30193. * @param destination defines the target object
  30194. * @param doNotCopyList defines a list of properties to avoid
  30195. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30196. */
  30197. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30198. /**
  30199. * Gets a boolean indicating if the given object has no own property
  30200. * @param obj defines the object to test
  30201. * @returns true if object has no own property
  30202. */
  30203. static IsEmpty(obj: any): boolean;
  30204. /**
  30205. * Function used to register events at window level
  30206. * @param events defines the events to register
  30207. */
  30208. static RegisterTopRootEvents(events: {
  30209. name: string;
  30210. handler: Nullable<(e: FocusEvent) => any>;
  30211. }[]): void;
  30212. /**
  30213. * Function used to unregister events from window level
  30214. * @param events defines the events to unregister
  30215. */
  30216. static UnregisterTopRootEvents(events: {
  30217. name: string;
  30218. handler: Nullable<(e: FocusEvent) => any>;
  30219. }[]): void;
  30220. /**
  30221. * Dumps the current bound framebuffer
  30222. * @param width defines the rendering width
  30223. * @param height defines the rendering height
  30224. * @param engine defines the hosting engine
  30225. * @param successCallback defines the callback triggered once the data are available
  30226. * @param mimeType defines the mime type of the result
  30227. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30228. */
  30229. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30230. /**
  30231. * Converts the canvas data to blob.
  30232. * This acts as a polyfill for browsers not supporting the to blob function.
  30233. * @param canvas Defines the canvas to extract the data from
  30234. * @param successCallback Defines the callback triggered once the data are available
  30235. * @param mimeType Defines the mime type of the result
  30236. */
  30237. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30238. /**
  30239. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30240. * @param successCallback defines the callback triggered once the data are available
  30241. * @param mimeType defines the mime type of the result
  30242. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30243. */
  30244. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30245. /**
  30246. * Downloads a blob in the browser
  30247. * @param blob defines the blob to download
  30248. * @param fileName defines the name of the downloaded file
  30249. */
  30250. static Download(blob: Blob, fileName: string): void;
  30251. /**
  30252. * Captures a screenshot of the current rendering
  30253. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30254. * @param engine defines the rendering engine
  30255. * @param camera defines the source camera
  30256. * @param size This parameter can be set to a single number or to an object with the
  30257. * following (optional) properties: precision, width, height. If a single number is passed,
  30258. * it will be used for both width and height. If an object is passed, the screenshot size
  30259. * will be derived from the parameters. The precision property is a multiplier allowing
  30260. * rendering at a higher or lower resolution
  30261. * @param successCallback defines the callback receives a single parameter which contains the
  30262. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30263. * src parameter of an <img> to display it
  30264. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  30265. * Check your browser for supported MIME types
  30266. */
  30267. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30268. /**
  30269. * Generates an image screenshot from the specified camera.
  30270. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30271. * @param engine The engine to use for rendering
  30272. * @param camera The camera to use for rendering
  30273. * @param size This parameter can be set to a single number or to an object with the
  30274. * following (optional) properties: precision, width, height. If a single number is passed,
  30275. * it will be used for both width and height. If an object is passed, the screenshot size
  30276. * will be derived from the parameters. The precision property is a multiplier allowing
  30277. * rendering at a higher or lower resolution
  30278. * @param successCallback The callback receives a single parameter which contains the
  30279. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30280. * src parameter of an <img> to display it
  30281. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30282. * Check your browser for supported MIME types
  30283. * @param samples Texture samples (default: 1)
  30284. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30285. * @param fileName A name for for the downloaded file.
  30286. */
  30287. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30288. /**
  30289. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30290. * Be aware Math.random() could cause collisions, but:
  30291. * "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"
  30292. * @returns a pseudo random id
  30293. */
  30294. static RandomId(): string;
  30295. /**
  30296. * Test if the given uri is a base64 string
  30297. * @param uri The uri to test
  30298. * @return True if the uri is a base64 string or false otherwise
  30299. */
  30300. static IsBase64(uri: string): boolean;
  30301. /**
  30302. * Decode the given base64 uri.
  30303. * @param uri The uri to decode
  30304. * @return The decoded base64 data.
  30305. */
  30306. static DecodeBase64(uri: string): ArrayBuffer;
  30307. /**
  30308. * No log
  30309. */
  30310. static readonly NoneLogLevel: number;
  30311. /**
  30312. * Only message logs
  30313. */
  30314. static readonly MessageLogLevel: number;
  30315. /**
  30316. * Only warning logs
  30317. */
  30318. static readonly WarningLogLevel: number;
  30319. /**
  30320. * Only error logs
  30321. */
  30322. static readonly ErrorLogLevel: number;
  30323. /**
  30324. * All logs
  30325. */
  30326. static readonly AllLogLevel: number;
  30327. /**
  30328. * Gets a value indicating the number of loading errors
  30329. * @ignorenaming
  30330. */
  30331. static readonly errorsCount: number;
  30332. /**
  30333. * Callback called when a new log is added
  30334. */
  30335. static OnNewCacheEntry: (entry: string) => void;
  30336. /**
  30337. * Log a message to the console
  30338. * @param message defines the message to log
  30339. */
  30340. static Log(message: string): void;
  30341. /**
  30342. * Write a warning message to the console
  30343. * @param message defines the message to log
  30344. */
  30345. static Warn(message: string): void;
  30346. /**
  30347. * Write an error message to the console
  30348. * @param message defines the message to log
  30349. */
  30350. static Error(message: string): void;
  30351. /**
  30352. * Gets current log cache (list of logs)
  30353. */
  30354. static readonly LogCache: string;
  30355. /**
  30356. * Clears the log cache
  30357. */
  30358. static ClearLogCache(): void;
  30359. /**
  30360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  30361. */
  30362. static LogLevels: number;
  30363. /**
  30364. * Checks if the loaded document was accessed via `file:`-Protocol.
  30365. * @returns boolean
  30366. */
  30367. static IsFileURL(): boolean;
  30368. /**
  30369. * Checks if the window object exists
  30370. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  30371. */
  30372. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  30373. /**
  30374. * No performance log
  30375. */
  30376. static readonly PerformanceNoneLogLevel: number;
  30377. /**
  30378. * Use user marks to log performance
  30379. */
  30380. static readonly PerformanceUserMarkLogLevel: number;
  30381. /**
  30382. * Log performance to the console
  30383. */
  30384. static readonly PerformanceConsoleLogLevel: number;
  30385. private static _performance;
  30386. /**
  30387. * Sets the current performance log level
  30388. */
  30389. static PerformanceLogLevel: number;
  30390. private static _StartPerformanceCounterDisabled;
  30391. private static _EndPerformanceCounterDisabled;
  30392. private static _StartUserMark;
  30393. private static _EndUserMark;
  30394. private static _StartPerformanceConsole;
  30395. private static _EndPerformanceConsole;
  30396. /**
  30397. * Injects the @see CustomRequestHeaders into the given request
  30398. * @param request the request that should be used for injection
  30399. */
  30400. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  30401. /**
  30402. * Starts a performance counter
  30403. */
  30404. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30405. /**
  30406. * Ends a specific performance coutner
  30407. */
  30408. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30409. /**
  30410. * Gets either window.performance.now() if supported or Date.now() else
  30411. */
  30412. static readonly Now: number;
  30413. /**
  30414. * This method will return the name of the class used to create the instance of the given object.
  30415. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  30416. * @param object the object to get the class name from
  30417. * @param isType defines if the object is actually a type
  30418. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  30419. */
  30420. static GetClassName(object: any, isType?: boolean): string;
  30421. /**
  30422. * Gets the first element of an array satisfying a given predicate
  30423. * @param array defines the array to browse
  30424. * @param predicate defines the predicate to use
  30425. * @returns null if not found or the element
  30426. */
  30427. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  30428. /**
  30429. * This method will return the name of the full name of the class, including its owning module (if any).
  30430. * 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).
  30431. * @param object the object to get the class name from
  30432. * @param isType defines if the object is actually a type
  30433. * @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.
  30434. * @ignorenaming
  30435. */
  30436. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  30437. /**
  30438. * Returns a promise that resolves after the given amount of time.
  30439. * @param delay Number of milliseconds to delay
  30440. * @returns Promise that resolves after the given amount of time
  30441. */
  30442. static DelayAsync(delay: number): Promise<void>;
  30443. /**
  30444. * Gets the current gradient from an array of IValueGradient
  30445. * @param ratio defines the current ratio to get
  30446. * @param gradients defines the array of IValueGradient
  30447. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  30448. */
  30449. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  30450. }
  30451. /**
  30452. * This class is used to track a performance counter which is number based.
  30453. * The user has access to many properties which give statistics of different nature.
  30454. *
  30455. * The implementer can track two kinds of Performance Counter: time and count.
  30456. * 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.
  30457. * 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.
  30458. */
  30459. export class PerfCounter {
  30460. /**
  30461. * Gets or sets a global boolean to turn on and off all the counters
  30462. */
  30463. static Enabled: boolean;
  30464. /**
  30465. * Returns the smallest value ever
  30466. */
  30467. readonly min: number;
  30468. /**
  30469. * Returns the biggest value ever
  30470. */
  30471. readonly max: number;
  30472. /**
  30473. * Returns the average value since the performance counter is running
  30474. */
  30475. readonly average: number;
  30476. /**
  30477. * Returns the average value of the last second the counter was monitored
  30478. */
  30479. readonly lastSecAverage: number;
  30480. /**
  30481. * Returns the current value
  30482. */
  30483. readonly current: number;
  30484. /**
  30485. * Gets the accumulated total
  30486. */
  30487. readonly total: number;
  30488. /**
  30489. * Gets the total value count
  30490. */
  30491. readonly count: number;
  30492. /**
  30493. * Creates a new counter
  30494. */
  30495. constructor();
  30496. /**
  30497. * Call this method to start monitoring a new frame.
  30498. * 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.
  30499. */
  30500. fetchNewFrame(): void;
  30501. /**
  30502. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30503. * @param newCount the count value to add to the monitored count
  30504. * @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.
  30505. */
  30506. addCount(newCount: number, fetchResult: boolean): void;
  30507. /**
  30508. * Start monitoring this performance counter
  30509. */
  30510. beginMonitoring(): void;
  30511. /**
  30512. * Compute the time lapsed since the previous beginMonitoring() call.
  30513. * @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
  30514. */
  30515. endMonitoring(newFrame?: boolean): void;
  30516. private _fetchResult;
  30517. private _startMonitoringTime;
  30518. private _min;
  30519. private _max;
  30520. private _average;
  30521. private _current;
  30522. private _totalValueCount;
  30523. private _totalAccumulated;
  30524. private _lastSecAverage;
  30525. private _lastSecAccumulated;
  30526. private _lastSecTime;
  30527. private _lastSecValueCount;
  30528. }
  30529. /**
  30530. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30531. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30532. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30533. * @param name The name of the class, case should be preserved
  30534. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30535. */
  30536. export function className(name: string, module?: string): (target: Object) => void;
  30537. /**
  30538. * An implementation of a loop for asynchronous functions.
  30539. */
  30540. export class AsyncLoop {
  30541. /**
  30542. * Defines the number of iterations for the loop
  30543. */
  30544. iterations: number;
  30545. /**
  30546. * Defines the current index of the loop.
  30547. */
  30548. index: number;
  30549. private _done;
  30550. private _fn;
  30551. private _successCallback;
  30552. /**
  30553. * Constructor.
  30554. * @param iterations the number of iterations.
  30555. * @param func the function to run each iteration
  30556. * @param successCallback the callback that will be called upon succesful execution
  30557. * @param offset starting offset.
  30558. */
  30559. constructor(
  30560. /**
  30561. * Defines the number of iterations for the loop
  30562. */
  30563. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  30564. /**
  30565. * Execute the next iteration. Must be called after the last iteration was finished.
  30566. */
  30567. executeNext(): void;
  30568. /**
  30569. * Break the loop and run the success callback.
  30570. */
  30571. breakLoop(): void;
  30572. /**
  30573. * Create and run an async loop.
  30574. * @param iterations the number of iterations.
  30575. * @param fn the function to run each iteration
  30576. * @param successCallback the callback that will be called upon succesful execution
  30577. * @param offset starting offset.
  30578. * @returns the created async loop object
  30579. */
  30580. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  30581. /**
  30582. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30583. * @param iterations total number of iterations
  30584. * @param syncedIterations number of synchronous iterations in each async iteration.
  30585. * @param fn the function to call each iteration.
  30586. * @param callback a success call back that will be called when iterating stops.
  30587. * @param breakFunction a break condition (optional)
  30588. * @param timeout timeout settings for the setTimeout function. default - 0.
  30589. * @returns the created async loop object
  30590. */
  30591. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  30592. }
  30593. }
  30594. declare module BABYLON {
  30595. /** @hidden */
  30596. export interface ICollisionCoordinator {
  30597. createCollider(): Collider;
  30598. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30599. init(scene: Scene): void;
  30600. }
  30601. /** @hidden */
  30602. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  30603. private _scene;
  30604. private _scaledPosition;
  30605. private _scaledVelocity;
  30606. private _finalPosition;
  30607. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30608. createCollider(): Collider;
  30609. init(scene: Scene): void;
  30610. private _collideWithWorld;
  30611. }
  30612. }
  30613. declare module BABYLON {
  30614. /**
  30615. * This class defines the direct association between an animation and a target
  30616. */
  30617. export class TargetedAnimation {
  30618. /**
  30619. * Animation to perform
  30620. */
  30621. animation: Animation;
  30622. /**
  30623. * Target to animate
  30624. */
  30625. target: any;
  30626. }
  30627. /**
  30628. * Use this class to create coordinated animations on multiple targets
  30629. */
  30630. export class AnimationGroup implements IDisposable {
  30631. /** The name of the animation group */
  30632. name: string;
  30633. private _scene;
  30634. private _targetedAnimations;
  30635. private _animatables;
  30636. private _from;
  30637. private _to;
  30638. private _isStarted;
  30639. private _isPaused;
  30640. private _speedRatio;
  30641. /**
  30642. * Gets or sets the unique id of the node
  30643. */
  30644. uniqueId: number;
  30645. /**
  30646. * This observable will notify when one animation have ended
  30647. */
  30648. onAnimationEndObservable: Observable<TargetedAnimation>;
  30649. /**
  30650. * Observer raised when one animation loops
  30651. */
  30652. onAnimationLoopObservable: Observable<TargetedAnimation>;
  30653. /**
  30654. * This observable will notify when all animations have ended.
  30655. */
  30656. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  30657. /**
  30658. * This observable will notify when all animations have paused.
  30659. */
  30660. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  30661. /**
  30662. * This observable will notify when all animations are playing.
  30663. */
  30664. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  30665. /**
  30666. * Gets the first frame
  30667. */
  30668. readonly from: number;
  30669. /**
  30670. * Gets the last frame
  30671. */
  30672. readonly to: number;
  30673. /**
  30674. * Define if the animations are started
  30675. */
  30676. readonly isStarted: boolean;
  30677. /**
  30678. * Gets a value indicating that the current group is playing
  30679. */
  30680. readonly isPlaying: boolean;
  30681. /**
  30682. * Gets or sets the speed ratio to use for all animations
  30683. */
  30684. /**
  30685. * Gets or sets the speed ratio to use for all animations
  30686. */
  30687. speedRatio: number;
  30688. /**
  30689. * Gets the targeted animations for this animation group
  30690. */
  30691. readonly targetedAnimations: Array<TargetedAnimation>;
  30692. /**
  30693. * returning the list of animatables controlled by this animation group.
  30694. */
  30695. readonly animatables: Array<Animatable>;
  30696. /**
  30697. * Instantiates a new Animation Group.
  30698. * This helps managing several animations at once.
  30699. * @see http://doc.babylonjs.com/how_to/group
  30700. * @param name Defines the name of the group
  30701. * @param scene Defines the scene the group belongs to
  30702. */
  30703. constructor(
  30704. /** The name of the animation group */
  30705. name: string, scene?: Nullable<Scene>);
  30706. /**
  30707. * Add an animation (with its target) in the group
  30708. * @param animation defines the animation we want to add
  30709. * @param target defines the target of the animation
  30710. * @returns the TargetedAnimation object
  30711. */
  30712. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  30713. /**
  30714. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  30715. * It can add constant keys at begin or end
  30716. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  30717. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  30718. * @returns the animation group
  30719. */
  30720. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  30721. /**
  30722. * Start all animations on given targets
  30723. * @param loop defines if animations must loop
  30724. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  30725. * @param from defines the from key (optional)
  30726. * @param to defines the to key (optional)
  30727. * @returns the current animation group
  30728. */
  30729. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  30730. /**
  30731. * Pause all animations
  30732. * @returns the animation group
  30733. */
  30734. pause(): AnimationGroup;
  30735. /**
  30736. * Play all animations to initial state
  30737. * This function will start() the animations if they were not started or will restart() them if they were paused
  30738. * @param loop defines if animations must loop
  30739. * @returns the animation group
  30740. */
  30741. play(loop?: boolean): AnimationGroup;
  30742. /**
  30743. * Reset all animations to initial state
  30744. * @returns the animation group
  30745. */
  30746. reset(): AnimationGroup;
  30747. /**
  30748. * Restart animations from key 0
  30749. * @returns the animation group
  30750. */
  30751. restart(): AnimationGroup;
  30752. /**
  30753. * Stop all animations
  30754. * @returns the animation group
  30755. */
  30756. stop(): AnimationGroup;
  30757. /**
  30758. * Set animation weight for all animatables
  30759. * @param weight defines the weight to use
  30760. * @return the animationGroup
  30761. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  30762. */
  30763. setWeightForAllAnimatables(weight: number): AnimationGroup;
  30764. /**
  30765. * Synchronize and normalize all animatables with a source animatable
  30766. * @param root defines the root animatable to synchronize with
  30767. * @return the animationGroup
  30768. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  30769. */
  30770. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  30771. /**
  30772. * Goes to a specific frame in this animation group
  30773. * @param frame the frame number to go to
  30774. * @return the animationGroup
  30775. */
  30776. goToFrame(frame: number): AnimationGroup;
  30777. /**
  30778. * Dispose all associated resources
  30779. */
  30780. dispose(): void;
  30781. private _checkAnimationGroupEnded;
  30782. /**
  30783. * Returns a new AnimationGroup object parsed from the source provided.
  30784. * @param parsedAnimationGroup defines the source
  30785. * @param scene defines the scene that will receive the animationGroup
  30786. * @returns a new AnimationGroup
  30787. */
  30788. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  30789. /**
  30790. * Returns the string "AnimationGroup"
  30791. * @returns "AnimationGroup"
  30792. */
  30793. getClassName(): string;
  30794. /**
  30795. * Creates a detailled string about the object
  30796. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  30797. * @returns a string representing the object
  30798. */
  30799. toString(fullDetails?: boolean): string;
  30800. }
  30801. }
  30802. declare module BABYLON {
  30803. /**
  30804. * Define an interface for all classes that will hold resources
  30805. */
  30806. export interface IDisposable {
  30807. /**
  30808. * Releases all held resources
  30809. */
  30810. dispose(): void;
  30811. }
  30812. /** Interface defining initialization parameters for Scene class */
  30813. export interface SceneOptions {
  30814. /**
  30815. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  30816. * It will improve performance when the number of geometries becomes important.
  30817. */
  30818. useGeometryUniqueIdsMap?: boolean;
  30819. /**
  30820. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  30821. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  30822. */
  30823. useMaterialMeshMap?: boolean;
  30824. /**
  30825. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  30826. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  30827. */
  30828. useClonedMeshhMap?: boolean;
  30829. }
  30830. /**
  30831. * Represents a scene to be rendered by the engine.
  30832. * @see http://doc.babylonjs.com/features/scene
  30833. */
  30834. export class Scene extends AbstractScene implements IAnimatable {
  30835. private static _uniqueIdCounter;
  30836. /** The fog is deactivated */
  30837. static readonly FOGMODE_NONE: number;
  30838. /** The fog density is following an exponential function */
  30839. static readonly FOGMODE_EXP: number;
  30840. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  30841. static readonly FOGMODE_EXP2: number;
  30842. /** The fog density is following a linear function. */
  30843. static readonly FOGMODE_LINEAR: number;
  30844. /**
  30845. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  30846. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30847. */
  30848. static MinDeltaTime: number;
  30849. /**
  30850. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  30851. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30852. */
  30853. static MaxDeltaTime: number;
  30854. /**
  30855. * Factory used to create the default material.
  30856. * @param name The name of the material to create
  30857. * @param scene The scene to create the material for
  30858. * @returns The default material
  30859. */
  30860. static DefaultMaterialFactory(scene: Scene): Material;
  30861. /**
  30862. * Factory used to create the a collision coordinator.
  30863. * @returns The collision coordinator
  30864. */
  30865. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  30866. /** @hidden */
  30867. readonly _isScene: boolean;
  30868. /**
  30869. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  30870. */
  30871. autoClear: boolean;
  30872. /**
  30873. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  30874. */
  30875. autoClearDepthAndStencil: boolean;
  30876. /**
  30877. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  30878. */
  30879. clearColor: Color4;
  30880. /**
  30881. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  30882. */
  30883. ambientColor: Color3;
  30884. /** @hidden */
  30885. _environmentBRDFTexture: BaseTexture;
  30886. /** @hidden */
  30887. protected _environmentTexture: Nullable<BaseTexture>;
  30888. /**
  30889. * Texture used in all pbr material as the reflection texture.
  30890. * As in the majority of the scene they are the same (exception for multi room and so on),
  30891. * this is easier to reference from here than from all the materials.
  30892. */
  30893. /**
  30894. * Texture used in all pbr material as the reflection texture.
  30895. * As in the majority of the scene they are the same (exception for multi room and so on),
  30896. * this is easier to set here than in all the materials.
  30897. */
  30898. environmentTexture: Nullable<BaseTexture>;
  30899. /** @hidden */
  30900. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30901. /**
  30902. * Default image processing configuration used either in the rendering
  30903. * Forward main pass or through the imageProcessingPostProcess if present.
  30904. * As in the majority of the scene they are the same (exception for multi camera),
  30905. * this is easier to reference from here than from all the materials and post process.
  30906. *
  30907. * No setter as we it is a shared configuration, you can set the values instead.
  30908. */
  30909. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  30910. private _forceWireframe;
  30911. /**
  30912. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  30913. */
  30914. forceWireframe: boolean;
  30915. private _forcePointsCloud;
  30916. /**
  30917. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  30918. */
  30919. forcePointsCloud: boolean;
  30920. /**
  30921. * Gets or sets the active clipplane 1
  30922. */
  30923. clipPlane: Nullable<Plane>;
  30924. /**
  30925. * Gets or sets the active clipplane 2
  30926. */
  30927. clipPlane2: Nullable<Plane>;
  30928. /**
  30929. * Gets or sets the active clipplane 3
  30930. */
  30931. clipPlane3: Nullable<Plane>;
  30932. /**
  30933. * Gets or sets the active clipplane 4
  30934. */
  30935. clipPlane4: Nullable<Plane>;
  30936. /**
  30937. * Gets or sets a boolean indicating if animations are enabled
  30938. */
  30939. animationsEnabled: boolean;
  30940. private _animationPropertiesOverride;
  30941. /**
  30942. * Gets or sets the animation properties override
  30943. */
  30944. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  30945. /**
  30946. * Gets or sets a boolean indicating if a constant deltatime has to be used
  30947. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  30948. */
  30949. useConstantAnimationDeltaTime: boolean;
  30950. /**
  30951. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  30952. * Please note that it requires to run a ray cast through the scene on every frame
  30953. */
  30954. constantlyUpdateMeshUnderPointer: boolean;
  30955. /**
  30956. * Defines the HTML cursor to use when hovering over interactive elements
  30957. */
  30958. hoverCursor: string;
  30959. /**
  30960. * Defines the HTML default cursor to use (empty by default)
  30961. */
  30962. defaultCursor: string;
  30963. /**
  30964. * This is used to call preventDefault() on pointer down
  30965. * in order to block unwanted artifacts like system double clicks
  30966. */
  30967. preventDefaultOnPointerDown: boolean;
  30968. /**
  30969. * This is used to call preventDefault() on pointer up
  30970. * in order to block unwanted artifacts like system double clicks
  30971. */
  30972. preventDefaultOnPointerUp: boolean;
  30973. /**
  30974. * Gets or sets user defined metadata
  30975. */
  30976. metadata: any;
  30977. /**
  30978. * For internal use only. Please do not use.
  30979. */
  30980. reservedDataStore: any;
  30981. /**
  30982. * Gets the name of the plugin used to load this scene (null by default)
  30983. */
  30984. loadingPluginName: string;
  30985. /**
  30986. * Use this array to add regular expressions used to disable offline support for specific urls
  30987. */
  30988. disableOfflineSupportExceptionRules: RegExp[];
  30989. /**
  30990. * An event triggered when the scene is disposed.
  30991. */
  30992. onDisposeObservable: Observable<Scene>;
  30993. private _onDisposeObserver;
  30994. /** Sets a function to be executed when this scene is disposed. */
  30995. onDispose: () => void;
  30996. /**
  30997. * An event triggered before rendering the scene (right after animations and physics)
  30998. */
  30999. onBeforeRenderObservable: Observable<Scene>;
  31000. private _onBeforeRenderObserver;
  31001. /** Sets a function to be executed before rendering this scene */
  31002. beforeRender: Nullable<() => void>;
  31003. /**
  31004. * An event triggered after rendering the scene
  31005. */
  31006. onAfterRenderObservable: Observable<Scene>;
  31007. private _onAfterRenderObserver;
  31008. /** Sets a function to be executed after rendering this scene */
  31009. afterRender: Nullable<() => void>;
  31010. /**
  31011. * An event triggered before animating the scene
  31012. */
  31013. onBeforeAnimationsObservable: Observable<Scene>;
  31014. /**
  31015. * An event triggered after animations processing
  31016. */
  31017. onAfterAnimationsObservable: Observable<Scene>;
  31018. /**
  31019. * An event triggered before draw calls are ready to be sent
  31020. */
  31021. onBeforeDrawPhaseObservable: Observable<Scene>;
  31022. /**
  31023. * An event triggered after draw calls have been sent
  31024. */
  31025. onAfterDrawPhaseObservable: Observable<Scene>;
  31026. /**
  31027. * An event triggered when the scene is ready
  31028. */
  31029. onReadyObservable: Observable<Scene>;
  31030. /**
  31031. * An event triggered before rendering a camera
  31032. */
  31033. onBeforeCameraRenderObservable: Observable<Camera>;
  31034. private _onBeforeCameraRenderObserver;
  31035. /** Sets a function to be executed before rendering a camera*/
  31036. beforeCameraRender: () => void;
  31037. /**
  31038. * An event triggered after rendering a camera
  31039. */
  31040. onAfterCameraRenderObservable: Observable<Camera>;
  31041. private _onAfterCameraRenderObserver;
  31042. /** Sets a function to be executed after rendering a camera*/
  31043. afterCameraRender: () => void;
  31044. /**
  31045. * An event triggered when active meshes evaluation is about to start
  31046. */
  31047. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31048. /**
  31049. * An event triggered when active meshes evaluation is done
  31050. */
  31051. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31052. /**
  31053. * An event triggered when particles rendering is about to start
  31054. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31055. */
  31056. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31057. /**
  31058. * An event triggered when particles rendering is done
  31059. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31060. */
  31061. onAfterParticlesRenderingObservable: Observable<Scene>;
  31062. /**
  31063. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31064. */
  31065. onDataLoadedObservable: Observable<Scene>;
  31066. /**
  31067. * An event triggered when a camera is created
  31068. */
  31069. onNewCameraAddedObservable: Observable<Camera>;
  31070. /**
  31071. * An event triggered when a camera is removed
  31072. */
  31073. onCameraRemovedObservable: Observable<Camera>;
  31074. /**
  31075. * An event triggered when a light is created
  31076. */
  31077. onNewLightAddedObservable: Observable<Light>;
  31078. /**
  31079. * An event triggered when a light is removed
  31080. */
  31081. onLightRemovedObservable: Observable<Light>;
  31082. /**
  31083. * An event triggered when a geometry is created
  31084. */
  31085. onNewGeometryAddedObservable: Observable<Geometry>;
  31086. /**
  31087. * An event triggered when a geometry is removed
  31088. */
  31089. onGeometryRemovedObservable: Observable<Geometry>;
  31090. /**
  31091. * An event triggered when a transform node is created
  31092. */
  31093. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31094. /**
  31095. * An event triggered when a transform node is removed
  31096. */
  31097. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31098. /**
  31099. * An event triggered when a mesh is created
  31100. */
  31101. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31102. /**
  31103. * An event triggered when a mesh is removed
  31104. */
  31105. onMeshRemovedObservable: Observable<AbstractMesh>;
  31106. /**
  31107. * An event triggered when a material is created
  31108. */
  31109. onNewMaterialAddedObservable: Observable<Material>;
  31110. /**
  31111. * An event triggered when a material is removed
  31112. */
  31113. onMaterialRemovedObservable: Observable<Material>;
  31114. /**
  31115. * An event triggered when a texture is created
  31116. */
  31117. onNewTextureAddedObservable: Observable<BaseTexture>;
  31118. /**
  31119. * An event triggered when a texture is removed
  31120. */
  31121. onTextureRemovedObservable: Observable<BaseTexture>;
  31122. /**
  31123. * An event triggered when render targets are about to be rendered
  31124. * Can happen multiple times per frame.
  31125. */
  31126. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31127. /**
  31128. * An event triggered when render targets were rendered.
  31129. * Can happen multiple times per frame.
  31130. */
  31131. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31132. /**
  31133. * An event triggered before calculating deterministic simulation step
  31134. */
  31135. onBeforeStepObservable: Observable<Scene>;
  31136. /**
  31137. * An event triggered after calculating deterministic simulation step
  31138. */
  31139. onAfterStepObservable: Observable<Scene>;
  31140. /**
  31141. * An event triggered when the activeCamera property is updated
  31142. */
  31143. onActiveCameraChanged: Observable<Scene>;
  31144. /**
  31145. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31146. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31147. * 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)
  31148. */
  31149. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31150. /**
  31151. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31152. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31153. * 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)
  31154. */
  31155. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31156. /**
  31157. * This Observable will when a mesh has been imported into the scene.
  31158. */
  31159. onMeshImportedObservable: Observable<AbstractMesh>;
  31160. /** @hidden */
  31161. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31162. /**
  31163. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31164. */
  31165. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31166. /**
  31167. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31168. */
  31169. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31170. /**
  31171. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31172. */
  31173. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31174. private _onPointerMove;
  31175. private _onPointerDown;
  31176. private _onPointerUp;
  31177. /** Callback called when a pointer move is detected */
  31178. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31179. /** Callback called when a pointer down is detected */
  31180. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31181. /** Callback called when a pointer up is detected */
  31182. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31183. /** Callback called when a pointer pick is detected */
  31184. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  31185. /**
  31186. * 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).
  31187. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  31188. */
  31189. onPrePointerObservable: Observable<PointerInfoPre>;
  31190. /**
  31191. * Observable event triggered each time an input event is received from the rendering canvas
  31192. */
  31193. onPointerObservable: Observable<PointerInfo>;
  31194. /**
  31195. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  31196. */
  31197. readonly unTranslatedPointer: Vector2;
  31198. /** The distance in pixel that you have to move to prevent some events */
  31199. static DragMovementThreshold: number;
  31200. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31201. static LongPressDelay: number;
  31202. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31203. static DoubleClickDelay: number;
  31204. /** If you need to check double click without raising a single click at first click, enable this flag */
  31205. static ExclusiveDoubleClickMode: boolean;
  31206. private _initClickEvent;
  31207. private _initActionManager;
  31208. private _delayedSimpleClick;
  31209. private _delayedSimpleClickTimeout;
  31210. private _previousDelayedSimpleClickTimeout;
  31211. private _meshPickProceed;
  31212. private _previousButtonPressed;
  31213. private _currentPickResult;
  31214. private _previousPickResult;
  31215. private _totalPointersPressed;
  31216. private _doubleClickOccured;
  31217. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31218. cameraToUseForPointers: Nullable<Camera>;
  31219. private _pointerX;
  31220. private _pointerY;
  31221. private _unTranslatedPointerX;
  31222. private _unTranslatedPointerY;
  31223. private _startingPointerPosition;
  31224. private _previousStartingPointerPosition;
  31225. private _startingPointerTime;
  31226. private _previousStartingPointerTime;
  31227. private _pointerCaptures;
  31228. private _timeAccumulator;
  31229. private _currentStepId;
  31230. private _currentInternalStep;
  31231. /** @hidden */
  31232. _mirroredCameraPosition: Nullable<Vector3>;
  31233. /**
  31234. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  31235. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  31236. */
  31237. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  31238. /**
  31239. * Observable event triggered each time an keyboard event is received from the hosting window
  31240. */
  31241. onKeyboardObservable: Observable<KeyboardInfo>;
  31242. private _onKeyDown;
  31243. private _onKeyUp;
  31244. private _onCanvasFocusObserver;
  31245. private _onCanvasBlurObserver;
  31246. private _useRightHandedSystem;
  31247. /**
  31248. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  31249. */
  31250. useRightHandedSystem: boolean;
  31251. /**
  31252. * Sets the step Id used by deterministic lock step
  31253. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31254. * @param newStepId defines the step Id
  31255. */
  31256. setStepId(newStepId: number): void;
  31257. /**
  31258. * Gets the step Id used by deterministic lock step
  31259. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31260. * @returns the step Id
  31261. */
  31262. getStepId(): number;
  31263. /**
  31264. * Gets the internal step used by deterministic lock step
  31265. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31266. * @returns the internal step
  31267. */
  31268. getInternalStep(): number;
  31269. private _fogEnabled;
  31270. /**
  31271. * Gets or sets a boolean indicating if fog is enabled on this scene
  31272. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31273. * (Default is true)
  31274. */
  31275. fogEnabled: boolean;
  31276. private _fogMode;
  31277. /**
  31278. * Gets or sets the fog mode to use
  31279. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31280. * | mode | value |
  31281. * | --- | --- |
  31282. * | FOGMODE_NONE | 0 |
  31283. * | FOGMODE_EXP | 1 |
  31284. * | FOGMODE_EXP2 | 2 |
  31285. * | FOGMODE_LINEAR | 3 |
  31286. */
  31287. fogMode: number;
  31288. /**
  31289. * Gets or sets the fog color to use
  31290. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31291. * (Default is Color3(0.2, 0.2, 0.3))
  31292. */
  31293. fogColor: Color3;
  31294. /**
  31295. * Gets or sets the fog density to use
  31296. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31297. * (Default is 0.1)
  31298. */
  31299. fogDensity: number;
  31300. /**
  31301. * Gets or sets the fog start distance to use
  31302. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31303. * (Default is 0)
  31304. */
  31305. fogStart: number;
  31306. /**
  31307. * Gets or sets the fog end distance to use
  31308. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31309. * (Default is 1000)
  31310. */
  31311. fogEnd: number;
  31312. private _shadowsEnabled;
  31313. /**
  31314. * Gets or sets a boolean indicating if shadows are enabled on this scene
  31315. */
  31316. shadowsEnabled: boolean;
  31317. private _lightsEnabled;
  31318. /**
  31319. * Gets or sets a boolean indicating if lights are enabled on this scene
  31320. */
  31321. lightsEnabled: boolean;
  31322. /** All of the active cameras added to this scene. */
  31323. activeCameras: Camera[];
  31324. private _activeCamera;
  31325. /** Gets or sets the current active camera */
  31326. activeCamera: Nullable<Camera>;
  31327. private _defaultMaterial;
  31328. /** The default material used on meshes when no material is affected */
  31329. /** The default material used on meshes when no material is affected */
  31330. defaultMaterial: Material;
  31331. private _texturesEnabled;
  31332. /**
  31333. * Gets or sets a boolean indicating if textures are enabled on this scene
  31334. */
  31335. texturesEnabled: boolean;
  31336. /**
  31337. * Gets or sets a boolean indicating if particles are enabled on this scene
  31338. */
  31339. particlesEnabled: boolean;
  31340. /**
  31341. * Gets or sets a boolean indicating if sprites are enabled on this scene
  31342. */
  31343. spritesEnabled: boolean;
  31344. private _skeletonsEnabled;
  31345. /**
  31346. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  31347. */
  31348. skeletonsEnabled: boolean;
  31349. /**
  31350. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  31351. */
  31352. lensFlaresEnabled: boolean;
  31353. /**
  31354. * Gets or sets a boolean indicating if collisions are enabled on this scene
  31355. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31356. */
  31357. collisionsEnabled: boolean;
  31358. private _collisionCoordinator;
  31359. /** @hidden */
  31360. readonly collisionCoordinator: ICollisionCoordinator;
  31361. /**
  31362. * Defines the gravity applied to this scene (used only for collisions)
  31363. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31364. */
  31365. gravity: Vector3;
  31366. /**
  31367. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  31368. */
  31369. postProcessesEnabled: boolean;
  31370. /**
  31371. * The list of postprocesses added to the scene
  31372. */
  31373. postProcesses: PostProcess[];
  31374. /**
  31375. * Gets the current postprocess manager
  31376. */
  31377. postProcessManager: PostProcessManager;
  31378. /**
  31379. * Gets or sets a boolean indicating if render targets are enabled on this scene
  31380. */
  31381. renderTargetsEnabled: boolean;
  31382. /**
  31383. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  31384. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  31385. */
  31386. dumpNextRenderTargets: boolean;
  31387. /**
  31388. * The list of user defined render targets added to the scene
  31389. */
  31390. customRenderTargets: RenderTargetTexture[];
  31391. /**
  31392. * Defines if texture loading must be delayed
  31393. * If true, textures will only be loaded when they need to be rendered
  31394. */
  31395. useDelayedTextureLoading: boolean;
  31396. /**
  31397. * Gets the list of meshes imported to the scene through SceneLoader
  31398. */
  31399. importedMeshesFiles: String[];
  31400. /**
  31401. * Gets or sets a boolean indicating if probes are enabled on this scene
  31402. */
  31403. probesEnabled: boolean;
  31404. /**
  31405. * Gets or sets the current offline provider to use to store scene data
  31406. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  31407. */
  31408. offlineProvider: IOfflineProvider;
  31409. /**
  31410. * Gets or sets the action manager associated with the scene
  31411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31412. */
  31413. actionManager: AbstractActionManager;
  31414. private _meshesForIntersections;
  31415. /**
  31416. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  31417. */
  31418. proceduralTexturesEnabled: boolean;
  31419. private _engine;
  31420. private _totalVertices;
  31421. /** @hidden */
  31422. _activeIndices: PerfCounter;
  31423. /** @hidden */
  31424. _activeParticles: PerfCounter;
  31425. /** @hidden */
  31426. _activeBones: PerfCounter;
  31427. private _animationRatio;
  31428. /** @hidden */
  31429. _animationTimeLast: number;
  31430. /** @hidden */
  31431. _animationTime: number;
  31432. /**
  31433. * Gets or sets a general scale for animation speed
  31434. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  31435. */
  31436. animationTimeScale: number;
  31437. /** @hidden */
  31438. _cachedMaterial: Nullable<Material>;
  31439. /** @hidden */
  31440. _cachedEffect: Nullable<Effect>;
  31441. /** @hidden */
  31442. _cachedVisibility: Nullable<number>;
  31443. private _renderId;
  31444. private _frameId;
  31445. private _executeWhenReadyTimeoutId;
  31446. private _intermediateRendering;
  31447. private _viewUpdateFlag;
  31448. private _projectionUpdateFlag;
  31449. private _alternateViewUpdateFlag;
  31450. private _alternateProjectionUpdateFlag;
  31451. /** @hidden */
  31452. _toBeDisposed: Nullable<IDisposable>[];
  31453. private _activeRequests;
  31454. /** @hidden */
  31455. _pendingData: any[];
  31456. private _isDisposed;
  31457. /**
  31458. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  31459. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  31460. */
  31461. dispatchAllSubMeshesOfActiveMeshes: boolean;
  31462. private _activeMeshes;
  31463. private _processedMaterials;
  31464. private _renderTargets;
  31465. /** @hidden */
  31466. _activeParticleSystems: SmartArray<IParticleSystem>;
  31467. private _activeSkeletons;
  31468. private _softwareSkinnedMeshes;
  31469. private _renderingManager;
  31470. /** @hidden */
  31471. _activeAnimatables: Animatable[];
  31472. private _transformMatrix;
  31473. private _sceneUbo;
  31474. private _alternateSceneUbo;
  31475. private _pickWithRayInverseMatrix;
  31476. private _viewMatrix;
  31477. private _projectionMatrix;
  31478. private _alternateViewMatrix;
  31479. private _alternateProjectionMatrix;
  31480. private _alternateTransformMatrix;
  31481. private _useAlternateCameraConfiguration;
  31482. private _alternateRendering;
  31483. private _wheelEventName;
  31484. /** @hidden */
  31485. _forcedViewPosition: Nullable<Vector3>;
  31486. /** @hidden */
  31487. readonly _isAlternateRenderingEnabled: boolean;
  31488. private _frustumPlanes;
  31489. /**
  31490. * Gets the list of frustum planes (built from the active camera)
  31491. */
  31492. readonly frustumPlanes: Plane[];
  31493. /**
  31494. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  31495. * This is useful if there are more lights that the maximum simulteanous authorized
  31496. */
  31497. requireLightSorting: boolean;
  31498. /** @hidden */
  31499. readonly useMaterialMeshMap: boolean;
  31500. /** @hidden */
  31501. readonly useClonedMeshhMap: boolean;
  31502. private _pointerOverMesh;
  31503. private _pickedDownMesh;
  31504. private _pickedUpMesh;
  31505. private _externalData;
  31506. private _uid;
  31507. /**
  31508. * @hidden
  31509. * Backing store of defined scene components.
  31510. */
  31511. _components: ISceneComponent[];
  31512. /**
  31513. * @hidden
  31514. * Backing store of defined scene components.
  31515. */
  31516. _serializableComponents: ISceneSerializableComponent[];
  31517. /**
  31518. * List of components to register on the next registration step.
  31519. */
  31520. private _transientComponents;
  31521. /**
  31522. * Registers the transient components if needed.
  31523. */
  31524. private _registerTransientComponents;
  31525. /**
  31526. * @hidden
  31527. * Add a component to the scene.
  31528. * Note that the ccomponent could be registered on th next frame if this is called after
  31529. * the register component stage.
  31530. * @param component Defines the component to add to the scene
  31531. */
  31532. _addComponent(component: ISceneComponent): void;
  31533. /**
  31534. * @hidden
  31535. * Gets a component from the scene.
  31536. * @param name defines the name of the component to retrieve
  31537. * @returns the component or null if not present
  31538. */
  31539. _getComponent(name: string): Nullable<ISceneComponent>;
  31540. /**
  31541. * @hidden
  31542. * Defines the actions happening before camera updates.
  31543. */
  31544. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  31545. /**
  31546. * @hidden
  31547. * Defines the actions happening before clear the canvas.
  31548. */
  31549. _beforeClearStage: Stage<SimpleStageAction>;
  31550. /**
  31551. * @hidden
  31552. * Defines the actions when collecting render targets for the frame.
  31553. */
  31554. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31555. /**
  31556. * @hidden
  31557. * Defines the actions happening for one camera in the frame.
  31558. */
  31559. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31560. /**
  31561. * @hidden
  31562. * Defines the actions happening during the per mesh ready checks.
  31563. */
  31564. _isReadyForMeshStage: Stage<MeshStageAction>;
  31565. /**
  31566. * @hidden
  31567. * Defines the actions happening before evaluate active mesh checks.
  31568. */
  31569. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  31570. /**
  31571. * @hidden
  31572. * Defines the actions happening during the evaluate sub mesh checks.
  31573. */
  31574. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  31575. /**
  31576. * @hidden
  31577. * Defines the actions happening during the active mesh stage.
  31578. */
  31579. _activeMeshStage: Stage<ActiveMeshStageAction>;
  31580. /**
  31581. * @hidden
  31582. * Defines the actions happening during the per camera render target step.
  31583. */
  31584. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  31585. /**
  31586. * @hidden
  31587. * Defines the actions happening just before the active camera is drawing.
  31588. */
  31589. _beforeCameraDrawStage: Stage<CameraStageAction>;
  31590. /**
  31591. * @hidden
  31592. * Defines the actions happening just before a render target is drawing.
  31593. */
  31594. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31595. /**
  31596. * @hidden
  31597. * Defines the actions happening just before a rendering group is drawing.
  31598. */
  31599. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31600. /**
  31601. * @hidden
  31602. * Defines the actions happening just before a mesh is drawing.
  31603. */
  31604. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31605. /**
  31606. * @hidden
  31607. * Defines the actions happening just after a mesh has been drawn.
  31608. */
  31609. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31610. /**
  31611. * @hidden
  31612. * Defines the actions happening just after a rendering group has been drawn.
  31613. */
  31614. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31615. /**
  31616. * @hidden
  31617. * Defines the actions happening just after the active camera has been drawn.
  31618. */
  31619. _afterCameraDrawStage: Stage<CameraStageAction>;
  31620. /**
  31621. * @hidden
  31622. * Defines the actions happening just after a render target has been drawn.
  31623. */
  31624. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31625. /**
  31626. * @hidden
  31627. * Defines the actions happening just after rendering all cameras and computing intersections.
  31628. */
  31629. _afterRenderStage: Stage<SimpleStageAction>;
  31630. /**
  31631. * @hidden
  31632. * Defines the actions happening when a pointer move event happens.
  31633. */
  31634. _pointerMoveStage: Stage<PointerMoveStageAction>;
  31635. /**
  31636. * @hidden
  31637. * Defines the actions happening when a pointer down event happens.
  31638. */
  31639. _pointerDownStage: Stage<PointerUpDownStageAction>;
  31640. /**
  31641. * @hidden
  31642. * Defines the actions happening when a pointer up event happens.
  31643. */
  31644. _pointerUpStage: Stage<PointerUpDownStageAction>;
  31645. /**
  31646. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  31647. */
  31648. private geometriesByUniqueId;
  31649. /**
  31650. * Creates a new Scene
  31651. * @param engine defines the engine to use to render this scene
  31652. * @param options defines the scene options
  31653. */
  31654. constructor(engine: Engine, options?: SceneOptions);
  31655. private _defaultMeshCandidates;
  31656. /**
  31657. * @hidden
  31658. */
  31659. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  31660. private _defaultSubMeshCandidates;
  31661. /**
  31662. * @hidden
  31663. */
  31664. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  31665. /**
  31666. * Sets the default candidate providers for the scene.
  31667. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  31668. * and getCollidingSubMeshCandidates to their default function
  31669. */
  31670. setDefaultCandidateProviders(): void;
  31671. /**
  31672. * Gets the mesh that is currently under the pointer
  31673. */
  31674. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31675. /**
  31676. * Gets or sets the current on-screen X position of the pointer
  31677. */
  31678. pointerX: number;
  31679. /**
  31680. * Gets or sets the current on-screen Y position of the pointer
  31681. */
  31682. pointerY: number;
  31683. /**
  31684. * Gets the cached material (ie. the latest rendered one)
  31685. * @returns the cached material
  31686. */
  31687. getCachedMaterial(): Nullable<Material>;
  31688. /**
  31689. * Gets the cached effect (ie. the latest rendered one)
  31690. * @returns the cached effect
  31691. */
  31692. getCachedEffect(): Nullable<Effect>;
  31693. /**
  31694. * Gets the cached visibility state (ie. the latest rendered one)
  31695. * @returns the cached visibility state
  31696. */
  31697. getCachedVisibility(): Nullable<number>;
  31698. /**
  31699. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  31700. * @param material defines the current material
  31701. * @param effect defines the current effect
  31702. * @param visibility defines the current visibility state
  31703. * @returns true if one parameter is not cached
  31704. */
  31705. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  31706. /**
  31707. * Gets the engine associated with the scene
  31708. * @returns an Engine
  31709. */
  31710. getEngine(): Engine;
  31711. /**
  31712. * Gets the total number of vertices rendered per frame
  31713. * @returns the total number of vertices rendered per frame
  31714. */
  31715. getTotalVertices(): number;
  31716. /**
  31717. * Gets the performance counter for total vertices
  31718. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31719. */
  31720. readonly totalVerticesPerfCounter: PerfCounter;
  31721. /**
  31722. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  31723. * @returns the total number of active indices rendered per frame
  31724. */
  31725. getActiveIndices(): number;
  31726. /**
  31727. * Gets the performance counter for active indices
  31728. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31729. */
  31730. readonly totalActiveIndicesPerfCounter: PerfCounter;
  31731. /**
  31732. * Gets the total number of active particles rendered per frame
  31733. * @returns the total number of active particles rendered per frame
  31734. */
  31735. getActiveParticles(): number;
  31736. /**
  31737. * Gets the performance counter for active particles
  31738. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31739. */
  31740. readonly activeParticlesPerfCounter: PerfCounter;
  31741. /**
  31742. * Gets the total number of active bones rendered per frame
  31743. * @returns the total number of active bones rendered per frame
  31744. */
  31745. getActiveBones(): number;
  31746. /**
  31747. * Gets the performance counter for active bones
  31748. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31749. */
  31750. readonly activeBonesPerfCounter: PerfCounter;
  31751. /**
  31752. * Gets the array of active meshes
  31753. * @returns an array of AbstractMesh
  31754. */
  31755. getActiveMeshes(): SmartArray<AbstractMesh>;
  31756. /**
  31757. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  31758. * @returns a number
  31759. */
  31760. getAnimationRatio(): number;
  31761. /**
  31762. * Gets an unique Id for the current render phase
  31763. * @returns a number
  31764. */
  31765. getRenderId(): number;
  31766. /**
  31767. * Gets an unique Id for the current frame
  31768. * @returns a number
  31769. */
  31770. getFrameId(): number;
  31771. /** Call this function if you want to manually increment the render Id*/
  31772. incrementRenderId(): void;
  31773. private _updatePointerPosition;
  31774. private _createUbo;
  31775. private _createAlternateUbo;
  31776. private _setRayOnPointerInfo;
  31777. /**
  31778. * Use this method to simulate a pointer move on a mesh
  31779. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31780. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31781. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31782. * @returns the current scene
  31783. */
  31784. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  31785. private _processPointerMove;
  31786. private _checkPrePointerObservable;
  31787. /**
  31788. * Use this method to simulate a pointer down on a mesh
  31789. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31790. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31791. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31792. * @returns the current scene
  31793. */
  31794. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  31795. private _processPointerDown;
  31796. /**
  31797. * Use this method to simulate a pointer up on a mesh
  31798. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31799. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31800. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31801. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31802. * @returns the current scene
  31803. */
  31804. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  31805. private _processPointerUp;
  31806. /**
  31807. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31808. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31809. * @returns true if the pointer was captured
  31810. */
  31811. isPointerCaptured(pointerId?: number): boolean;
  31812. /** @hidden */
  31813. _isPointerSwiping(): boolean;
  31814. /**
  31815. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31816. * @param attachUp defines if you want to attach events to pointerup
  31817. * @param attachDown defines if you want to attach events to pointerdown
  31818. * @param attachMove defines if you want to attach events to pointermove
  31819. */
  31820. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31821. /** Detaches all event handlers*/
  31822. detachControl(): void;
  31823. /**
  31824. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  31825. * Delay loaded resources are not taking in account
  31826. * @return true if all required resources are ready
  31827. */
  31828. isReady(): boolean;
  31829. /** Resets all cached information relative to material (including effect and visibility) */
  31830. resetCachedMaterial(): void;
  31831. /**
  31832. * Registers a function to be called before every frame render
  31833. * @param func defines the function to register
  31834. */
  31835. registerBeforeRender(func: () => void): void;
  31836. /**
  31837. * Unregisters a function called before every frame render
  31838. * @param func defines the function to unregister
  31839. */
  31840. unregisterBeforeRender(func: () => void): void;
  31841. /**
  31842. * Registers a function to be called after every frame render
  31843. * @param func defines the function to register
  31844. */
  31845. registerAfterRender(func: () => void): void;
  31846. /**
  31847. * Unregisters a function called after every frame render
  31848. * @param func defines the function to unregister
  31849. */
  31850. unregisterAfterRender(func: () => void): void;
  31851. private _executeOnceBeforeRender;
  31852. /**
  31853. * The provided function will run before render once and will be disposed afterwards.
  31854. * A timeout delay can be provided so that the function will be executed in N ms.
  31855. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  31856. * @param func The function to be executed.
  31857. * @param timeout optional delay in ms
  31858. */
  31859. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  31860. /** @hidden */
  31861. _addPendingData(data: any): void;
  31862. /** @hidden */
  31863. _removePendingData(data: any): void;
  31864. /**
  31865. * Returns the number of items waiting to be loaded
  31866. * @returns the number of items waiting to be loaded
  31867. */
  31868. getWaitingItemsCount(): number;
  31869. /**
  31870. * Returns a boolean indicating if the scene is still loading data
  31871. */
  31872. readonly isLoading: boolean;
  31873. /**
  31874. * Registers a function to be executed when the scene is ready
  31875. * @param {Function} func - the function to be executed
  31876. */
  31877. executeWhenReady(func: () => void): void;
  31878. /**
  31879. * Returns a promise that resolves when the scene is ready
  31880. * @returns A promise that resolves when the scene is ready
  31881. */
  31882. whenReadyAsync(): Promise<void>;
  31883. /** @hidden */
  31884. _checkIsReady(): void;
  31885. /**
  31886. * Gets all animatable attached to the scene
  31887. */
  31888. readonly animatables: Animatable[];
  31889. /**
  31890. * Resets the last animation time frame.
  31891. * Useful to override when animations start running when loading a scene for the first time.
  31892. */
  31893. resetLastAnimationTimeFrame(): void;
  31894. /** @hidden */
  31895. _switchToAlternateCameraConfiguration(active: boolean): void;
  31896. /**
  31897. * Gets the current view matrix
  31898. * @returns a Matrix
  31899. */
  31900. getViewMatrix(): Matrix;
  31901. /**
  31902. * Gets the current projection matrix
  31903. * @returns a Matrix
  31904. */
  31905. getProjectionMatrix(): Matrix;
  31906. /**
  31907. * Gets the current transform matrix
  31908. * @returns a Matrix made of View * Projection
  31909. */
  31910. getTransformMatrix(): Matrix;
  31911. /**
  31912. * Sets the current transform matrix
  31913. * @param view defines the View matrix to use
  31914. * @param projection defines the Projection matrix to use
  31915. */
  31916. setTransformMatrix(view: Matrix, projection: Matrix): void;
  31917. /** @hidden */
  31918. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  31919. /**
  31920. * Gets the uniform buffer used to store scene data
  31921. * @returns a UniformBuffer
  31922. */
  31923. getSceneUniformBuffer(): UniformBuffer;
  31924. /**
  31925. * Gets an unique (relatively to the current scene) Id
  31926. * @returns an unique number for the scene
  31927. */
  31928. getUniqueId(): number;
  31929. /**
  31930. * Add a mesh to the list of scene's meshes
  31931. * @param newMesh defines the mesh to add
  31932. * @param recursive if all child meshes should also be added to the scene
  31933. */
  31934. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  31935. /**
  31936. * Remove a mesh for the list of scene's meshes
  31937. * @param toRemove defines the mesh to remove
  31938. * @param recursive if all child meshes should also be removed from the scene
  31939. * @returns the index where the mesh was in the mesh list
  31940. */
  31941. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  31942. /**
  31943. * Add a transform node to the list of scene's transform nodes
  31944. * @param newTransformNode defines the transform node to add
  31945. */
  31946. addTransformNode(newTransformNode: TransformNode): void;
  31947. /**
  31948. * Remove a transform node for the list of scene's transform nodes
  31949. * @param toRemove defines the transform node to remove
  31950. * @returns the index where the transform node was in the transform node list
  31951. */
  31952. removeTransformNode(toRemove: TransformNode): number;
  31953. /**
  31954. * Remove a skeleton for the list of scene's skeletons
  31955. * @param toRemove defines the skeleton to remove
  31956. * @returns the index where the skeleton was in the skeleton list
  31957. */
  31958. removeSkeleton(toRemove: Skeleton): number;
  31959. /**
  31960. * Remove a morph target for the list of scene's morph targets
  31961. * @param toRemove defines the morph target to remove
  31962. * @returns the index where the morph target was in the morph target list
  31963. */
  31964. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  31965. /**
  31966. * Remove a light for the list of scene's lights
  31967. * @param toRemove defines the light to remove
  31968. * @returns the index where the light was in the light list
  31969. */
  31970. removeLight(toRemove: Light): number;
  31971. /**
  31972. * Remove a camera for the list of scene's cameras
  31973. * @param toRemove defines the camera to remove
  31974. * @returns the index where the camera was in the camera list
  31975. */
  31976. removeCamera(toRemove: Camera): number;
  31977. /**
  31978. * Remove a particle system for the list of scene's particle systems
  31979. * @param toRemove defines the particle system to remove
  31980. * @returns the index where the particle system was in the particle system list
  31981. */
  31982. removeParticleSystem(toRemove: IParticleSystem): number;
  31983. /**
  31984. * Remove a animation for the list of scene's animations
  31985. * @param toRemove defines the animation to remove
  31986. * @returns the index where the animation was in the animation list
  31987. */
  31988. removeAnimation(toRemove: Animation): number;
  31989. /**
  31990. * Removes the given animation group from this scene.
  31991. * @param toRemove The animation group to remove
  31992. * @returns The index of the removed animation group
  31993. */
  31994. removeAnimationGroup(toRemove: AnimationGroup): number;
  31995. /**
  31996. * Removes the given multi-material from this scene.
  31997. * @param toRemove The multi-material to remove
  31998. * @returns The index of the removed multi-material
  31999. */
  32000. removeMultiMaterial(toRemove: MultiMaterial): number;
  32001. /**
  32002. * Removes the given material from this scene.
  32003. * @param toRemove The material to remove
  32004. * @returns The index of the removed material
  32005. */
  32006. removeMaterial(toRemove: Material): number;
  32007. /**
  32008. * Removes the given action manager from this scene.
  32009. * @param toRemove The action manager to remove
  32010. * @returns The index of the removed action manager
  32011. */
  32012. removeActionManager(toRemove: AbstractActionManager): number;
  32013. /**
  32014. * Removes the given texture from this scene.
  32015. * @param toRemove The texture to remove
  32016. * @returns The index of the removed texture
  32017. */
  32018. removeTexture(toRemove: BaseTexture): number;
  32019. /**
  32020. * Adds the given light to this scene
  32021. * @param newLight The light to add
  32022. */
  32023. addLight(newLight: Light): void;
  32024. /**
  32025. * Sorts the list list based on light priorities
  32026. */
  32027. sortLightsByPriority(): void;
  32028. /**
  32029. * Adds the given camera to this scene
  32030. * @param newCamera The camera to add
  32031. */
  32032. addCamera(newCamera: Camera): void;
  32033. /**
  32034. * Adds the given skeleton to this scene
  32035. * @param newSkeleton The skeleton to add
  32036. */
  32037. addSkeleton(newSkeleton: Skeleton): void;
  32038. /**
  32039. * Adds the given particle system to this scene
  32040. * @param newParticleSystem The particle system to add
  32041. */
  32042. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32043. /**
  32044. * Adds the given animation to this scene
  32045. * @param newAnimation The animation to add
  32046. */
  32047. addAnimation(newAnimation: Animation): void;
  32048. /**
  32049. * Adds the given animation group to this scene.
  32050. * @param newAnimationGroup The animation group to add
  32051. */
  32052. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32053. /**
  32054. * Adds the given multi-material to this scene
  32055. * @param newMultiMaterial The multi-material to add
  32056. */
  32057. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32058. /**
  32059. * Adds the given material to this scene
  32060. * @param newMaterial The material to add
  32061. */
  32062. addMaterial(newMaterial: Material): void;
  32063. /**
  32064. * Adds the given morph target to this scene
  32065. * @param newMorphTargetManager The morph target to add
  32066. */
  32067. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32068. /**
  32069. * Adds the given geometry to this scene
  32070. * @param newGeometry The geometry to add
  32071. */
  32072. addGeometry(newGeometry: Geometry): void;
  32073. /**
  32074. * Adds the given action manager to this scene
  32075. * @param newActionManager The action manager to add
  32076. */
  32077. addActionManager(newActionManager: AbstractActionManager): void;
  32078. /**
  32079. * Adds the given texture to this scene.
  32080. * @param newTexture The texture to add
  32081. */
  32082. addTexture(newTexture: BaseTexture): void;
  32083. /**
  32084. * Switch active camera
  32085. * @param newCamera defines the new active camera
  32086. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32087. */
  32088. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32089. /**
  32090. * sets the active camera of the scene using its ID
  32091. * @param id defines the camera's ID
  32092. * @return the new active camera or null if none found.
  32093. */
  32094. setActiveCameraByID(id: string): Nullable<Camera>;
  32095. /**
  32096. * sets the active camera of the scene using its name
  32097. * @param name defines the camera's name
  32098. * @returns the new active camera or null if none found.
  32099. */
  32100. setActiveCameraByName(name: string): Nullable<Camera>;
  32101. /**
  32102. * get an animation group using its name
  32103. * @param name defines the material's name
  32104. * @return the animation group or null if none found.
  32105. */
  32106. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32107. /**
  32108. * get a material using its id
  32109. * @param id defines the material's ID
  32110. * @return the material or null if none found.
  32111. */
  32112. getMaterialByID(id: string): Nullable<Material>;
  32113. /**
  32114. * Gets a material using its name
  32115. * @param name defines the material's name
  32116. * @return the material or null if none found.
  32117. */
  32118. getMaterialByName(name: string): Nullable<Material>;
  32119. /**
  32120. * Gets a camera using its id
  32121. * @param id defines the id to look for
  32122. * @returns the camera or null if not found
  32123. */
  32124. getCameraByID(id: string): Nullable<Camera>;
  32125. /**
  32126. * Gets a camera using its unique id
  32127. * @param uniqueId defines the unique id to look for
  32128. * @returns the camera or null if not found
  32129. */
  32130. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32131. /**
  32132. * Gets a camera using its name
  32133. * @param name defines the camera's name
  32134. * @return the camera or null if none found.
  32135. */
  32136. getCameraByName(name: string): Nullable<Camera>;
  32137. /**
  32138. * Gets a bone using its id
  32139. * @param id defines the bone's id
  32140. * @return the bone or null if not found
  32141. */
  32142. getBoneByID(id: string): Nullable<Bone>;
  32143. /**
  32144. * Gets a bone using its id
  32145. * @param name defines the bone's name
  32146. * @return the bone or null if not found
  32147. */
  32148. getBoneByName(name: string): Nullable<Bone>;
  32149. /**
  32150. * Gets a light node using its name
  32151. * @param name defines the the light's name
  32152. * @return the light or null if none found.
  32153. */
  32154. getLightByName(name: string): Nullable<Light>;
  32155. /**
  32156. * Gets a light node using its id
  32157. * @param id defines the light's id
  32158. * @return the light or null if none found.
  32159. */
  32160. getLightByID(id: string): Nullable<Light>;
  32161. /**
  32162. * Gets a light node using its scene-generated unique ID
  32163. * @param uniqueId defines the light's unique id
  32164. * @return the light or null if none found.
  32165. */
  32166. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32167. /**
  32168. * Gets a particle system by id
  32169. * @param id defines the particle system id
  32170. * @return the corresponding system or null if none found
  32171. */
  32172. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32173. /**
  32174. * Gets a geometry using its ID
  32175. * @param id defines the geometry's id
  32176. * @return the geometry or null if none found.
  32177. */
  32178. getGeometryByID(id: string): Nullable<Geometry>;
  32179. private _getGeometryByUniqueID;
  32180. /**
  32181. * Add a new geometry to this scene
  32182. * @param geometry defines the geometry to be added to the scene.
  32183. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32184. * @return a boolean defining if the geometry was added or not
  32185. */
  32186. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32187. /**
  32188. * Removes an existing geometry
  32189. * @param geometry defines the geometry to be removed from the scene
  32190. * @return a boolean defining if the geometry was removed or not
  32191. */
  32192. removeGeometry(geometry: Geometry): boolean;
  32193. /**
  32194. * Gets the list of geometries attached to the scene
  32195. * @returns an array of Geometry
  32196. */
  32197. getGeometries(): Geometry[];
  32198. /**
  32199. * Gets the first added mesh found of a given ID
  32200. * @param id defines the id to search for
  32201. * @return the mesh found or null if not found at all
  32202. */
  32203. getMeshByID(id: string): Nullable<AbstractMesh>;
  32204. /**
  32205. * Gets a list of meshes using their id
  32206. * @param id defines the id to search for
  32207. * @returns a list of meshes
  32208. */
  32209. getMeshesByID(id: string): Array<AbstractMesh>;
  32210. /**
  32211. * Gets the first added transform node found of a given ID
  32212. * @param id defines the id to search for
  32213. * @return the found transform node or null if not found at all.
  32214. */
  32215. getTransformNodeByID(id: string): Nullable<TransformNode>;
  32216. /**
  32217. * Gets a list of transform nodes using their id
  32218. * @param id defines the id to search for
  32219. * @returns a list of transform nodes
  32220. */
  32221. getTransformNodesByID(id: string): Array<TransformNode>;
  32222. /**
  32223. * Gets a mesh with its auto-generated unique id
  32224. * @param uniqueId defines the unique id to search for
  32225. * @return the found mesh or null if not found at all.
  32226. */
  32227. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  32228. /**
  32229. * Gets a the last added mesh using a given id
  32230. * @param id defines the id to search for
  32231. * @return the found mesh or null if not found at all.
  32232. */
  32233. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  32234. /**
  32235. * Gets a the last added node (Mesh, Camera, Light) using a given id
  32236. * @param id defines the id to search for
  32237. * @return the found node or null if not found at all
  32238. */
  32239. getLastEntryByID(id: string): Nullable<Node>;
  32240. /**
  32241. * Gets a node (Mesh, Camera, Light) using a given id
  32242. * @param id defines the id to search for
  32243. * @return the found node or null if not found at all
  32244. */
  32245. getNodeByID(id: string): Nullable<Node>;
  32246. /**
  32247. * Gets a node (Mesh, Camera, Light) using a given name
  32248. * @param name defines the name to search for
  32249. * @return the found node or null if not found at all.
  32250. */
  32251. getNodeByName(name: string): Nullable<Node>;
  32252. /**
  32253. * Gets a mesh using a given name
  32254. * @param name defines the name to search for
  32255. * @return the found mesh or null if not found at all.
  32256. */
  32257. getMeshByName(name: string): Nullable<AbstractMesh>;
  32258. /**
  32259. * Gets a transform node using a given name
  32260. * @param name defines the name to search for
  32261. * @return the found transform node or null if not found at all.
  32262. */
  32263. getTransformNodeByName(name: string): Nullable<TransformNode>;
  32264. /**
  32265. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  32266. * @param id defines the id to search for
  32267. * @return the found skeleton or null if not found at all.
  32268. */
  32269. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  32270. /**
  32271. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  32272. * @param id defines the id to search for
  32273. * @return the found skeleton or null if not found at all.
  32274. */
  32275. getSkeletonById(id: string): Nullable<Skeleton>;
  32276. /**
  32277. * Gets a skeleton using a given name
  32278. * @param name defines the name to search for
  32279. * @return the found skeleton or null if not found at all.
  32280. */
  32281. getSkeletonByName(name: string): Nullable<Skeleton>;
  32282. /**
  32283. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  32284. * @param id defines the id to search for
  32285. * @return the found morph target manager or null if not found at all.
  32286. */
  32287. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  32288. /**
  32289. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  32290. * @param id defines the id to search for
  32291. * @return the found morph target or null if not found at all.
  32292. */
  32293. getMorphTargetById(id: string): Nullable<MorphTarget>;
  32294. /**
  32295. * Gets a boolean indicating if the given mesh is active
  32296. * @param mesh defines the mesh to look for
  32297. * @returns true if the mesh is in the active list
  32298. */
  32299. isActiveMesh(mesh: AbstractMesh): boolean;
  32300. /**
  32301. * Return a unique id as a string which can serve as an identifier for the scene
  32302. */
  32303. readonly uid: string;
  32304. /**
  32305. * Add an externaly attached data from its key.
  32306. * This method call will fail and return false, if such key already exists.
  32307. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32308. * @param key the unique key that identifies the data
  32309. * @param data the data object to associate to the key for this Engine instance
  32310. * @return true if no such key were already present and the data was added successfully, false otherwise
  32311. */
  32312. addExternalData<T>(key: string, data: T): boolean;
  32313. /**
  32314. * Get an externaly attached data from its key
  32315. * @param key the unique key that identifies the data
  32316. * @return the associated data, if present (can be null), or undefined if not present
  32317. */
  32318. getExternalData<T>(key: string): Nullable<T>;
  32319. /**
  32320. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32321. * @param key the unique key that identifies the data
  32322. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32323. * @return the associated data, can be null if the factory returned null.
  32324. */
  32325. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32326. /**
  32327. * Remove an externaly attached data from the Engine instance
  32328. * @param key the unique key that identifies the data
  32329. * @return true if the data was successfully removed, false if it doesn't exist
  32330. */
  32331. removeExternalData(key: string): boolean;
  32332. private _evaluateSubMesh;
  32333. /**
  32334. * Clear the processed materials smart array preventing retention point in material dispose.
  32335. */
  32336. freeProcessedMaterials(): void;
  32337. private _preventFreeActiveMeshesAndRenderingGroups;
  32338. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  32339. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  32340. * when disposing several meshes in a row or a hierarchy of meshes.
  32341. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  32342. */
  32343. blockfreeActiveMeshesAndRenderingGroups: boolean;
  32344. /**
  32345. * Clear the active meshes smart array preventing retention point in mesh dispose.
  32346. */
  32347. freeActiveMeshes(): void;
  32348. /**
  32349. * Clear the info related to rendering groups preventing retention points during dispose.
  32350. */
  32351. freeRenderingGroups(): void;
  32352. /** @hidden */
  32353. _isInIntermediateRendering(): boolean;
  32354. /**
  32355. * Lambda returning the list of potentially active meshes.
  32356. */
  32357. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  32358. /**
  32359. * Lambda returning the list of potentially active sub meshes.
  32360. */
  32361. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  32362. /**
  32363. * Lambda returning the list of potentially intersecting sub meshes.
  32364. */
  32365. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  32366. /**
  32367. * Lambda returning the list of potentially colliding sub meshes.
  32368. */
  32369. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  32370. private _activeMeshesFrozen;
  32371. /**
  32372. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  32373. * @returns the current scene
  32374. */
  32375. freezeActiveMeshes(): Scene;
  32376. /**
  32377. * Use this function to restart evaluating active meshes on every frame
  32378. * @returns the current scene
  32379. */
  32380. unfreezeActiveMeshes(): Scene;
  32381. private _evaluateActiveMeshes;
  32382. private _activeMesh;
  32383. /**
  32384. * Update the transform matrix to update from the current active camera
  32385. * @param force defines a boolean used to force the update even if cache is up to date
  32386. */
  32387. updateTransformMatrix(force?: boolean): void;
  32388. /**
  32389. * 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)
  32390. * @param alternateCamera defines the camera to use
  32391. */
  32392. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  32393. /** @hidden */
  32394. _allowPostProcessClearColor: boolean;
  32395. private _renderForCamera;
  32396. private _processSubCameras;
  32397. private _checkIntersections;
  32398. /** @hidden */
  32399. _advancePhysicsEngineStep(step: number): void;
  32400. /**
  32401. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  32402. */
  32403. getDeterministicFrameTime: () => number;
  32404. /**
  32405. * Render the scene
  32406. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  32407. */
  32408. render(updateCameras?: boolean): void;
  32409. /**
  32410. * Freeze all materials
  32411. * A frozen material will not be updatable but should be faster to render
  32412. */
  32413. freezeMaterials(): void;
  32414. /**
  32415. * Unfreeze all materials
  32416. * A frozen material will not be updatable but should be faster to render
  32417. */
  32418. unfreezeMaterials(): void;
  32419. /**
  32420. * Releases all held ressources
  32421. */
  32422. dispose(): void;
  32423. /**
  32424. * Gets if the scene is already disposed
  32425. */
  32426. readonly isDisposed: boolean;
  32427. /**
  32428. * Call this function to reduce memory footprint of the scene.
  32429. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  32430. */
  32431. clearCachedVertexData(): void;
  32432. /**
  32433. * This function will remove the local cached buffer data from texture.
  32434. * It will save memory but will prevent the texture from being rebuilt
  32435. */
  32436. cleanCachedTextureBuffer(): void;
  32437. /**
  32438. * Get the world extend vectors with an optional filter
  32439. *
  32440. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  32441. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  32442. */
  32443. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  32444. min: Vector3;
  32445. max: Vector3;
  32446. };
  32447. /**
  32448. * Creates a ray that can be used to pick in the scene
  32449. * @param x defines the x coordinate of the origin (on-screen)
  32450. * @param y defines the y coordinate of the origin (on-screen)
  32451. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32452. * @param camera defines the camera to use for the picking
  32453. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32454. * @returns a Ray
  32455. */
  32456. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  32457. /**
  32458. * Creates a ray that can be used to pick in the scene
  32459. * @param x defines the x coordinate of the origin (on-screen)
  32460. * @param y defines the y coordinate of the origin (on-screen)
  32461. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32462. * @param result defines the ray where to store the picking ray
  32463. * @param camera defines the camera to use for the picking
  32464. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32465. * @returns the current scene
  32466. */
  32467. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  32468. /**
  32469. * Creates a ray that can be used to pick in the scene
  32470. * @param x defines the x coordinate of the origin (on-screen)
  32471. * @param y defines the y coordinate of the origin (on-screen)
  32472. * @param camera defines the camera to use for the picking
  32473. * @returns a Ray
  32474. */
  32475. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  32476. /**
  32477. * Creates a ray that can be used to pick in the scene
  32478. * @param x defines the x coordinate of the origin (on-screen)
  32479. * @param y defines the y coordinate of the origin (on-screen)
  32480. * @param result defines the ray where to store the picking ray
  32481. * @param camera defines the camera to use for the picking
  32482. * @returns the current scene
  32483. */
  32484. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  32485. private _internalPick;
  32486. private _internalMultiPick;
  32487. private _tempPickingRay;
  32488. /** Launch a ray to try to pick a mesh in the scene
  32489. * @param x position on screen
  32490. * @param y position on screen
  32491. * @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
  32492. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  32493. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32494. * @returns a PickingInfo
  32495. */
  32496. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  32497. private _cachedRayForTransform;
  32498. /** Use the given ray to pick a mesh in the scene
  32499. * @param ray The ray to use to pick meshes
  32500. * @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
  32501. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  32502. * @returns a PickingInfo
  32503. */
  32504. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  32505. /**
  32506. * Launch a ray to try to pick a mesh in the scene
  32507. * @param x X position on screen
  32508. * @param y Y position on screen
  32509. * @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
  32510. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32511. * @returns an array of PickingInfo
  32512. */
  32513. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  32514. /**
  32515. * Launch a ray to try to pick a mesh in the scene
  32516. * @param ray Ray to use
  32517. * @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
  32518. * @returns an array of PickingInfo
  32519. */
  32520. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  32521. /**
  32522. * Force the value of meshUnderPointer
  32523. * @param mesh defines the mesh to use
  32524. */
  32525. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32526. /**
  32527. * Gets the mesh under the pointer
  32528. * @returns a Mesh or null if no mesh is under the pointer
  32529. */
  32530. getPointerOverMesh(): Nullable<AbstractMesh>;
  32531. /** @hidden */
  32532. _rebuildGeometries(): void;
  32533. /** @hidden */
  32534. _rebuildTextures(): void;
  32535. private _getByTags;
  32536. /**
  32537. * Get a list of meshes by tags
  32538. * @param tagsQuery defines the tags query to use
  32539. * @param forEach defines a predicate used to filter results
  32540. * @returns an array of Mesh
  32541. */
  32542. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  32543. /**
  32544. * Get a list of cameras by tags
  32545. * @param tagsQuery defines the tags query to use
  32546. * @param forEach defines a predicate used to filter results
  32547. * @returns an array of Camera
  32548. */
  32549. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  32550. /**
  32551. * Get a list of lights by tags
  32552. * @param tagsQuery defines the tags query to use
  32553. * @param forEach defines a predicate used to filter results
  32554. * @returns an array of Light
  32555. */
  32556. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  32557. /**
  32558. * Get a list of materials by tags
  32559. * @param tagsQuery defines the tags query to use
  32560. * @param forEach defines a predicate used to filter results
  32561. * @returns an array of Material
  32562. */
  32563. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  32564. /**
  32565. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  32566. * This allowed control for front to back rendering or reversly depending of the special needs.
  32567. *
  32568. * @param renderingGroupId The rendering group id corresponding to its index
  32569. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  32570. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  32571. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  32572. */
  32573. 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;
  32574. /**
  32575. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  32576. *
  32577. * @param renderingGroupId The rendering group id corresponding to its index
  32578. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  32579. * @param depth Automatically clears depth between groups if true and autoClear is true.
  32580. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  32581. */
  32582. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  32583. /**
  32584. * Gets the current auto clear configuration for one rendering group of the rendering
  32585. * manager.
  32586. * @param index the rendering group index to get the information for
  32587. * @returns The auto clear setup for the requested rendering group
  32588. */
  32589. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  32590. private _blockMaterialDirtyMechanism;
  32591. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  32592. blockMaterialDirtyMechanism: boolean;
  32593. /**
  32594. * Will flag all materials as dirty to trigger new shader compilation
  32595. * @param flag defines the flag used to specify which material part must be marked as dirty
  32596. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  32597. */
  32598. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32599. /** @hidden */
  32600. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  32601. /** @hidden */
  32602. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32603. }
  32604. }
  32605. declare module BABYLON {
  32606. /**
  32607. * Set of assets to keep when moving a scene into an asset container.
  32608. */
  32609. export class KeepAssets extends AbstractScene {
  32610. }
  32611. /**
  32612. * Container with a set of assets that can be added or removed from a scene.
  32613. */
  32614. export class AssetContainer extends AbstractScene {
  32615. /**
  32616. * The scene the AssetContainer belongs to.
  32617. */
  32618. scene: Scene;
  32619. /**
  32620. * Instantiates an AssetContainer.
  32621. * @param scene The scene the AssetContainer belongs to.
  32622. */
  32623. constructor(scene: Scene);
  32624. /**
  32625. * Adds all the assets from the container to the scene.
  32626. */
  32627. addAllToScene(): void;
  32628. /**
  32629. * Removes all the assets in the container from the scene
  32630. */
  32631. removeAllFromScene(): void;
  32632. /**
  32633. * Disposes all the assets in the container
  32634. */
  32635. dispose(): void;
  32636. private _moveAssets;
  32637. /**
  32638. * Removes all the assets contained in the scene and adds them to the container.
  32639. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  32640. */
  32641. moveAllFromScene(keepAssets?: KeepAssets): void;
  32642. /**
  32643. * 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.
  32644. * @returns the root mesh
  32645. */
  32646. createRootMesh(): Mesh;
  32647. }
  32648. }
  32649. declare module BABYLON {
  32650. /**
  32651. * Defines how the parser contract is defined.
  32652. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  32653. */
  32654. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  32655. /**
  32656. * Defines how the individual parser contract is defined.
  32657. * These parser can parse an individual asset
  32658. */
  32659. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  32660. /**
  32661. * Base class of the scene acting as a container for the different elements composing a scene.
  32662. * This class is dynamically extended by the different components of the scene increasing
  32663. * flexibility and reducing coupling
  32664. */
  32665. export abstract class AbstractScene {
  32666. /**
  32667. * Stores the list of available parsers in the application.
  32668. */
  32669. private static _BabylonFileParsers;
  32670. /**
  32671. * Stores the list of available individual parsers in the application.
  32672. */
  32673. private static _IndividualBabylonFileParsers;
  32674. /**
  32675. * Adds a parser in the list of available ones
  32676. * @param name Defines the name of the parser
  32677. * @param parser Defines the parser to add
  32678. */
  32679. static AddParser(name: string, parser: BabylonFileParser): void;
  32680. /**
  32681. * Gets a general parser from the list of avaialble ones
  32682. * @param name Defines the name of the parser
  32683. * @returns the requested parser or null
  32684. */
  32685. static GetParser(name: string): Nullable<BabylonFileParser>;
  32686. /**
  32687. * Adds n individual parser in the list of available ones
  32688. * @param name Defines the name of the parser
  32689. * @param parser Defines the parser to add
  32690. */
  32691. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  32692. /**
  32693. * Gets an individual parser from the list of avaialble ones
  32694. * @param name Defines the name of the parser
  32695. * @returns the requested parser or null
  32696. */
  32697. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  32698. /**
  32699. * Parser json data and populate both a scene and its associated container object
  32700. * @param jsonData Defines the data to parse
  32701. * @param scene Defines the scene to parse the data for
  32702. * @param container Defines the container attached to the parsing sequence
  32703. * @param rootUrl Defines the root url of the data
  32704. */
  32705. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  32706. /**
  32707. * Gets the list of root nodes (ie. nodes with no parent)
  32708. */
  32709. rootNodes: Node[];
  32710. /** All of the cameras added to this scene
  32711. * @see http://doc.babylonjs.com/babylon101/cameras
  32712. */
  32713. cameras: Camera[];
  32714. /**
  32715. * All of the lights added to this scene
  32716. * @see http://doc.babylonjs.com/babylon101/lights
  32717. */
  32718. lights: Light[];
  32719. /**
  32720. * All of the (abstract) meshes added to this scene
  32721. */
  32722. meshes: AbstractMesh[];
  32723. /**
  32724. * The list of skeletons added to the scene
  32725. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32726. */
  32727. skeletons: Skeleton[];
  32728. /**
  32729. * All of the particle systems added to this scene
  32730. * @see http://doc.babylonjs.com/babylon101/particles
  32731. */
  32732. particleSystems: IParticleSystem[];
  32733. /**
  32734. * Gets a list of Animations associated with the scene
  32735. */
  32736. animations: Animation[];
  32737. /**
  32738. * All of the animation groups added to this scene
  32739. * @see http://doc.babylonjs.com/how_to/group
  32740. */
  32741. animationGroups: AnimationGroup[];
  32742. /**
  32743. * All of the multi-materials added to this scene
  32744. * @see http://doc.babylonjs.com/how_to/multi_materials
  32745. */
  32746. multiMaterials: MultiMaterial[];
  32747. /**
  32748. * All of the materials added to this scene
  32749. * In the context of a Scene, it is not supposed to be modified manually.
  32750. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  32751. * Note also that the order of the Material wihin the array is not significant and might change.
  32752. * @see http://doc.babylonjs.com/babylon101/materials
  32753. */
  32754. materials: Material[];
  32755. /**
  32756. * The list of morph target managers added to the scene
  32757. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  32758. */
  32759. morphTargetManagers: MorphTargetManager[];
  32760. /**
  32761. * The list of geometries used in the scene.
  32762. */
  32763. geometries: Geometry[];
  32764. /**
  32765. * All of the tranform nodes added to this scene
  32766. * In the context of a Scene, it is not supposed to be modified manually.
  32767. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  32768. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  32769. * @see http://doc.babylonjs.com/how_to/transformnode
  32770. */
  32771. transformNodes: TransformNode[];
  32772. /**
  32773. * ActionManagers available on the scene.
  32774. */
  32775. actionManagers: AbstractActionManager[];
  32776. /**
  32777. * Textures to keep.
  32778. */
  32779. textures: BaseTexture[];
  32780. }
  32781. }
  32782. declare module BABYLON {
  32783. /**
  32784. * Defines a sound that can be played in the application.
  32785. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  32786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32787. */
  32788. export class Sound {
  32789. /**
  32790. * The name of the sound in the scene.
  32791. */
  32792. name: string;
  32793. /**
  32794. * Does the sound autoplay once loaded.
  32795. */
  32796. autoplay: boolean;
  32797. /**
  32798. * Does the sound loop after it finishes playing once.
  32799. */
  32800. loop: boolean;
  32801. /**
  32802. * Does the sound use a custom attenuation curve to simulate the falloff
  32803. * happening when the source gets further away from the camera.
  32804. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  32805. */
  32806. useCustomAttenuation: boolean;
  32807. /**
  32808. * The sound track id this sound belongs to.
  32809. */
  32810. soundTrackId: number;
  32811. /**
  32812. * Is this sound currently played.
  32813. */
  32814. isPlaying: boolean;
  32815. /**
  32816. * Is this sound currently paused.
  32817. */
  32818. isPaused: boolean;
  32819. /**
  32820. * Does this sound enables spatial sound.
  32821. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32822. */
  32823. spatialSound: boolean;
  32824. /**
  32825. * Define the reference distance the sound should be heard perfectly.
  32826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32827. */
  32828. refDistance: number;
  32829. /**
  32830. * Define the roll off factor of spatial sounds.
  32831. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32832. */
  32833. rolloffFactor: number;
  32834. /**
  32835. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  32836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32837. */
  32838. maxDistance: number;
  32839. /**
  32840. * Define the distance attenuation model the sound will follow.
  32841. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32842. */
  32843. distanceModel: string;
  32844. /**
  32845. * @hidden
  32846. * Back Compat
  32847. **/
  32848. onended: () => any;
  32849. /**
  32850. * Observable event when the current playing sound finishes.
  32851. */
  32852. onEndedObservable: Observable<Sound>;
  32853. private _panningModel;
  32854. private _playbackRate;
  32855. private _streaming;
  32856. private _startTime;
  32857. private _startOffset;
  32858. private _position;
  32859. /** @hidden */
  32860. _positionInEmitterSpace: boolean;
  32861. private _localDirection;
  32862. private _volume;
  32863. private _isReadyToPlay;
  32864. private _isDirectional;
  32865. private _readyToPlayCallback;
  32866. private _audioBuffer;
  32867. private _soundSource;
  32868. private _streamingSource;
  32869. private _soundPanner;
  32870. private _soundGain;
  32871. private _inputAudioNode;
  32872. private _outputAudioNode;
  32873. private _coneInnerAngle;
  32874. private _coneOuterAngle;
  32875. private _coneOuterGain;
  32876. private _scene;
  32877. private _connectedTransformNode;
  32878. private _customAttenuationFunction;
  32879. private _registerFunc;
  32880. private _isOutputConnected;
  32881. private _htmlAudioElement;
  32882. private _urlType;
  32883. /** @hidden */
  32884. static _SceneComponentInitialization: (scene: Scene) => void;
  32885. /**
  32886. * Create a sound and attach it to a scene
  32887. * @param name Name of your sound
  32888. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  32889. * @param scene defines the scene the sound belongs to
  32890. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  32891. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  32892. */
  32893. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  32894. /**
  32895. * Release the sound and its associated resources
  32896. */
  32897. dispose(): void;
  32898. /**
  32899. * Gets if the sounds is ready to be played or not.
  32900. * @returns true if ready, otherwise false
  32901. */
  32902. isReady(): boolean;
  32903. private _soundLoaded;
  32904. /**
  32905. * Sets the data of the sound from an audiobuffer
  32906. * @param audioBuffer The audioBuffer containing the data
  32907. */
  32908. setAudioBuffer(audioBuffer: AudioBuffer): void;
  32909. /**
  32910. * Updates the current sounds options such as maxdistance, loop...
  32911. * @param options A JSON object containing values named as the object properties
  32912. */
  32913. updateOptions(options: any): void;
  32914. private _createSpatialParameters;
  32915. private _updateSpatialParameters;
  32916. /**
  32917. * Switch the panning model to HRTF:
  32918. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  32919. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32920. */
  32921. switchPanningModelToHRTF(): void;
  32922. /**
  32923. * Switch the panning model to Equal Power:
  32924. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  32925. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32926. */
  32927. switchPanningModelToEqualPower(): void;
  32928. private _switchPanningModel;
  32929. /**
  32930. * Connect this sound to a sound track audio node like gain...
  32931. * @param soundTrackAudioNode the sound track audio node to connect to
  32932. */
  32933. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  32934. /**
  32935. * Transform this sound into a directional source
  32936. * @param coneInnerAngle Size of the inner cone in degree
  32937. * @param coneOuterAngle Size of the outer cone in degree
  32938. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  32939. */
  32940. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  32941. /**
  32942. * Gets or sets the inner angle for the directional cone.
  32943. */
  32944. /**
  32945. * Gets or sets the inner angle for the directional cone.
  32946. */
  32947. directionalConeInnerAngle: number;
  32948. /**
  32949. * Gets or sets the outer angle for the directional cone.
  32950. */
  32951. /**
  32952. * Gets or sets the outer angle for the directional cone.
  32953. */
  32954. directionalConeOuterAngle: number;
  32955. /**
  32956. * Sets the position of the emitter if spatial sound is enabled
  32957. * @param newPosition Defines the new posisiton
  32958. */
  32959. setPosition(newPosition: Vector3): void;
  32960. /**
  32961. * Sets the local direction of the emitter if spatial sound is enabled
  32962. * @param newLocalDirection Defines the new local direction
  32963. */
  32964. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  32965. private _updateDirection;
  32966. /** @hidden */
  32967. updateDistanceFromListener(): void;
  32968. /**
  32969. * Sets a new custom attenuation function for the sound.
  32970. * @param callback Defines the function used for the attenuation
  32971. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  32972. */
  32973. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  32974. /**
  32975. * Play the sound
  32976. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  32977. * @param offset (optional) Start the sound setting it at a specific time
  32978. */
  32979. play(time?: number, offset?: number): void;
  32980. private _onended;
  32981. /**
  32982. * Stop the sound
  32983. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  32984. */
  32985. stop(time?: number): void;
  32986. /**
  32987. * Put the sound in pause
  32988. */
  32989. pause(): void;
  32990. /**
  32991. * Sets a dedicated volume for this sounds
  32992. * @param newVolume Define the new volume of the sound
  32993. * @param time Define in how long the sound should be at this value
  32994. */
  32995. setVolume(newVolume: number, time?: number): void;
  32996. /**
  32997. * Set the sound play back rate
  32998. * @param newPlaybackRate Define the playback rate the sound should be played at
  32999. */
  33000. setPlaybackRate(newPlaybackRate: number): void;
  33001. /**
  33002. * Gets the volume of the sound.
  33003. * @returns the volume of the sound
  33004. */
  33005. getVolume(): number;
  33006. /**
  33007. * Attach the sound to a dedicated mesh
  33008. * @param transformNode The transform node to connect the sound with
  33009. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33010. */
  33011. attachToMesh(transformNode: TransformNode): void;
  33012. /**
  33013. * Detach the sound from the previously attached mesh
  33014. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33015. */
  33016. detachFromMesh(): void;
  33017. private _onRegisterAfterWorldMatrixUpdate;
  33018. /**
  33019. * Clone the current sound in the scene.
  33020. * @returns the new sound clone
  33021. */
  33022. clone(): Nullable<Sound>;
  33023. /**
  33024. * Gets the current underlying audio buffer containing the data
  33025. * @returns the audio buffer
  33026. */
  33027. getAudioBuffer(): Nullable<AudioBuffer>;
  33028. /**
  33029. * Serializes the Sound in a JSON representation
  33030. * @returns the JSON representation of the sound
  33031. */
  33032. serialize(): any;
  33033. /**
  33034. * Parse a JSON representation of a sound to innstantiate in a given scene
  33035. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33036. * @param scene Define the scene the new parsed sound should be created in
  33037. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33038. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33039. * @returns the newly parsed sound
  33040. */
  33041. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33042. }
  33043. }
  33044. declare module BABYLON {
  33045. /**
  33046. * This defines an action helpful to play a defined sound on a triggered action.
  33047. */
  33048. export class PlaySoundAction extends Action {
  33049. private _sound;
  33050. /**
  33051. * Instantiate the action
  33052. * @param triggerOptions defines the trigger options
  33053. * @param sound defines the sound to play
  33054. * @param condition defines the trigger related conditions
  33055. */
  33056. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33057. /** @hidden */
  33058. _prepare(): void;
  33059. /**
  33060. * Execute the action and play the sound.
  33061. */
  33062. execute(): void;
  33063. /**
  33064. * Serializes the actions and its related information.
  33065. * @param parent defines the object to serialize in
  33066. * @returns the serialized object
  33067. */
  33068. serialize(parent: any): any;
  33069. }
  33070. /**
  33071. * This defines an action helpful to stop a defined sound on a triggered action.
  33072. */
  33073. export class StopSoundAction extends Action {
  33074. private _sound;
  33075. /**
  33076. * Instantiate the action
  33077. * @param triggerOptions defines the trigger options
  33078. * @param sound defines the sound to stop
  33079. * @param condition defines the trigger related conditions
  33080. */
  33081. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33082. /** @hidden */
  33083. _prepare(): void;
  33084. /**
  33085. * Execute the action and stop the sound.
  33086. */
  33087. execute(): void;
  33088. /**
  33089. * Serializes the actions and its related information.
  33090. * @param parent defines the object to serialize in
  33091. * @returns the serialized object
  33092. */
  33093. serialize(parent: any): any;
  33094. }
  33095. }
  33096. declare module BABYLON {
  33097. /**
  33098. * This defines an action responsible to change the value of a property
  33099. * by interpolating between its current value and the newly set one once triggered.
  33100. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33101. */
  33102. export class InterpolateValueAction extends Action {
  33103. /**
  33104. * Defines the path of the property where the value should be interpolated
  33105. */
  33106. propertyPath: string;
  33107. /**
  33108. * Defines the target value at the end of the interpolation.
  33109. */
  33110. value: any;
  33111. /**
  33112. * Defines the time it will take for the property to interpolate to the value.
  33113. */
  33114. duration: number;
  33115. /**
  33116. * Defines if the other scene animations should be stopped when the action has been triggered
  33117. */
  33118. stopOtherAnimations?: boolean;
  33119. /**
  33120. * Defines a callback raised once the interpolation animation has been done.
  33121. */
  33122. onInterpolationDone?: () => void;
  33123. /**
  33124. * Observable triggered once the interpolation animation has been done.
  33125. */
  33126. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33127. private _target;
  33128. private _effectiveTarget;
  33129. private _property;
  33130. /**
  33131. * Instantiate the action
  33132. * @param triggerOptions defines the trigger options
  33133. * @param target defines the object containing the value to interpolate
  33134. * @param propertyPath defines the path to the property in the target object
  33135. * @param value defines the target value at the end of the interpolation
  33136. * @param duration deines the time it will take for the property to interpolate to the value.
  33137. * @param condition defines the trigger related conditions
  33138. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33139. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33140. */
  33141. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33142. /** @hidden */
  33143. _prepare(): void;
  33144. /**
  33145. * Execute the action starts the value interpolation.
  33146. */
  33147. execute(): void;
  33148. /**
  33149. * Serializes the actions and its related information.
  33150. * @param parent defines the object to serialize in
  33151. * @returns the serialized object
  33152. */
  33153. serialize(parent: any): any;
  33154. }
  33155. }
  33156. declare module BABYLON {
  33157. /**
  33158. * Options allowed during the creation of a sound track.
  33159. */
  33160. export interface ISoundTrackOptions {
  33161. /**
  33162. * The volume the sound track should take during creation
  33163. */
  33164. volume?: number;
  33165. /**
  33166. * Define if the sound track is the main sound track of the scene
  33167. */
  33168. mainTrack?: boolean;
  33169. }
  33170. /**
  33171. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  33172. * It will be also used in a future release to apply effects on a specific track.
  33173. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33174. */
  33175. export class SoundTrack {
  33176. /**
  33177. * The unique identifier of the sound track in the scene.
  33178. */
  33179. id: number;
  33180. /**
  33181. * The list of sounds included in the sound track.
  33182. */
  33183. soundCollection: Array<Sound>;
  33184. private _outputAudioNode;
  33185. private _scene;
  33186. private _isMainTrack;
  33187. private _connectedAnalyser;
  33188. private _options;
  33189. private _isInitialized;
  33190. /**
  33191. * Creates a new sound track.
  33192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33193. * @param scene Define the scene the sound track belongs to
  33194. * @param options
  33195. */
  33196. constructor(scene: Scene, options?: ISoundTrackOptions);
  33197. private _initializeSoundTrackAudioGraph;
  33198. /**
  33199. * Release the sound track and its associated resources
  33200. */
  33201. dispose(): void;
  33202. /**
  33203. * Adds a sound to this sound track
  33204. * @param sound define the cound to add
  33205. * @ignoreNaming
  33206. */
  33207. AddSound(sound: Sound): void;
  33208. /**
  33209. * Removes a sound to this sound track
  33210. * @param sound define the cound to remove
  33211. * @ignoreNaming
  33212. */
  33213. RemoveSound(sound: Sound): void;
  33214. /**
  33215. * Set a global volume for the full sound track.
  33216. * @param newVolume Define the new volume of the sound track
  33217. */
  33218. setVolume(newVolume: number): void;
  33219. /**
  33220. * Switch the panning model to HRTF:
  33221. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33222. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33223. */
  33224. switchPanningModelToHRTF(): void;
  33225. /**
  33226. * Switch the panning model to Equal Power:
  33227. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33229. */
  33230. switchPanningModelToEqualPower(): void;
  33231. /**
  33232. * Connect the sound track to an audio analyser allowing some amazing
  33233. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33234. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33235. * @param analyser The analyser to connect to the engine
  33236. */
  33237. connectToAnalyser(analyser: Analyser): void;
  33238. }
  33239. }
  33240. declare module BABYLON {
  33241. interface AbstractScene {
  33242. /**
  33243. * The list of sounds used in the scene.
  33244. */
  33245. sounds: Nullable<Array<Sound>>;
  33246. }
  33247. interface Scene {
  33248. /**
  33249. * @hidden
  33250. * Backing field
  33251. */
  33252. _mainSoundTrack: SoundTrack;
  33253. /**
  33254. * The main sound track played by the scene.
  33255. * It cotains your primary collection of sounds.
  33256. */
  33257. mainSoundTrack: SoundTrack;
  33258. /**
  33259. * The list of sound tracks added to the scene
  33260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33261. */
  33262. soundTracks: Nullable<Array<SoundTrack>>;
  33263. /**
  33264. * Gets a sound using a given name
  33265. * @param name defines the name to search for
  33266. * @return the found sound or null if not found at all.
  33267. */
  33268. getSoundByName(name: string): Nullable<Sound>;
  33269. /**
  33270. * Gets or sets if audio support is enabled
  33271. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33272. */
  33273. audioEnabled: boolean;
  33274. /**
  33275. * Gets or sets if audio will be output to headphones
  33276. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33277. */
  33278. headphone: boolean;
  33279. }
  33280. /**
  33281. * Defines the sound scene component responsible to manage any sounds
  33282. * in a given scene.
  33283. */
  33284. export class AudioSceneComponent implements ISceneSerializableComponent {
  33285. /**
  33286. * The component name helpfull to identify the component in the list of scene components.
  33287. */
  33288. readonly name: string;
  33289. /**
  33290. * The scene the component belongs to.
  33291. */
  33292. scene: Scene;
  33293. private _audioEnabled;
  33294. /**
  33295. * Gets whether audio is enabled or not.
  33296. * Please use related enable/disable method to switch state.
  33297. */
  33298. readonly audioEnabled: boolean;
  33299. private _headphone;
  33300. /**
  33301. * Gets whether audio is outputing to headphone or not.
  33302. * Please use the according Switch methods to change output.
  33303. */
  33304. readonly headphone: boolean;
  33305. /**
  33306. * Creates a new instance of the component for the given scene
  33307. * @param scene Defines the scene to register the component in
  33308. */
  33309. constructor(scene: Scene);
  33310. /**
  33311. * Registers the component in a given scene
  33312. */
  33313. register(): void;
  33314. /**
  33315. * Rebuilds the elements related to this component in case of
  33316. * context lost for instance.
  33317. */
  33318. rebuild(): void;
  33319. /**
  33320. * Serializes the component data to the specified json object
  33321. * @param serializationObject The object to serialize to
  33322. */
  33323. serialize(serializationObject: any): void;
  33324. /**
  33325. * Adds all the element from the container to the scene
  33326. * @param container the container holding the elements
  33327. */
  33328. addFromContainer(container: AbstractScene): void;
  33329. /**
  33330. * Removes all the elements in the container from the scene
  33331. * @param container contains the elements to remove
  33332. */
  33333. removeFromContainer(container: AbstractScene): void;
  33334. /**
  33335. * Disposes the component and the associated ressources.
  33336. */
  33337. dispose(): void;
  33338. /**
  33339. * Disables audio in the associated scene.
  33340. */
  33341. disableAudio(): void;
  33342. /**
  33343. * Enables audio in the associated scene.
  33344. */
  33345. enableAudio(): void;
  33346. /**
  33347. * Switch audio to headphone output.
  33348. */
  33349. switchAudioModeForHeadphones(): void;
  33350. /**
  33351. * Switch audio to normal speakers.
  33352. */
  33353. switchAudioModeForNormalSpeakers(): void;
  33354. private _afterRender;
  33355. }
  33356. }
  33357. declare module BABYLON {
  33358. /**
  33359. * Wraps one or more Sound objects and selects one with random weight for playback.
  33360. */
  33361. export class WeightedSound {
  33362. /** When true a Sound will be selected and played when the current playing Sound completes. */
  33363. loop: boolean;
  33364. private _coneInnerAngle;
  33365. private _coneOuterAngle;
  33366. private _volume;
  33367. /** A Sound is currently playing. */
  33368. isPlaying: boolean;
  33369. /** A Sound is currently paused. */
  33370. isPaused: boolean;
  33371. private _sounds;
  33372. private _weights;
  33373. private _currentIndex?;
  33374. /**
  33375. * Creates a new WeightedSound from the list of sounds given.
  33376. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  33377. * @param sounds Array of Sounds that will be selected from.
  33378. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  33379. */
  33380. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  33381. /**
  33382. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  33383. */
  33384. /**
  33385. * The size of cone in degress for a directional sound in which there will be no attenuation.
  33386. */
  33387. directionalConeInnerAngle: number;
  33388. /**
  33389. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33390. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33391. */
  33392. /**
  33393. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33394. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33395. */
  33396. directionalConeOuterAngle: number;
  33397. /**
  33398. * Playback volume.
  33399. */
  33400. /**
  33401. * Playback volume.
  33402. */
  33403. volume: number;
  33404. private _onended;
  33405. /**
  33406. * Suspend playback
  33407. */
  33408. pause(): void;
  33409. /**
  33410. * Stop playback
  33411. */
  33412. stop(): void;
  33413. /**
  33414. * Start playback.
  33415. * @param startOffset Position the clip head at a specific time in seconds.
  33416. */
  33417. play(startOffset?: number): void;
  33418. }
  33419. }
  33420. declare module BABYLON {
  33421. /**
  33422. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  33423. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  33424. */
  33425. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  33426. /**
  33427. * Gets the name of the behavior.
  33428. */
  33429. readonly name: string;
  33430. /**
  33431. * The easing function used by animations
  33432. */
  33433. static EasingFunction: BackEase;
  33434. /**
  33435. * The easing mode used by animations
  33436. */
  33437. static EasingMode: number;
  33438. /**
  33439. * The duration of the animation, in milliseconds
  33440. */
  33441. transitionDuration: number;
  33442. /**
  33443. * Length of the distance animated by the transition when lower radius is reached
  33444. */
  33445. lowerRadiusTransitionRange: number;
  33446. /**
  33447. * Length of the distance animated by the transition when upper radius is reached
  33448. */
  33449. upperRadiusTransitionRange: number;
  33450. private _autoTransitionRange;
  33451. /**
  33452. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33453. */
  33454. /**
  33455. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33456. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  33457. */
  33458. autoTransitionRange: boolean;
  33459. private _attachedCamera;
  33460. private _onAfterCheckInputsObserver;
  33461. private _onMeshTargetChangedObserver;
  33462. /**
  33463. * Initializes the behavior.
  33464. */
  33465. init(): void;
  33466. /**
  33467. * Attaches the behavior to its arc rotate camera.
  33468. * @param camera Defines the camera to attach the behavior to
  33469. */
  33470. attach(camera: ArcRotateCamera): void;
  33471. /**
  33472. * Detaches the behavior from its current arc rotate camera.
  33473. */
  33474. detach(): void;
  33475. private _radiusIsAnimating;
  33476. private _radiusBounceTransition;
  33477. private _animatables;
  33478. private _cachedWheelPrecision;
  33479. /**
  33480. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  33481. * @param radiusLimit The limit to check against.
  33482. * @return Bool to indicate if at limit.
  33483. */
  33484. private _isRadiusAtLimit;
  33485. /**
  33486. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  33487. * @param radiusDelta The delta by which to animate to. Can be negative.
  33488. */
  33489. private _applyBoundRadiusAnimation;
  33490. /**
  33491. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  33492. */
  33493. protected _clearAnimationLocks(): void;
  33494. /**
  33495. * Stops and removes all animations that have been applied to the camera
  33496. */
  33497. stopAllAnimations(): void;
  33498. }
  33499. }
  33500. declare module BABYLON {
  33501. /**
  33502. * The framing behavior (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.
  33503. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  33504. */
  33505. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  33506. /**
  33507. * Gets the name of the behavior.
  33508. */
  33509. readonly name: string;
  33510. private _mode;
  33511. private _radiusScale;
  33512. private _positionScale;
  33513. private _defaultElevation;
  33514. private _elevationReturnTime;
  33515. private _elevationReturnWaitTime;
  33516. private _zoomStopsAnimation;
  33517. private _framingTime;
  33518. /**
  33519. * The easing function used by animations
  33520. */
  33521. static EasingFunction: ExponentialEase;
  33522. /**
  33523. * The easing mode used by animations
  33524. */
  33525. static EasingMode: number;
  33526. /**
  33527. * Sets the current mode used by the behavior
  33528. */
  33529. /**
  33530. * Gets current mode used by the behavior.
  33531. */
  33532. mode: number;
  33533. /**
  33534. * Sets the scale applied to the radius (1 by default)
  33535. */
  33536. /**
  33537. * Gets the scale applied to the radius
  33538. */
  33539. radiusScale: number;
  33540. /**
  33541. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33542. */
  33543. /**
  33544. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33545. */
  33546. positionScale: number;
  33547. /**
  33548. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33549. * behaviour is triggered, in radians.
  33550. */
  33551. /**
  33552. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33553. * behaviour is triggered, in radians.
  33554. */
  33555. defaultElevation: number;
  33556. /**
  33557. * Sets the time (in milliseconds) taken to return to the default beta position.
  33558. * Negative value indicates camera should not return to default.
  33559. */
  33560. /**
  33561. * Gets the time (in milliseconds) taken to return to the default beta position.
  33562. * Negative value indicates camera should not return to default.
  33563. */
  33564. elevationReturnTime: number;
  33565. /**
  33566. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33567. */
  33568. /**
  33569. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33570. */
  33571. elevationReturnWaitTime: number;
  33572. /**
  33573. * Sets the flag that indicates if user zooming should stop animation.
  33574. */
  33575. /**
  33576. * Gets the flag that indicates if user zooming should stop animation.
  33577. */
  33578. zoomStopsAnimation: boolean;
  33579. /**
  33580. * Sets the transition time when framing the mesh, in milliseconds
  33581. */
  33582. /**
  33583. * Gets the transition time when framing the mesh, in milliseconds
  33584. */
  33585. framingTime: number;
  33586. /**
  33587. * Define if the behavior should automatically change the configured
  33588. * camera limits and sensibilities.
  33589. */
  33590. autoCorrectCameraLimitsAndSensibility: boolean;
  33591. private _onPrePointerObservableObserver;
  33592. private _onAfterCheckInputsObserver;
  33593. private _onMeshTargetChangedObserver;
  33594. private _attachedCamera;
  33595. private _isPointerDown;
  33596. private _lastInteractionTime;
  33597. /**
  33598. * Initializes the behavior.
  33599. */
  33600. init(): void;
  33601. /**
  33602. * Attaches the behavior to its arc rotate camera.
  33603. * @param camera Defines the camera to attach the behavior to
  33604. */
  33605. attach(camera: ArcRotateCamera): void;
  33606. /**
  33607. * Detaches the behavior from its current arc rotate camera.
  33608. */
  33609. detach(): void;
  33610. private _animatables;
  33611. private _betaIsAnimating;
  33612. private _betaTransition;
  33613. private _radiusTransition;
  33614. private _vectorTransition;
  33615. /**
  33616. * Targets the given mesh and updates zoom level accordingly.
  33617. * @param mesh The mesh to target.
  33618. * @param radius Optional. If a cached radius position already exists, overrides default.
  33619. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33620. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33621. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33622. */
  33623. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33624. /**
  33625. * Targets the given mesh with its children and updates zoom level accordingly.
  33626. * @param mesh The mesh to target.
  33627. * @param radius Optional. If a cached radius position already exists, overrides default.
  33628. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33629. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33630. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33631. */
  33632. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33633. /**
  33634. * Targets the given meshes with their children and updates zoom level accordingly.
  33635. * @param meshes The mesh to target.
  33636. * @param radius Optional. If a cached radius position already exists, overrides default.
  33637. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33638. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33639. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33640. */
  33641. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33642. /**
  33643. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  33644. * @param minimumWorld Determines the smaller position of the bounding box extend
  33645. * @param maximumWorld Determines the bigger position of the bounding box extend
  33646. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33647. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33648. */
  33649. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33650. /**
  33651. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  33652. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  33653. * frustum width.
  33654. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  33655. * to fully enclose the mesh in the viewing frustum.
  33656. */
  33657. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  33658. /**
  33659. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  33660. * is automatically returned to its default position (expected to be above ground plane).
  33661. */
  33662. private _maintainCameraAboveGround;
  33663. /**
  33664. * Returns the frustum slope based on the canvas ratio and camera FOV
  33665. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  33666. */
  33667. private _getFrustumSlope;
  33668. /**
  33669. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  33670. */
  33671. private _clearAnimationLocks;
  33672. /**
  33673. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  33674. */
  33675. private _applyUserInteraction;
  33676. /**
  33677. * Stops and removes all animations that have been applied to the camera
  33678. */
  33679. stopAllAnimations(): void;
  33680. /**
  33681. * Gets a value indicating if the user is moving the camera
  33682. */
  33683. readonly isUserIsMoving: boolean;
  33684. /**
  33685. * The camera can move all the way towards the mesh.
  33686. */
  33687. static IgnoreBoundsSizeMode: number;
  33688. /**
  33689. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  33690. */
  33691. static FitFrustumSidesMode: number;
  33692. }
  33693. }
  33694. declare module BABYLON {
  33695. /**
  33696. * Manage the pointers inputs to control an arc rotate camera.
  33697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33698. */
  33699. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  33700. /**
  33701. * Defines the camera the input is attached to.
  33702. */
  33703. camera: ArcRotateCamera;
  33704. /**
  33705. * Defines the buttons associated with the input to handle camera move.
  33706. */
  33707. buttons: number[];
  33708. /**
  33709. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  33710. */
  33711. angularSensibilityX: number;
  33712. /**
  33713. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  33714. */
  33715. angularSensibilityY: number;
  33716. /**
  33717. * Defines the pointer pinch precision or how fast is the camera zooming.
  33718. */
  33719. pinchPrecision: number;
  33720. /**
  33721. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  33722. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  33723. */
  33724. pinchDeltaPercentage: number;
  33725. /**
  33726. * Defines the pointer panning sensibility or how fast is the camera moving.
  33727. */
  33728. panningSensibility: number;
  33729. /**
  33730. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  33731. */
  33732. multiTouchPanning: boolean;
  33733. /**
  33734. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  33735. */
  33736. multiTouchPanAndZoom: boolean;
  33737. /**
  33738. * Revers pinch action direction.
  33739. */
  33740. pinchInwards: boolean;
  33741. private _isPanClick;
  33742. private _pointerInput;
  33743. private _observer;
  33744. private _onMouseMove;
  33745. private _onGestureStart;
  33746. private _onGesture;
  33747. private _MSGestureHandler;
  33748. private _onLostFocus;
  33749. private _onContextMenu;
  33750. /**
  33751. * Attach the input controls to a specific dom element to get the input from.
  33752. * @param element Defines the element the controls should be listened from
  33753. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33754. */
  33755. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33756. /**
  33757. * Detach the current controls from the specified dom element.
  33758. * @param element Defines the element to stop listening the inputs from
  33759. */
  33760. detachControl(element: Nullable<HTMLElement>): void;
  33761. /**
  33762. * Gets the class name of the current intput.
  33763. * @returns the class name
  33764. */
  33765. getClassName(): string;
  33766. /**
  33767. * Get the friendly name associated with the input class.
  33768. * @returns the input friendly name
  33769. */
  33770. getSimpleName(): string;
  33771. }
  33772. }
  33773. declare module BABYLON {
  33774. /**
  33775. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  33776. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33777. */
  33778. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  33779. /**
  33780. * Defines the camera the input is attached to.
  33781. */
  33782. camera: ArcRotateCamera;
  33783. /**
  33784. * Defines the list of key codes associated with the up action (increase alpha)
  33785. */
  33786. keysUp: number[];
  33787. /**
  33788. * Defines the list of key codes associated with the down action (decrease alpha)
  33789. */
  33790. keysDown: number[];
  33791. /**
  33792. * Defines the list of key codes associated with the left action (increase beta)
  33793. */
  33794. keysLeft: number[];
  33795. /**
  33796. * Defines the list of key codes associated with the right action (decrease beta)
  33797. */
  33798. keysRight: number[];
  33799. /**
  33800. * Defines the list of key codes associated with the reset action.
  33801. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  33802. */
  33803. keysReset: number[];
  33804. /**
  33805. * Defines the panning sensibility of the inputs.
  33806. * (How fast is the camera paning)
  33807. */
  33808. panningSensibility: number;
  33809. /**
  33810. * Defines the zooming sensibility of the inputs.
  33811. * (How fast is the camera zooming)
  33812. */
  33813. zoomingSensibility: number;
  33814. /**
  33815. * Defines wether maintaining the alt key down switch the movement mode from
  33816. * orientation to zoom.
  33817. */
  33818. useAltToZoom: boolean;
  33819. /**
  33820. * Rotation speed of the camera
  33821. */
  33822. angularSpeed: number;
  33823. private _keys;
  33824. private _ctrlPressed;
  33825. private _altPressed;
  33826. private _onCanvasBlurObserver;
  33827. private _onKeyboardObserver;
  33828. private _engine;
  33829. private _scene;
  33830. /**
  33831. * Attach the input controls to a specific dom element to get the input from.
  33832. * @param element Defines the element the controls should be listened from
  33833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33834. */
  33835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33836. /**
  33837. * Detach the current controls from the specified dom element.
  33838. * @param element Defines the element to stop listening the inputs from
  33839. */
  33840. detachControl(element: Nullable<HTMLElement>): void;
  33841. /**
  33842. * Update the current camera state depending on the inputs that have been used this frame.
  33843. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  33844. */
  33845. checkInputs(): void;
  33846. /**
  33847. * Gets the class name of the current intput.
  33848. * @returns the class name
  33849. */
  33850. getClassName(): string;
  33851. /**
  33852. * Get the friendly name associated with the input class.
  33853. * @returns the input friendly name
  33854. */
  33855. getSimpleName(): string;
  33856. }
  33857. }
  33858. declare module BABYLON {
  33859. /**
  33860. * Manage the mouse wheel inputs to control an arc rotate camera.
  33861. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33862. */
  33863. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  33864. /**
  33865. * Defines the camera the input is attached to.
  33866. */
  33867. camera: ArcRotateCamera;
  33868. /**
  33869. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  33870. */
  33871. wheelPrecision: number;
  33872. /**
  33873. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  33874. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  33875. */
  33876. wheelDeltaPercentage: number;
  33877. private _wheel;
  33878. private _observer;
  33879. /**
  33880. * Attach the input controls to a specific dom element to get the input from.
  33881. * @param element Defines the element the controls should be listened from
  33882. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33883. */
  33884. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33885. /**
  33886. * Detach the current controls from the specified dom element.
  33887. * @param element Defines the element to stop listening the inputs from
  33888. */
  33889. detachControl(element: Nullable<HTMLElement>): void;
  33890. /**
  33891. * Gets the class name of the current intput.
  33892. * @returns the class name
  33893. */
  33894. getClassName(): string;
  33895. /**
  33896. * Get the friendly name associated with the input class.
  33897. * @returns the input friendly name
  33898. */
  33899. getSimpleName(): string;
  33900. }
  33901. }
  33902. declare module BABYLON {
  33903. /**
  33904. * Default Inputs manager for the ArcRotateCamera.
  33905. * It groups all the default supported inputs for ease of use.
  33906. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33907. */
  33908. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  33909. /**
  33910. * Instantiates a new ArcRotateCameraInputsManager.
  33911. * @param camera Defines the camera the inputs belong to
  33912. */
  33913. constructor(camera: ArcRotateCamera);
  33914. /**
  33915. * Add mouse wheel input support to the input manager.
  33916. * @returns the current input manager
  33917. */
  33918. addMouseWheel(): ArcRotateCameraInputsManager;
  33919. /**
  33920. * Add pointers input support to the input manager.
  33921. * @returns the current input manager
  33922. */
  33923. addPointers(): ArcRotateCameraInputsManager;
  33924. /**
  33925. * Add keyboard input support to the input manager.
  33926. * @returns the current input manager
  33927. */
  33928. addKeyboard(): ArcRotateCameraInputsManager;
  33929. }
  33930. }
  33931. declare module BABYLON {
  33932. /**
  33933. * This represents an orbital type of camera.
  33934. *
  33935. * 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.
  33936. * 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.
  33937. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  33938. */
  33939. export class ArcRotateCamera extends TargetCamera {
  33940. /**
  33941. * Defines the rotation angle of the camera along the longitudinal axis.
  33942. */
  33943. alpha: number;
  33944. /**
  33945. * Defines the rotation angle of the camera along the latitudinal axis.
  33946. */
  33947. beta: number;
  33948. /**
  33949. * Defines the radius of the camera from it s target point.
  33950. */
  33951. radius: number;
  33952. protected _target: Vector3;
  33953. protected _targetHost: Nullable<AbstractMesh>;
  33954. /**
  33955. * Defines the target point of the camera.
  33956. * The camera looks towards it form the radius distance.
  33957. */
  33958. target: Vector3;
  33959. /**
  33960. * Current inertia value on the longitudinal axis.
  33961. * The bigger this number the longer it will take for the camera to stop.
  33962. */
  33963. inertialAlphaOffset: number;
  33964. /**
  33965. * Current inertia value on the latitudinal axis.
  33966. * The bigger this number the longer it will take for the camera to stop.
  33967. */
  33968. inertialBetaOffset: number;
  33969. /**
  33970. * Current inertia value on the radius axis.
  33971. * The bigger this number the longer it will take for the camera to stop.
  33972. */
  33973. inertialRadiusOffset: number;
  33974. /**
  33975. * Minimum allowed angle on the longitudinal axis.
  33976. * This can help limiting how the Camera is able to move in the scene.
  33977. */
  33978. lowerAlphaLimit: Nullable<number>;
  33979. /**
  33980. * Maximum allowed angle on the longitudinal axis.
  33981. * This can help limiting how the Camera is able to move in the scene.
  33982. */
  33983. upperAlphaLimit: Nullable<number>;
  33984. /**
  33985. * Minimum allowed angle on the latitudinal axis.
  33986. * This can help limiting how the Camera is able to move in the scene.
  33987. */
  33988. lowerBetaLimit: number;
  33989. /**
  33990. * Maximum allowed angle on the latitudinal axis.
  33991. * This can help limiting how the Camera is able to move in the scene.
  33992. */
  33993. upperBetaLimit: number;
  33994. /**
  33995. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  33996. * This can help limiting how the Camera is able to move in the scene.
  33997. */
  33998. lowerRadiusLimit: Nullable<number>;
  33999. /**
  34000. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34001. * This can help limiting how the Camera is able to move in the scene.
  34002. */
  34003. upperRadiusLimit: Nullable<number>;
  34004. /**
  34005. * Defines the current inertia value used during panning of the camera along the X axis.
  34006. */
  34007. inertialPanningX: number;
  34008. /**
  34009. * Defines the current inertia value used during panning of the camera along the Y axis.
  34010. */
  34011. inertialPanningY: number;
  34012. /**
  34013. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34014. * Basically if your fingers moves away from more than this distance you will be considered
  34015. * in pinch mode.
  34016. */
  34017. pinchToPanMaxDistance: number;
  34018. /**
  34019. * Defines the maximum distance the camera can pan.
  34020. * This could help keeping the cammera always in your scene.
  34021. */
  34022. panningDistanceLimit: Nullable<number>;
  34023. /**
  34024. * Defines the target of the camera before paning.
  34025. */
  34026. panningOriginTarget: Vector3;
  34027. /**
  34028. * Defines the value of the inertia used during panning.
  34029. * 0 would mean stop inertia and one would mean no decelleration at all.
  34030. */
  34031. panningInertia: number;
  34032. /**
  34033. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34034. */
  34035. angularSensibilityX: number;
  34036. /**
  34037. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34038. */
  34039. angularSensibilityY: number;
  34040. /**
  34041. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34042. */
  34043. pinchPrecision: number;
  34044. /**
  34045. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34046. * It will be used instead of pinchDeltaPrecision if different from 0.
  34047. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34048. */
  34049. pinchDeltaPercentage: number;
  34050. /**
  34051. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34052. */
  34053. panningSensibility: number;
  34054. /**
  34055. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34056. */
  34057. keysUp: number[];
  34058. /**
  34059. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34060. */
  34061. keysDown: number[];
  34062. /**
  34063. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34064. */
  34065. keysLeft: number[];
  34066. /**
  34067. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34068. */
  34069. keysRight: number[];
  34070. /**
  34071. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34072. */
  34073. wheelPrecision: number;
  34074. /**
  34075. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34076. * It will be used instead of pinchDeltaPrecision if different from 0.
  34077. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34078. */
  34079. wheelDeltaPercentage: number;
  34080. /**
  34081. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34082. */
  34083. zoomOnFactor: number;
  34084. /**
  34085. * Defines a screen offset for the camera position.
  34086. */
  34087. targetScreenOffset: Vector2;
  34088. /**
  34089. * Allows the camera to be completely reversed.
  34090. * If false the camera can not arrive upside down.
  34091. */
  34092. allowUpsideDown: boolean;
  34093. /**
  34094. * Define if double tap/click is used to restore the previously saved state of the camera.
  34095. */
  34096. useInputToRestoreState: boolean;
  34097. /** @hidden */
  34098. _viewMatrix: Matrix;
  34099. /** @hidden */
  34100. _useCtrlForPanning: boolean;
  34101. /** @hidden */
  34102. _panningMouseButton: number;
  34103. /**
  34104. * Defines the input associated to the camera.
  34105. */
  34106. inputs: ArcRotateCameraInputsManager;
  34107. /** @hidden */
  34108. _reset: () => void;
  34109. /**
  34110. * Defines the allowed panning axis.
  34111. */
  34112. panningAxis: Vector3;
  34113. protected _localDirection: Vector3;
  34114. protected _transformedDirection: Vector3;
  34115. private _bouncingBehavior;
  34116. /**
  34117. * Gets the bouncing behavior of the camera if it has been enabled.
  34118. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34119. */
  34120. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  34121. /**
  34122. * Defines if the bouncing behavior of the camera is enabled on the camera.
  34123. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34124. */
  34125. useBouncingBehavior: boolean;
  34126. private _framingBehavior;
  34127. /**
  34128. * Gets the framing behavior of the camera if it has been enabled.
  34129. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34130. */
  34131. readonly framingBehavior: Nullable<FramingBehavior>;
  34132. /**
  34133. * Defines if the framing behavior of the camera is enabled on the camera.
  34134. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34135. */
  34136. useFramingBehavior: boolean;
  34137. private _autoRotationBehavior;
  34138. /**
  34139. * Gets the auto rotation behavior of the camera if it has been enabled.
  34140. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34141. */
  34142. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  34143. /**
  34144. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  34145. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34146. */
  34147. useAutoRotationBehavior: boolean;
  34148. /**
  34149. * Observable triggered when the mesh target has been changed on the camera.
  34150. */
  34151. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  34152. /**
  34153. * Event raised when the camera is colliding with a mesh.
  34154. */
  34155. onCollide: (collidedMesh: AbstractMesh) => void;
  34156. /**
  34157. * Defines whether the camera should check collision with the objects oh the scene.
  34158. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  34159. */
  34160. checkCollisions: boolean;
  34161. /**
  34162. * Defines the collision radius of the camera.
  34163. * This simulates a sphere around the camera.
  34164. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  34165. */
  34166. collisionRadius: Vector3;
  34167. protected _collider: Collider;
  34168. protected _previousPosition: Vector3;
  34169. protected _collisionVelocity: Vector3;
  34170. protected _newPosition: Vector3;
  34171. protected _previousAlpha: number;
  34172. protected _previousBeta: number;
  34173. protected _previousRadius: number;
  34174. protected _collisionTriggered: boolean;
  34175. protected _targetBoundingCenter: Nullable<Vector3>;
  34176. private _computationVector;
  34177. private _tempAxisVector;
  34178. private _tempAxisRotationMatrix;
  34179. /**
  34180. * Instantiates a new ArcRotateCamera in a given scene
  34181. * @param name Defines the name of the camera
  34182. * @param alpha Defines the camera rotation along the logitudinal axis
  34183. * @param beta Defines the camera rotation along the latitudinal axis
  34184. * @param radius Defines the camera distance from its target
  34185. * @param target Defines the camera target
  34186. * @param scene Defines the scene the camera belongs to
  34187. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  34188. */
  34189. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34190. /** @hidden */
  34191. _initCache(): void;
  34192. /** @hidden */
  34193. _updateCache(ignoreParentClass?: boolean): void;
  34194. protected _getTargetPosition(): Vector3;
  34195. private _storedAlpha;
  34196. private _storedBeta;
  34197. private _storedRadius;
  34198. private _storedTarget;
  34199. /**
  34200. * Stores the current state of the camera (alpha, beta, radius and target)
  34201. * @returns the camera itself
  34202. */
  34203. storeState(): Camera;
  34204. /**
  34205. * @hidden
  34206. * Restored camera state. You must call storeState() first
  34207. */
  34208. _restoreStateValues(): boolean;
  34209. /** @hidden */
  34210. _isSynchronizedViewMatrix(): boolean;
  34211. /**
  34212. * Attached controls to the current camera.
  34213. * @param element Defines the element the controls should be listened from
  34214. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34215. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  34216. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  34217. */
  34218. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  34219. /**
  34220. * Detach the current controls from the camera.
  34221. * The camera will stop reacting to inputs.
  34222. * @param element Defines the element to stop listening the inputs from
  34223. */
  34224. detachControl(element: HTMLElement): void;
  34225. /** @hidden */
  34226. _checkInputs(): void;
  34227. protected _checkLimits(): void;
  34228. /**
  34229. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  34230. */
  34231. rebuildAnglesAndRadius(): void;
  34232. /**
  34233. * Use a position to define the current camera related information like aplha, beta and radius
  34234. * @param position Defines the position to set the camera at
  34235. */
  34236. setPosition(position: Vector3): void;
  34237. /**
  34238. * Defines the target the camera should look at.
  34239. * This will automatically adapt alpha beta and radius to fit within the new target.
  34240. * @param target Defines the new target as a Vector or a mesh
  34241. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  34242. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  34243. */
  34244. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  34245. /** @hidden */
  34246. _getViewMatrix(): Matrix;
  34247. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  34248. /**
  34249. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  34250. * @param meshes Defines the mesh to zoom on
  34251. * @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)
  34252. */
  34253. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  34254. /**
  34255. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  34256. * The target will be changed but the radius
  34257. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  34258. * @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)
  34259. */
  34260. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  34261. min: Vector3;
  34262. max: Vector3;
  34263. distance: number;
  34264. }, doNotUpdateMaxZ?: boolean): void;
  34265. /**
  34266. * @override
  34267. * Override Camera.createRigCamera
  34268. */
  34269. createRigCamera(name: string, cameraIndex: number): Camera;
  34270. /**
  34271. * @hidden
  34272. * @override
  34273. * Override Camera._updateRigCameras
  34274. */
  34275. _updateRigCameras(): void;
  34276. /**
  34277. * Destroy the camera and release the current resources hold by it.
  34278. */
  34279. dispose(): void;
  34280. /**
  34281. * Gets the current object class name.
  34282. * @return the class name
  34283. */
  34284. getClassName(): string;
  34285. }
  34286. }
  34287. declare module BABYLON {
  34288. /**
  34289. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  34290. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34291. */
  34292. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  34293. /**
  34294. * Gets the name of the behavior.
  34295. */
  34296. readonly name: string;
  34297. private _zoomStopsAnimation;
  34298. private _idleRotationSpeed;
  34299. private _idleRotationWaitTime;
  34300. private _idleRotationSpinupTime;
  34301. /**
  34302. * Sets the flag that indicates if user zooming should stop animation.
  34303. */
  34304. /**
  34305. * Gets the flag that indicates if user zooming should stop animation.
  34306. */
  34307. zoomStopsAnimation: boolean;
  34308. /**
  34309. * Sets the default speed at which the camera rotates around the model.
  34310. */
  34311. /**
  34312. * Gets the default speed at which the camera rotates around the model.
  34313. */
  34314. idleRotationSpeed: number;
  34315. /**
  34316. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  34317. */
  34318. /**
  34319. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  34320. */
  34321. idleRotationWaitTime: number;
  34322. /**
  34323. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34324. */
  34325. /**
  34326. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34327. */
  34328. idleRotationSpinupTime: number;
  34329. /**
  34330. * Gets a value indicating if the camera is currently rotating because of this behavior
  34331. */
  34332. readonly rotationInProgress: boolean;
  34333. private _onPrePointerObservableObserver;
  34334. private _onAfterCheckInputsObserver;
  34335. private _attachedCamera;
  34336. private _isPointerDown;
  34337. private _lastFrameTime;
  34338. private _lastInteractionTime;
  34339. private _cameraRotationSpeed;
  34340. /**
  34341. * Initializes the behavior.
  34342. */
  34343. init(): void;
  34344. /**
  34345. * Attaches the behavior to its arc rotate camera.
  34346. * @param camera Defines the camera to attach the behavior to
  34347. */
  34348. attach(camera: ArcRotateCamera): void;
  34349. /**
  34350. * Detaches the behavior from its current arc rotate camera.
  34351. */
  34352. detach(): void;
  34353. /**
  34354. * Returns true if user is scrolling.
  34355. * @return true if user is scrolling.
  34356. */
  34357. private _userIsZooming;
  34358. private _lastFrameRadius;
  34359. private _shouldAnimationStopForInteraction;
  34360. /**
  34361. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34362. */
  34363. private _applyUserInteraction;
  34364. private _userIsMoving;
  34365. }
  34366. }
  34367. declare module BABYLON {
  34368. /**
  34369. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  34370. */
  34371. export class AttachToBoxBehavior implements Behavior<Mesh> {
  34372. private ui;
  34373. /**
  34374. * The name of the behavior
  34375. */
  34376. name: string;
  34377. /**
  34378. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  34379. */
  34380. distanceAwayFromFace: number;
  34381. /**
  34382. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  34383. */
  34384. distanceAwayFromBottomOfFace: number;
  34385. private _faceVectors;
  34386. private _target;
  34387. private _scene;
  34388. private _onRenderObserver;
  34389. private _tmpMatrix;
  34390. private _tmpVector;
  34391. /**
  34392. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  34393. * @param ui The transform node that should be attched to the mesh
  34394. */
  34395. constructor(ui: TransformNode);
  34396. /**
  34397. * Initializes the behavior
  34398. */
  34399. init(): void;
  34400. private _closestFace;
  34401. private _zeroVector;
  34402. private _lookAtTmpMatrix;
  34403. private _lookAtToRef;
  34404. /**
  34405. * Attaches the AttachToBoxBehavior to the passed in mesh
  34406. * @param target The mesh that the specified node will be attached to
  34407. */
  34408. attach(target: Mesh): void;
  34409. /**
  34410. * Detaches the behavior from the mesh
  34411. */
  34412. detach(): void;
  34413. }
  34414. }
  34415. declare module BABYLON {
  34416. /**
  34417. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  34418. */
  34419. export class FadeInOutBehavior implements Behavior<Mesh> {
  34420. /**
  34421. * Time in milliseconds to delay before fading in (Default: 0)
  34422. */
  34423. delay: number;
  34424. /**
  34425. * Time in milliseconds for the mesh to fade in (Default: 300)
  34426. */
  34427. fadeInTime: number;
  34428. private _millisecondsPerFrame;
  34429. private _hovered;
  34430. private _hoverValue;
  34431. private _ownerNode;
  34432. /**
  34433. * Instatiates the FadeInOutBehavior
  34434. */
  34435. constructor();
  34436. /**
  34437. * The name of the behavior
  34438. */
  34439. readonly name: string;
  34440. /**
  34441. * Initializes the behavior
  34442. */
  34443. init(): void;
  34444. /**
  34445. * Attaches the fade behavior on the passed in mesh
  34446. * @param ownerNode The mesh that will be faded in/out once attached
  34447. */
  34448. attach(ownerNode: Mesh): void;
  34449. /**
  34450. * Detaches the behavior from the mesh
  34451. */
  34452. detach(): void;
  34453. /**
  34454. * Triggers the mesh to begin fading in or out
  34455. * @param value if the object should fade in or out (true to fade in)
  34456. */
  34457. fadeIn(value: boolean): void;
  34458. private _update;
  34459. private _setAllVisibility;
  34460. }
  34461. }
  34462. declare module BABYLON {
  34463. /**
  34464. * Class containing a set of static utilities functions for managing Pivots
  34465. * @hidden
  34466. */
  34467. export class PivotTools {
  34468. private static _PivotCached;
  34469. private static _OldPivotPoint;
  34470. private static _PivotTranslation;
  34471. private static _PivotTmpVector;
  34472. /** @hidden */
  34473. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  34474. /** @hidden */
  34475. static _RestorePivotPoint(mesh: AbstractMesh): void;
  34476. }
  34477. }
  34478. declare module BABYLON {
  34479. /**
  34480. * Class containing static functions to help procedurally build meshes
  34481. */
  34482. export class PlaneBuilder {
  34483. /**
  34484. * Creates a plane mesh
  34485. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  34486. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  34487. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  34488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34489. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34491. * @param name defines the name of the mesh
  34492. * @param options defines the options used to create the mesh
  34493. * @param scene defines the hosting scene
  34494. * @returns the plane mesh
  34495. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  34496. */
  34497. static CreatePlane(name: string, options: {
  34498. size?: number;
  34499. width?: number;
  34500. height?: number;
  34501. sideOrientation?: number;
  34502. frontUVs?: Vector4;
  34503. backUVs?: Vector4;
  34504. updatable?: boolean;
  34505. sourcePlane?: Plane;
  34506. }, scene: Scene): Mesh;
  34507. }
  34508. }
  34509. declare module BABYLON {
  34510. /**
  34511. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  34512. */
  34513. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  34514. private static _AnyMouseID;
  34515. private _attachedNode;
  34516. private _dragPlane;
  34517. private _scene;
  34518. private _pointerObserver;
  34519. private _beforeRenderObserver;
  34520. private static _planeScene;
  34521. /**
  34522. * 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)
  34523. */
  34524. maxDragAngle: number;
  34525. /**
  34526. * @hidden
  34527. */
  34528. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  34529. /**
  34530. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  34531. */
  34532. currentDraggingPointerID: number;
  34533. /**
  34534. * The last position where the pointer hit the drag plane in world space
  34535. */
  34536. lastDragPosition: Vector3;
  34537. /**
  34538. * If the behavior is currently in a dragging state
  34539. */
  34540. dragging: boolean;
  34541. /**
  34542. * 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)
  34543. */
  34544. dragDeltaRatio: number;
  34545. /**
  34546. * If the drag plane orientation should be updated during the dragging (Default: true)
  34547. */
  34548. updateDragPlane: boolean;
  34549. private _debugMode;
  34550. private _moving;
  34551. /**
  34552. * Fires each time the attached mesh is dragged with the pointer
  34553. * * delta between last drag position and current drag position in world space
  34554. * * dragDistance along the drag axis
  34555. * * dragPlaneNormal normal of the current drag plane used during the drag
  34556. * * dragPlanePoint in world space where the drag intersects the drag plane
  34557. */
  34558. onDragObservable: Observable<{
  34559. delta: Vector3;
  34560. dragPlanePoint: Vector3;
  34561. dragPlaneNormal: Vector3;
  34562. dragDistance: number;
  34563. pointerId: number;
  34564. }>;
  34565. /**
  34566. * Fires each time a drag begins (eg. mouse down on mesh)
  34567. */
  34568. onDragStartObservable: Observable<{
  34569. dragPlanePoint: Vector3;
  34570. pointerId: number;
  34571. }>;
  34572. /**
  34573. * Fires each time a drag ends (eg. mouse release after drag)
  34574. */
  34575. onDragEndObservable: Observable<{
  34576. dragPlanePoint: Vector3;
  34577. pointerId: number;
  34578. }>;
  34579. /**
  34580. * If the attached mesh should be moved when dragged
  34581. */
  34582. moveAttached: boolean;
  34583. /**
  34584. * If the drag behavior will react to drag events (Default: true)
  34585. */
  34586. enabled: boolean;
  34587. /**
  34588. * If camera controls should be detached during the drag
  34589. */
  34590. detachCameraControls: boolean;
  34591. /**
  34592. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  34593. */
  34594. useObjectOrienationForDragging: boolean;
  34595. private _options;
  34596. /**
  34597. * Creates a pointer drag behavior that can be attached to a mesh
  34598. * @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)
  34599. */
  34600. constructor(options?: {
  34601. dragAxis?: Vector3;
  34602. dragPlaneNormal?: Vector3;
  34603. });
  34604. /**
  34605. * Predicate to determine if it is valid to move the object to a new position when it is moved
  34606. */
  34607. validateDrag: (targetPosition: Vector3) => boolean;
  34608. /**
  34609. * The name of the behavior
  34610. */
  34611. readonly name: string;
  34612. /**
  34613. * Initializes the behavior
  34614. */
  34615. init(): void;
  34616. private _tmpVector;
  34617. private _alternatePickedPoint;
  34618. private _worldDragAxis;
  34619. private _targetPosition;
  34620. private _attachedElement;
  34621. /**
  34622. * Attaches the drag behavior the passed in mesh
  34623. * @param ownerNode The mesh that will be dragged around once attached
  34624. */
  34625. attach(ownerNode: AbstractMesh): void;
  34626. /**
  34627. * Force relase the drag action by code.
  34628. */
  34629. releaseDrag(): void;
  34630. private _startDragRay;
  34631. private _lastPointerRay;
  34632. /**
  34633. * Simulates the start of a pointer drag event on the behavior
  34634. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  34635. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  34636. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  34637. */
  34638. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  34639. private _startDrag;
  34640. private _dragDelta;
  34641. private _moveDrag;
  34642. private _pickWithRayOnDragPlane;
  34643. private _pointA;
  34644. private _pointB;
  34645. private _pointC;
  34646. private _lineA;
  34647. private _lineB;
  34648. private _localAxis;
  34649. private _lookAt;
  34650. private _updateDragPlanePosition;
  34651. /**
  34652. * Detaches the behavior from the mesh
  34653. */
  34654. detach(): void;
  34655. }
  34656. }
  34657. declare module BABYLON {
  34658. /**
  34659. * A behavior that when attached to a mesh will allow the mesh to be scaled
  34660. */
  34661. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  34662. private _dragBehaviorA;
  34663. private _dragBehaviorB;
  34664. private _startDistance;
  34665. private _initialScale;
  34666. private _targetScale;
  34667. private _ownerNode;
  34668. private _sceneRenderObserver;
  34669. /**
  34670. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  34671. */
  34672. constructor();
  34673. /**
  34674. * The name of the behavior
  34675. */
  34676. readonly name: string;
  34677. /**
  34678. * Initializes the behavior
  34679. */
  34680. init(): void;
  34681. private _getCurrentDistance;
  34682. /**
  34683. * Attaches the scale behavior the passed in mesh
  34684. * @param ownerNode The mesh that will be scaled around once attached
  34685. */
  34686. attach(ownerNode: Mesh): void;
  34687. /**
  34688. * Detaches the behavior from the mesh
  34689. */
  34690. detach(): void;
  34691. }
  34692. }
  34693. declare module BABYLON {
  34694. /**
  34695. * 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
  34696. */
  34697. export class SixDofDragBehavior implements Behavior<Mesh> {
  34698. private static _virtualScene;
  34699. private _ownerNode;
  34700. private _sceneRenderObserver;
  34701. private _scene;
  34702. private _targetPosition;
  34703. private _virtualOriginMesh;
  34704. private _virtualDragMesh;
  34705. private _pointerObserver;
  34706. private _moving;
  34707. private _startingOrientation;
  34708. /**
  34709. * 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)
  34710. */
  34711. private zDragFactor;
  34712. /**
  34713. * If the object should rotate to face the drag origin
  34714. */
  34715. rotateDraggedObject: boolean;
  34716. /**
  34717. * If the behavior is currently in a dragging state
  34718. */
  34719. dragging: boolean;
  34720. /**
  34721. * 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)
  34722. */
  34723. dragDeltaRatio: number;
  34724. /**
  34725. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  34726. */
  34727. currentDraggingPointerID: number;
  34728. /**
  34729. * If camera controls should be detached during the drag
  34730. */
  34731. detachCameraControls: boolean;
  34732. /**
  34733. * Fires each time a drag starts
  34734. */
  34735. onDragStartObservable: Observable<{}>;
  34736. /**
  34737. * Fires each time a drag ends (eg. mouse release after drag)
  34738. */
  34739. onDragEndObservable: Observable<{}>;
  34740. /**
  34741. * 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
  34742. */
  34743. constructor();
  34744. /**
  34745. * The name of the behavior
  34746. */
  34747. readonly name: string;
  34748. /**
  34749. * Initializes the behavior
  34750. */
  34751. init(): void;
  34752. /**
  34753. * Attaches the scale behavior the passed in mesh
  34754. * @param ownerNode The mesh that will be scaled around once attached
  34755. */
  34756. attach(ownerNode: Mesh): void;
  34757. /**
  34758. * Detaches the behavior from the mesh
  34759. */
  34760. detach(): void;
  34761. }
  34762. }
  34763. declare module BABYLON {
  34764. /**
  34765. * Class used to apply inverse kinematics to bones
  34766. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  34767. */
  34768. export class BoneIKController {
  34769. private static _tmpVecs;
  34770. private static _tmpQuat;
  34771. private static _tmpMats;
  34772. /**
  34773. * Gets or sets the target mesh
  34774. */
  34775. targetMesh: AbstractMesh;
  34776. /** Gets or sets the mesh used as pole */
  34777. poleTargetMesh: AbstractMesh;
  34778. /**
  34779. * Gets or sets the bone used as pole
  34780. */
  34781. poleTargetBone: Nullable<Bone>;
  34782. /**
  34783. * Gets or sets the target position
  34784. */
  34785. targetPosition: Vector3;
  34786. /**
  34787. * Gets or sets the pole target position
  34788. */
  34789. poleTargetPosition: Vector3;
  34790. /**
  34791. * Gets or sets the pole target local offset
  34792. */
  34793. poleTargetLocalOffset: Vector3;
  34794. /**
  34795. * Gets or sets the pole angle
  34796. */
  34797. poleAngle: number;
  34798. /**
  34799. * Gets or sets the mesh associated with the controller
  34800. */
  34801. mesh: AbstractMesh;
  34802. /**
  34803. * 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)
  34804. */
  34805. slerpAmount: number;
  34806. private _bone1Quat;
  34807. private _bone1Mat;
  34808. private _bone2Ang;
  34809. private _bone1;
  34810. private _bone2;
  34811. private _bone1Length;
  34812. private _bone2Length;
  34813. private _maxAngle;
  34814. private _maxReach;
  34815. private _rightHandedSystem;
  34816. private _bendAxis;
  34817. private _slerping;
  34818. private _adjustRoll;
  34819. /**
  34820. * Gets or sets maximum allowed angle
  34821. */
  34822. maxAngle: number;
  34823. /**
  34824. * Creates a new BoneIKController
  34825. * @param mesh defines the mesh to control
  34826. * @param bone defines the bone to control
  34827. * @param options defines options to set up the controller
  34828. */
  34829. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  34830. targetMesh?: AbstractMesh;
  34831. poleTargetMesh?: AbstractMesh;
  34832. poleTargetBone?: Bone;
  34833. poleTargetLocalOffset?: Vector3;
  34834. poleAngle?: number;
  34835. bendAxis?: Vector3;
  34836. maxAngle?: number;
  34837. slerpAmount?: number;
  34838. });
  34839. private _setMaxAngle;
  34840. /**
  34841. * Force the controller to update the bones
  34842. */
  34843. update(): void;
  34844. }
  34845. }
  34846. declare module BABYLON {
  34847. /**
  34848. * Class used to make a bone look toward a point in space
  34849. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  34850. */
  34851. export class BoneLookController {
  34852. private static _tmpVecs;
  34853. private static _tmpQuat;
  34854. private static _tmpMats;
  34855. /**
  34856. * The target Vector3 that the bone will look at
  34857. */
  34858. target: Vector3;
  34859. /**
  34860. * The mesh that the bone is attached to
  34861. */
  34862. mesh: AbstractMesh;
  34863. /**
  34864. * The bone that will be looking to the target
  34865. */
  34866. bone: Bone;
  34867. /**
  34868. * The up axis of the coordinate system that is used when the bone is rotated
  34869. */
  34870. upAxis: Vector3;
  34871. /**
  34872. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  34873. */
  34874. upAxisSpace: Space;
  34875. /**
  34876. * Used to make an adjustment to the yaw of the bone
  34877. */
  34878. adjustYaw: number;
  34879. /**
  34880. * Used to make an adjustment to the pitch of the bone
  34881. */
  34882. adjustPitch: number;
  34883. /**
  34884. * Used to make an adjustment to the roll of the bone
  34885. */
  34886. adjustRoll: number;
  34887. /**
  34888. * 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)
  34889. */
  34890. slerpAmount: number;
  34891. private _minYaw;
  34892. private _maxYaw;
  34893. private _minPitch;
  34894. private _maxPitch;
  34895. private _minYawSin;
  34896. private _minYawCos;
  34897. private _maxYawSin;
  34898. private _maxYawCos;
  34899. private _midYawConstraint;
  34900. private _minPitchTan;
  34901. private _maxPitchTan;
  34902. private _boneQuat;
  34903. private _slerping;
  34904. private _transformYawPitch;
  34905. private _transformYawPitchInv;
  34906. private _firstFrameSkipped;
  34907. private _yawRange;
  34908. private _fowardAxis;
  34909. /**
  34910. * Gets or sets the minimum yaw angle that the bone can look to
  34911. */
  34912. minYaw: number;
  34913. /**
  34914. * Gets or sets the maximum yaw angle that the bone can look to
  34915. */
  34916. maxYaw: number;
  34917. /**
  34918. * Gets or sets the minimum pitch angle that the bone can look to
  34919. */
  34920. minPitch: number;
  34921. /**
  34922. * Gets or sets the maximum pitch angle that the bone can look to
  34923. */
  34924. maxPitch: number;
  34925. /**
  34926. * Create a BoneLookController
  34927. * @param mesh the mesh that the bone belongs to
  34928. * @param bone the bone that will be looking to the target
  34929. * @param target the target Vector3 to look at
  34930. * @param options optional settings:
  34931. * * maxYaw: the maximum angle the bone will yaw to
  34932. * * minYaw: the minimum angle the bone will yaw to
  34933. * * maxPitch: the maximum angle the bone will pitch to
  34934. * * minPitch: the minimum angle the bone will yaw to
  34935. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  34936. * * upAxis: the up axis of the coordinate system
  34937. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  34938. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  34939. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  34940. * * adjustYaw: used to make an adjustment to the yaw of the bone
  34941. * * adjustPitch: used to make an adjustment to the pitch of the bone
  34942. * * adjustRoll: used to make an adjustment to the roll of the bone
  34943. **/
  34944. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  34945. maxYaw?: number;
  34946. minYaw?: number;
  34947. maxPitch?: number;
  34948. minPitch?: number;
  34949. slerpAmount?: number;
  34950. upAxis?: Vector3;
  34951. upAxisSpace?: Space;
  34952. yawAxis?: Vector3;
  34953. pitchAxis?: Vector3;
  34954. adjustYaw?: number;
  34955. adjustPitch?: number;
  34956. adjustRoll?: number;
  34957. });
  34958. /**
  34959. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  34960. */
  34961. update(): void;
  34962. private _getAngleDiff;
  34963. private _getAngleBetween;
  34964. private _isAngleBetween;
  34965. }
  34966. }
  34967. declare module BABYLON {
  34968. /**
  34969. * Manage the gamepad inputs to control an arc rotate camera.
  34970. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34971. */
  34972. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  34973. /**
  34974. * Defines the camera the input is attached to.
  34975. */
  34976. camera: ArcRotateCamera;
  34977. /**
  34978. * Defines the gamepad the input is gathering event from.
  34979. */
  34980. gamepad: Nullable<Gamepad>;
  34981. /**
  34982. * Defines the gamepad rotation sensiblity.
  34983. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  34984. */
  34985. gamepadRotationSensibility: number;
  34986. /**
  34987. * Defines the gamepad move sensiblity.
  34988. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  34989. */
  34990. gamepadMoveSensibility: number;
  34991. private _onGamepadConnectedObserver;
  34992. private _onGamepadDisconnectedObserver;
  34993. /**
  34994. * Attach the input controls to a specific dom element to get the input from.
  34995. * @param element Defines the element the controls should be listened from
  34996. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34997. */
  34998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34999. /**
  35000. * Detach the current controls from the specified dom element.
  35001. * @param element Defines the element to stop listening the inputs from
  35002. */
  35003. detachControl(element: Nullable<HTMLElement>): void;
  35004. /**
  35005. * Update the current camera state depending on the inputs that have been used this frame.
  35006. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35007. */
  35008. checkInputs(): void;
  35009. /**
  35010. * Gets the class name of the current intput.
  35011. * @returns the class name
  35012. */
  35013. getClassName(): string;
  35014. /**
  35015. * Get the friendly name associated with the input class.
  35016. * @returns the input friendly name
  35017. */
  35018. getSimpleName(): string;
  35019. }
  35020. }
  35021. declare module BABYLON {
  35022. interface ArcRotateCameraInputsManager {
  35023. /**
  35024. * Add orientation input support to the input manager.
  35025. * @returns the current input manager
  35026. */
  35027. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35028. }
  35029. /**
  35030. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35031. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35032. */
  35033. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35034. /**
  35035. * Defines the camera the input is attached to.
  35036. */
  35037. camera: ArcRotateCamera;
  35038. /**
  35039. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  35040. */
  35041. alphaCorrection: number;
  35042. /**
  35043. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  35044. */
  35045. gammaCorrection: number;
  35046. private _alpha;
  35047. private _gamma;
  35048. private _dirty;
  35049. private _deviceOrientationHandler;
  35050. /**
  35051. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  35052. */
  35053. constructor();
  35054. /**
  35055. * Attach the input controls to a specific dom element to get the input from.
  35056. * @param element Defines the element the controls should be listened from
  35057. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35058. */
  35059. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35060. /** @hidden */
  35061. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  35062. /**
  35063. * Update the current camera state depending on the inputs that have been used this frame.
  35064. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35065. */
  35066. checkInputs(): void;
  35067. /**
  35068. * Detach the current controls from the specified dom element.
  35069. * @param element Defines the element to stop listening the inputs from
  35070. */
  35071. detachControl(element: Nullable<HTMLElement>): void;
  35072. /**
  35073. * Gets the class name of the current intput.
  35074. * @returns the class name
  35075. */
  35076. getClassName(): string;
  35077. /**
  35078. * Get the friendly name associated with the input class.
  35079. * @returns the input friendly name
  35080. */
  35081. getSimpleName(): string;
  35082. }
  35083. }
  35084. declare module BABYLON {
  35085. /**
  35086. * Listen to mouse events to control the camera.
  35087. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35088. */
  35089. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  35090. /**
  35091. * Defines the camera the input is attached to.
  35092. */
  35093. camera: FlyCamera;
  35094. /**
  35095. * Defines if touch is enabled. (Default is true.)
  35096. */
  35097. touchEnabled: boolean;
  35098. /**
  35099. * Defines the buttons associated with the input to handle camera rotation.
  35100. */
  35101. buttons: number[];
  35102. /**
  35103. * Assign buttons for Yaw control.
  35104. */
  35105. buttonsYaw: number[];
  35106. /**
  35107. * Assign buttons for Pitch control.
  35108. */
  35109. buttonsPitch: number[];
  35110. /**
  35111. * Assign buttons for Roll control.
  35112. */
  35113. buttonsRoll: number[];
  35114. /**
  35115. * Detect if any button is being pressed while mouse is moved.
  35116. * -1 = Mouse locked.
  35117. * 0 = Left button.
  35118. * 1 = Middle Button.
  35119. * 2 = Right Button.
  35120. */
  35121. activeButton: number;
  35122. /**
  35123. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  35124. * Higher values reduce its sensitivity.
  35125. */
  35126. angularSensibility: number;
  35127. private _mousemoveCallback;
  35128. private _observer;
  35129. private _rollObserver;
  35130. private previousPosition;
  35131. private noPreventDefault;
  35132. private element;
  35133. /**
  35134. * Listen to mouse events to control the camera.
  35135. * @param touchEnabled Define if touch is enabled. (Default is true.)
  35136. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35137. */
  35138. constructor(touchEnabled?: boolean);
  35139. /**
  35140. * Attach the mouse control to the HTML DOM element.
  35141. * @param element Defines the element that listens to the input events.
  35142. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  35143. */
  35144. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35145. /**
  35146. * Detach the current controls from the specified dom element.
  35147. * @param element Defines the element to stop listening the inputs from
  35148. */
  35149. detachControl(element: Nullable<HTMLElement>): void;
  35150. /**
  35151. * Gets the class name of the current input.
  35152. * @returns the class name.
  35153. */
  35154. getClassName(): string;
  35155. /**
  35156. * Get the friendly name associated with the input class.
  35157. * @returns the input's friendly name.
  35158. */
  35159. getSimpleName(): string;
  35160. private _pointerInput;
  35161. private _onMouseMove;
  35162. /**
  35163. * Rotate camera by mouse offset.
  35164. */
  35165. private rotateCamera;
  35166. }
  35167. }
  35168. declare module BABYLON {
  35169. /**
  35170. * Default Inputs manager for the FlyCamera.
  35171. * It groups all the default supported inputs for ease of use.
  35172. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35173. */
  35174. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  35175. /**
  35176. * Instantiates a new FlyCameraInputsManager.
  35177. * @param camera Defines the camera the inputs belong to.
  35178. */
  35179. constructor(camera: FlyCamera);
  35180. /**
  35181. * Add keyboard input support to the input manager.
  35182. * @returns the new FlyCameraKeyboardMoveInput().
  35183. */
  35184. addKeyboard(): FlyCameraInputsManager;
  35185. /**
  35186. * Add mouse input support to the input manager.
  35187. * @param touchEnabled Enable touch screen support.
  35188. * @returns the new FlyCameraMouseInput().
  35189. */
  35190. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  35191. }
  35192. }
  35193. declare module BABYLON {
  35194. /**
  35195. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35196. * such as in a 3D Space Shooter or a Flight Simulator.
  35197. */
  35198. export class FlyCamera extends TargetCamera {
  35199. /**
  35200. * Define the collision ellipsoid of the camera.
  35201. * This is helpful for simulating a camera body, like a player's body.
  35202. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35203. */
  35204. ellipsoid: Vector3;
  35205. /**
  35206. * Define an offset for the position of the ellipsoid around the camera.
  35207. * This can be helpful if the camera is attached away from the player's body center,
  35208. * such as at its head.
  35209. */
  35210. ellipsoidOffset: Vector3;
  35211. /**
  35212. * Enable or disable collisions of the camera with the rest of the scene objects.
  35213. */
  35214. checkCollisions: boolean;
  35215. /**
  35216. * Enable or disable gravity on the camera.
  35217. */
  35218. applyGravity: boolean;
  35219. /**
  35220. * Define the current direction the camera is moving to.
  35221. */
  35222. cameraDirection: Vector3;
  35223. /**
  35224. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  35225. * This overrides and empties cameraRotation.
  35226. */
  35227. rotationQuaternion: Quaternion;
  35228. /**
  35229. * Track Roll to maintain the wanted Rolling when looking around.
  35230. */
  35231. _trackRoll: number;
  35232. /**
  35233. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  35234. */
  35235. rollCorrect: number;
  35236. /**
  35237. * Mimic a banked turn, Rolling the camera when Yawing.
  35238. * It's recommended to use rollCorrect = 10 for faster banking correction.
  35239. */
  35240. bankedTurn: boolean;
  35241. /**
  35242. * Limit in radians for how much Roll banking will add. (Default: 90°)
  35243. */
  35244. bankedTurnLimit: number;
  35245. /**
  35246. * Value of 0 disables the banked Roll.
  35247. * Value of 1 is equal to the Yaw angle in radians.
  35248. */
  35249. bankedTurnMultiplier: number;
  35250. /**
  35251. * The inputs manager loads all the input sources, such as keyboard and mouse.
  35252. */
  35253. inputs: FlyCameraInputsManager;
  35254. /**
  35255. * Gets the input sensibility for mouse input.
  35256. * Higher values reduce sensitivity.
  35257. */
  35258. /**
  35259. * Sets the input sensibility for a mouse input.
  35260. * Higher values reduce sensitivity.
  35261. */
  35262. angularSensibility: number;
  35263. /**
  35264. * Get the keys for camera movement forward.
  35265. */
  35266. /**
  35267. * Set the keys for camera movement forward.
  35268. */
  35269. keysForward: number[];
  35270. /**
  35271. * Get the keys for camera movement backward.
  35272. */
  35273. keysBackward: number[];
  35274. /**
  35275. * Get the keys for camera movement up.
  35276. */
  35277. /**
  35278. * Set the keys for camera movement up.
  35279. */
  35280. keysUp: number[];
  35281. /**
  35282. * Get the keys for camera movement down.
  35283. */
  35284. /**
  35285. * Set the keys for camera movement down.
  35286. */
  35287. keysDown: number[];
  35288. /**
  35289. * Get the keys for camera movement left.
  35290. */
  35291. /**
  35292. * Set the keys for camera movement left.
  35293. */
  35294. keysLeft: number[];
  35295. /**
  35296. * Set the keys for camera movement right.
  35297. */
  35298. /**
  35299. * Set the keys for camera movement right.
  35300. */
  35301. keysRight: number[];
  35302. /**
  35303. * Event raised when the camera collides with a mesh in the scene.
  35304. */
  35305. onCollide: (collidedMesh: AbstractMesh) => void;
  35306. private _collider;
  35307. private _needMoveForGravity;
  35308. private _oldPosition;
  35309. private _diffPosition;
  35310. private _newPosition;
  35311. /** @hidden */
  35312. _localDirection: Vector3;
  35313. /** @hidden */
  35314. _transformedDirection: Vector3;
  35315. /**
  35316. * Instantiates a FlyCamera.
  35317. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35318. * such as in a 3D Space Shooter or a Flight Simulator.
  35319. * @param name Define the name of the camera in the scene.
  35320. * @param position Define the starting position of the camera in the scene.
  35321. * @param scene Define the scene the camera belongs to.
  35322. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  35323. */
  35324. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35325. /**
  35326. * Attach a control to the HTML DOM element.
  35327. * @param element Defines the element that listens to the input events.
  35328. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  35329. */
  35330. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35331. /**
  35332. * Detach a control from the HTML DOM element.
  35333. * The camera will stop reacting to that input.
  35334. * @param element Defines the element that listens to the input events.
  35335. */
  35336. detachControl(element: HTMLElement): void;
  35337. private _collisionMask;
  35338. /**
  35339. * Get the mask that the camera ignores in collision events.
  35340. */
  35341. /**
  35342. * Set the mask that the camera ignores in collision events.
  35343. */
  35344. collisionMask: number;
  35345. /** @hidden */
  35346. _collideWithWorld(displacement: Vector3): void;
  35347. /** @hidden */
  35348. private _onCollisionPositionChange;
  35349. /** @hidden */
  35350. _checkInputs(): void;
  35351. /** @hidden */
  35352. _decideIfNeedsToMove(): boolean;
  35353. /** @hidden */
  35354. _updatePosition(): void;
  35355. /**
  35356. * Restore the Roll to its target value at the rate specified.
  35357. * @param rate - Higher means slower restoring.
  35358. * @hidden
  35359. */
  35360. restoreRoll(rate: number): void;
  35361. /**
  35362. * Destroy the camera and release the current resources held by it.
  35363. */
  35364. dispose(): void;
  35365. /**
  35366. * Get the current object class name.
  35367. * @returns the class name.
  35368. */
  35369. getClassName(): string;
  35370. }
  35371. }
  35372. declare module BABYLON {
  35373. /**
  35374. * Listen to keyboard events to control the camera.
  35375. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35376. */
  35377. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  35378. /**
  35379. * Defines the camera the input is attached to.
  35380. */
  35381. camera: FlyCamera;
  35382. /**
  35383. * The list of keyboard keys used to control the forward move of the camera.
  35384. */
  35385. keysForward: number[];
  35386. /**
  35387. * The list of keyboard keys used to control the backward move of the camera.
  35388. */
  35389. keysBackward: number[];
  35390. /**
  35391. * The list of keyboard keys used to control the forward move of the camera.
  35392. */
  35393. keysUp: number[];
  35394. /**
  35395. * The list of keyboard keys used to control the backward move of the camera.
  35396. */
  35397. keysDown: number[];
  35398. /**
  35399. * The list of keyboard keys used to control the right strafe move of the camera.
  35400. */
  35401. keysRight: number[];
  35402. /**
  35403. * The list of keyboard keys used to control the left strafe move of the camera.
  35404. */
  35405. keysLeft: number[];
  35406. private _keys;
  35407. private _onCanvasBlurObserver;
  35408. private _onKeyboardObserver;
  35409. private _engine;
  35410. private _scene;
  35411. /**
  35412. * Attach the input controls to a specific dom element to get the input from.
  35413. * @param element Defines the element the controls should be listened from
  35414. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35415. */
  35416. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35417. /**
  35418. * Detach the current controls from the specified dom element.
  35419. * @param element Defines the element to stop listening the inputs from
  35420. */
  35421. detachControl(element: Nullable<HTMLElement>): void;
  35422. /**
  35423. * Gets the class name of the current intput.
  35424. * @returns the class name
  35425. */
  35426. getClassName(): string;
  35427. /** @hidden */
  35428. _onLostFocus(e: FocusEvent): void;
  35429. /**
  35430. * Get the friendly name associated with the input class.
  35431. * @returns the input friendly name
  35432. */
  35433. getSimpleName(): string;
  35434. /**
  35435. * Update the current camera state depending on the inputs that have been used this frame.
  35436. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35437. */
  35438. checkInputs(): void;
  35439. }
  35440. }
  35441. declare module BABYLON {
  35442. interface FreeCameraInputsManager {
  35443. /**
  35444. * Add orientation input support to the input manager.
  35445. * @returns the current input manager
  35446. */
  35447. addDeviceOrientation(): FreeCameraInputsManager;
  35448. }
  35449. /**
  35450. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  35451. * Screen rotation is taken into account.
  35452. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35453. */
  35454. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  35455. private _camera;
  35456. private _screenOrientationAngle;
  35457. private _constantTranform;
  35458. private _screenQuaternion;
  35459. private _alpha;
  35460. private _beta;
  35461. private _gamma;
  35462. /**
  35463. * Instantiates a new input
  35464. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35465. */
  35466. constructor();
  35467. /**
  35468. * Define the camera controlled by the input.
  35469. */
  35470. camera: FreeCamera;
  35471. /**
  35472. * Attach the input controls to a specific dom element to get the input from.
  35473. * @param element Defines the element the controls should be listened from
  35474. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35475. */
  35476. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35477. private _orientationChanged;
  35478. private _deviceOrientation;
  35479. /**
  35480. * Detach the current controls from the specified dom element.
  35481. * @param element Defines the element to stop listening the inputs from
  35482. */
  35483. detachControl(element: Nullable<HTMLElement>): void;
  35484. /**
  35485. * Update the current camera state depending on the inputs that have been used this frame.
  35486. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35487. */
  35488. checkInputs(): void;
  35489. /**
  35490. * Gets the class name of the current intput.
  35491. * @returns the class name
  35492. */
  35493. getClassName(): string;
  35494. /**
  35495. * Get the friendly name associated with the input class.
  35496. * @returns the input friendly name
  35497. */
  35498. getSimpleName(): string;
  35499. }
  35500. }
  35501. declare module BABYLON {
  35502. /**
  35503. * Manage the gamepad inputs to control a free camera.
  35504. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35505. */
  35506. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  35507. /**
  35508. * Define the camera the input is attached to.
  35509. */
  35510. camera: FreeCamera;
  35511. /**
  35512. * Define the Gamepad controlling the input
  35513. */
  35514. gamepad: Nullable<Gamepad>;
  35515. /**
  35516. * Defines the gamepad rotation sensiblity.
  35517. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35518. */
  35519. gamepadAngularSensibility: number;
  35520. /**
  35521. * Defines the gamepad move sensiblity.
  35522. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35523. */
  35524. gamepadMoveSensibility: number;
  35525. private _onGamepadConnectedObserver;
  35526. private _onGamepadDisconnectedObserver;
  35527. private _cameraTransform;
  35528. private _deltaTransform;
  35529. private _vector3;
  35530. private _vector2;
  35531. /**
  35532. * Attach the input controls to a specific dom element to get the input from.
  35533. * @param element Defines the element the controls should be listened from
  35534. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35535. */
  35536. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35537. /**
  35538. * Detach the current controls from the specified dom element.
  35539. * @param element Defines the element to stop listening the inputs from
  35540. */
  35541. detachControl(element: Nullable<HTMLElement>): void;
  35542. /**
  35543. * Update the current camera state depending on the inputs that have been used this frame.
  35544. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35545. */
  35546. checkInputs(): void;
  35547. /**
  35548. * Gets the class name of the current intput.
  35549. * @returns the class name
  35550. */
  35551. getClassName(): string;
  35552. /**
  35553. * Get the friendly name associated with the input class.
  35554. * @returns the input friendly name
  35555. */
  35556. getSimpleName(): string;
  35557. }
  35558. }
  35559. declare module BABYLON {
  35560. /**
  35561. * Defines the potential axis of a Joystick
  35562. */
  35563. export enum JoystickAxis {
  35564. /** X axis */
  35565. X = 0,
  35566. /** Y axis */
  35567. Y = 1,
  35568. /** Z axis */
  35569. Z = 2
  35570. }
  35571. /**
  35572. * Class used to define virtual joystick (used in touch mode)
  35573. */
  35574. export class VirtualJoystick {
  35575. /**
  35576. * Gets or sets a boolean indicating that left and right values must be inverted
  35577. */
  35578. reverseLeftRight: boolean;
  35579. /**
  35580. * Gets or sets a boolean indicating that up and down values must be inverted
  35581. */
  35582. reverseUpDown: boolean;
  35583. /**
  35584. * Gets the offset value for the position (ie. the change of the position value)
  35585. */
  35586. deltaPosition: Vector3;
  35587. /**
  35588. * Gets a boolean indicating if the virtual joystick was pressed
  35589. */
  35590. pressed: boolean;
  35591. /**
  35592. * Canvas the virtual joystick will render onto, default z-index of this is 5
  35593. */
  35594. static Canvas: Nullable<HTMLCanvasElement>;
  35595. private static _globalJoystickIndex;
  35596. private static vjCanvasContext;
  35597. private static vjCanvasWidth;
  35598. private static vjCanvasHeight;
  35599. private static halfWidth;
  35600. private _action;
  35601. private _axisTargetedByLeftAndRight;
  35602. private _axisTargetedByUpAndDown;
  35603. private _joystickSensibility;
  35604. private _inversedSensibility;
  35605. private _joystickPointerID;
  35606. private _joystickColor;
  35607. private _joystickPointerPos;
  35608. private _joystickPreviousPointerPos;
  35609. private _joystickPointerStartPos;
  35610. private _deltaJoystickVector;
  35611. private _leftJoystick;
  35612. private _touches;
  35613. private _onPointerDownHandlerRef;
  35614. private _onPointerMoveHandlerRef;
  35615. private _onPointerUpHandlerRef;
  35616. private _onResize;
  35617. /**
  35618. * Creates a new virtual joystick
  35619. * @param leftJoystick defines that the joystick is for left hand (false by default)
  35620. */
  35621. constructor(leftJoystick?: boolean);
  35622. /**
  35623. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  35624. * @param newJoystickSensibility defines the new sensibility
  35625. */
  35626. setJoystickSensibility(newJoystickSensibility: number): void;
  35627. private _onPointerDown;
  35628. private _onPointerMove;
  35629. private _onPointerUp;
  35630. /**
  35631. * Change the color of the virtual joystick
  35632. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  35633. */
  35634. setJoystickColor(newColor: string): void;
  35635. /**
  35636. * Defines a callback to call when the joystick is touched
  35637. * @param action defines the callback
  35638. */
  35639. setActionOnTouch(action: () => any): void;
  35640. /**
  35641. * Defines which axis you'd like to control for left & right
  35642. * @param axis defines the axis to use
  35643. */
  35644. setAxisForLeftRight(axis: JoystickAxis): void;
  35645. /**
  35646. * Defines which axis you'd like to control for up & down
  35647. * @param axis defines the axis to use
  35648. */
  35649. setAxisForUpDown(axis: JoystickAxis): void;
  35650. private _drawVirtualJoystick;
  35651. /**
  35652. * Release internal HTML canvas
  35653. */
  35654. releaseCanvas(): void;
  35655. }
  35656. }
  35657. declare module BABYLON {
  35658. interface FreeCameraInputsManager {
  35659. /**
  35660. * Add virtual joystick input support to the input manager.
  35661. * @returns the current input manager
  35662. */
  35663. addVirtualJoystick(): FreeCameraInputsManager;
  35664. }
  35665. /**
  35666. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  35667. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35668. */
  35669. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  35670. /**
  35671. * Defines the camera the input is attached to.
  35672. */
  35673. camera: FreeCamera;
  35674. private _leftjoystick;
  35675. private _rightjoystick;
  35676. /**
  35677. * Gets the left stick of the virtual joystick.
  35678. * @returns The virtual Joystick
  35679. */
  35680. getLeftJoystick(): VirtualJoystick;
  35681. /**
  35682. * Gets the right stick of the virtual joystick.
  35683. * @returns The virtual Joystick
  35684. */
  35685. getRightJoystick(): VirtualJoystick;
  35686. /**
  35687. * Update the current camera state depending on the inputs that have been used this frame.
  35688. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35689. */
  35690. checkInputs(): void;
  35691. /**
  35692. * Attach the input controls to a specific dom element to get the input from.
  35693. * @param element Defines the element the controls should be listened from
  35694. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35695. */
  35696. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35697. /**
  35698. * Detach the current controls from the specified dom element.
  35699. * @param element Defines the element to stop listening the inputs from
  35700. */
  35701. detachControl(element: Nullable<HTMLElement>): void;
  35702. /**
  35703. * Gets the class name of the current intput.
  35704. * @returns the class name
  35705. */
  35706. getClassName(): string;
  35707. /**
  35708. * Get the friendly name associated with the input class.
  35709. * @returns the input friendly name
  35710. */
  35711. getSimpleName(): string;
  35712. }
  35713. }
  35714. declare module BABYLON {
  35715. /**
  35716. * This represents a FPS type of camera controlled by touch.
  35717. * This is like a universal camera minus the Gamepad controls.
  35718. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35719. */
  35720. export class TouchCamera extends FreeCamera {
  35721. /**
  35722. * Defines the touch sensibility for rotation.
  35723. * The higher the faster.
  35724. */
  35725. touchAngularSensibility: number;
  35726. /**
  35727. * Defines the touch sensibility for move.
  35728. * The higher the faster.
  35729. */
  35730. touchMoveSensibility: number;
  35731. /**
  35732. * Instantiates a new touch camera.
  35733. * This represents a FPS type of camera controlled by touch.
  35734. * This is like a universal camera minus the Gamepad controls.
  35735. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35736. * @param name Define the name of the camera in the scene
  35737. * @param position Define the start position of the camera in the scene
  35738. * @param scene Define the scene the camera belongs to
  35739. */
  35740. constructor(name: string, position: Vector3, scene: Scene);
  35741. /**
  35742. * Gets the current object class name.
  35743. * @return the class name
  35744. */
  35745. getClassName(): string;
  35746. /** @hidden */
  35747. _setupInputs(): void;
  35748. }
  35749. }
  35750. declare module BABYLON {
  35751. /**
  35752. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  35753. * being tilted forward or back and left or right.
  35754. */
  35755. export class DeviceOrientationCamera extends FreeCamera {
  35756. private _initialQuaternion;
  35757. private _quaternionCache;
  35758. /**
  35759. * Creates a new device orientation camera
  35760. * @param name The name of the camera
  35761. * @param position The start position camera
  35762. * @param scene The scene the camera belongs to
  35763. */
  35764. constructor(name: string, position: Vector3, scene: Scene);
  35765. /**
  35766. * Gets the current instance class name ("DeviceOrientationCamera").
  35767. * This helps avoiding instanceof at run time.
  35768. * @returns the class name
  35769. */
  35770. getClassName(): string;
  35771. /**
  35772. * @hidden
  35773. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  35774. */
  35775. _checkInputs(): void;
  35776. /**
  35777. * Reset the camera to its default orientation on the specified axis only.
  35778. * @param axis The axis to reset
  35779. */
  35780. resetToCurrentRotation(axis?: Axis): void;
  35781. }
  35782. }
  35783. declare module BABYLON {
  35784. /**
  35785. * Manage the keyboard inputs to control the movement of a follow camera.
  35786. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35787. */
  35788. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  35789. /**
  35790. * Defines the camera the input is attached to.
  35791. */
  35792. camera: FollowCamera;
  35793. /**
  35794. * Defines the list of key codes associated with the up action (increase heightOffset)
  35795. */
  35796. keysHeightOffsetIncr: number[];
  35797. /**
  35798. * Defines the list of key codes associated with the down action (decrease heightOffset)
  35799. */
  35800. keysHeightOffsetDecr: number[];
  35801. /**
  35802. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  35803. */
  35804. keysHeightOffsetModifierAlt: boolean;
  35805. /**
  35806. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  35807. */
  35808. keysHeightOffsetModifierCtrl: boolean;
  35809. /**
  35810. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  35811. */
  35812. keysHeightOffsetModifierShift: boolean;
  35813. /**
  35814. * Defines the list of key codes associated with the left action (increase rotationOffset)
  35815. */
  35816. keysRotationOffsetIncr: number[];
  35817. /**
  35818. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  35819. */
  35820. keysRotationOffsetDecr: number[];
  35821. /**
  35822. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  35823. */
  35824. keysRotationOffsetModifierAlt: boolean;
  35825. /**
  35826. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  35827. */
  35828. keysRotationOffsetModifierCtrl: boolean;
  35829. /**
  35830. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  35831. */
  35832. keysRotationOffsetModifierShift: boolean;
  35833. /**
  35834. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  35835. */
  35836. keysRadiusIncr: number[];
  35837. /**
  35838. * Defines the list of key codes associated with the zoom-out action (increase radius)
  35839. */
  35840. keysRadiusDecr: number[];
  35841. /**
  35842. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  35843. */
  35844. keysRadiusModifierAlt: boolean;
  35845. /**
  35846. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  35847. */
  35848. keysRadiusModifierCtrl: boolean;
  35849. /**
  35850. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  35851. */
  35852. keysRadiusModifierShift: boolean;
  35853. /**
  35854. * Defines the rate of change of heightOffset.
  35855. */
  35856. heightSensibility: number;
  35857. /**
  35858. * Defines the rate of change of rotationOffset.
  35859. */
  35860. rotationSensibility: number;
  35861. /**
  35862. * Defines the rate of change of radius.
  35863. */
  35864. radiusSensibility: number;
  35865. private _keys;
  35866. private _ctrlPressed;
  35867. private _altPressed;
  35868. private _shiftPressed;
  35869. private _onCanvasBlurObserver;
  35870. private _onKeyboardObserver;
  35871. private _engine;
  35872. private _scene;
  35873. /**
  35874. * Attach the input controls to a specific dom element to get the input from.
  35875. * @param element Defines the element the controls should be listened from
  35876. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35877. */
  35878. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35879. /**
  35880. * Detach the current controls from the specified dom element.
  35881. * @param element Defines the element to stop listening the inputs from
  35882. */
  35883. detachControl(element: Nullable<HTMLElement>): void;
  35884. /**
  35885. * Update the current camera state depending on the inputs that have been used this frame.
  35886. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35887. */
  35888. checkInputs(): void;
  35889. /**
  35890. * Gets the class name of the current input.
  35891. * @returns the class name
  35892. */
  35893. getClassName(): string;
  35894. /**
  35895. * Get the friendly name associated with the input class.
  35896. * @returns the input friendly name
  35897. */
  35898. getSimpleName(): string;
  35899. /**
  35900. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  35901. * allow modification of the heightOffset value.
  35902. */
  35903. private _modifierHeightOffset;
  35904. /**
  35905. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  35906. * allow modification of the rotationOffset value.
  35907. */
  35908. private _modifierRotationOffset;
  35909. /**
  35910. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  35911. * allow modification of the radius value.
  35912. */
  35913. private _modifierRadius;
  35914. }
  35915. }
  35916. declare module BABYLON {
  35917. /**
  35918. * Manage the mouse wheel inputs to control a follow camera.
  35919. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35920. */
  35921. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  35922. /**
  35923. * Defines the camera the input is attached to.
  35924. */
  35925. camera: FollowCamera;
  35926. /**
  35927. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  35928. */
  35929. axisControlRadius: boolean;
  35930. /**
  35931. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  35932. */
  35933. axisControlHeight: boolean;
  35934. /**
  35935. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  35936. */
  35937. axisControlRotation: boolean;
  35938. /**
  35939. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  35940. * relation to mouseWheel events.
  35941. */
  35942. wheelPrecision: number;
  35943. /**
  35944. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35945. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35946. */
  35947. wheelDeltaPercentage: number;
  35948. private _wheel;
  35949. private _observer;
  35950. /**
  35951. * Attach the input controls to a specific dom element to get the input from.
  35952. * @param element Defines the element the controls should be listened from
  35953. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35954. */
  35955. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35956. /**
  35957. * Detach the current controls from the specified dom element.
  35958. * @param element Defines the element to stop listening the inputs from
  35959. */
  35960. detachControl(element: Nullable<HTMLElement>): void;
  35961. /**
  35962. * Gets the class name of the current intput.
  35963. * @returns the class name
  35964. */
  35965. getClassName(): string;
  35966. /**
  35967. * Get the friendly name associated with the input class.
  35968. * @returns the input friendly name
  35969. */
  35970. getSimpleName(): string;
  35971. }
  35972. }
  35973. declare module BABYLON {
  35974. /**
  35975. * Default Inputs manager for the FollowCamera.
  35976. * It groups all the default supported inputs for ease of use.
  35977. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35978. */
  35979. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  35980. /**
  35981. * Instantiates a new FollowCameraInputsManager.
  35982. * @param camera Defines the camera the inputs belong to
  35983. */
  35984. constructor(camera: FollowCamera);
  35985. /**
  35986. * Add keyboard input support to the input manager.
  35987. * @returns the current input manager
  35988. */
  35989. addKeyboard(): FollowCameraInputsManager;
  35990. /**
  35991. * Add mouse wheel input support to the input manager.
  35992. * @returns the current input manager
  35993. */
  35994. addMouseWheel(): FollowCameraInputsManager;
  35995. /**
  35996. * Add pointers input support to the input manager.
  35997. * @returns the current input manager
  35998. */
  35999. addPointers(): FollowCameraInputsManager;
  36000. /**
  36001. * Add orientation input support to the input manager.
  36002. * @returns the current input manager
  36003. */
  36004. addVRDeviceOrientation(): FollowCameraInputsManager;
  36005. }
  36006. }
  36007. declare module BABYLON {
  36008. /**
  36009. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36010. * an arc rotate version arcFollowCamera are available.
  36011. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36012. */
  36013. export class FollowCamera extends TargetCamera {
  36014. /**
  36015. * Distance the follow camera should follow an object at
  36016. */
  36017. radius: number;
  36018. /**
  36019. * Minimum allowed distance of the camera to the axis of rotation
  36020. * (The camera can not get closer).
  36021. * This can help limiting how the Camera is able to move in the scene.
  36022. */
  36023. lowerRadiusLimit: Nullable<number>;
  36024. /**
  36025. * Maximum allowed distance of the camera to the axis of rotation
  36026. * (The camera can not get further).
  36027. * This can help limiting how the Camera is able to move in the scene.
  36028. */
  36029. upperRadiusLimit: Nullable<number>;
  36030. /**
  36031. * Define a rotation offset between the camera and the object it follows
  36032. */
  36033. rotationOffset: number;
  36034. /**
  36035. * Minimum allowed angle to camera position relative to target object.
  36036. * This can help limiting how the Camera is able to move in the scene.
  36037. */
  36038. lowerRotationOffsetLimit: Nullable<number>;
  36039. /**
  36040. * Maximum allowed angle to camera position relative to target object.
  36041. * This can help limiting how the Camera is able to move in the scene.
  36042. */
  36043. upperRotationOffsetLimit: Nullable<number>;
  36044. /**
  36045. * Define a height offset between the camera and the object it follows.
  36046. * It can help following an object from the top (like a car chaing a plane)
  36047. */
  36048. heightOffset: number;
  36049. /**
  36050. * Minimum allowed height of camera position relative to target object.
  36051. * This can help limiting how the Camera is able to move in the scene.
  36052. */
  36053. lowerHeightOffsetLimit: Nullable<number>;
  36054. /**
  36055. * Maximum allowed height of camera position relative to target object.
  36056. * This can help limiting how the Camera is able to move in the scene.
  36057. */
  36058. upperHeightOffsetLimit: Nullable<number>;
  36059. /**
  36060. * Define how fast the camera can accelerate to follow it s target.
  36061. */
  36062. cameraAcceleration: number;
  36063. /**
  36064. * Define the speed limit of the camera following an object.
  36065. */
  36066. maxCameraSpeed: number;
  36067. /**
  36068. * Define the target of the camera.
  36069. */
  36070. lockedTarget: Nullable<AbstractMesh>;
  36071. /**
  36072. * Defines the input associated with the camera.
  36073. */
  36074. inputs: FollowCameraInputsManager;
  36075. /**
  36076. * Instantiates the follow camera.
  36077. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36078. * @param name Define the name of the camera in the scene
  36079. * @param position Define the position of the camera
  36080. * @param scene Define the scene the camera belong to
  36081. * @param lockedTarget Define the target of the camera
  36082. */
  36083. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36084. private _follow;
  36085. /**
  36086. * Attached controls to the current camera.
  36087. * @param element Defines the element the controls should be listened from
  36088. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36089. */
  36090. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36091. /**
  36092. * Detach the current controls from the camera.
  36093. * The camera will stop reacting to inputs.
  36094. * @param element Defines the element to stop listening the inputs from
  36095. */
  36096. detachControl(element: HTMLElement): void;
  36097. /** @hidden */
  36098. _checkInputs(): void;
  36099. private _checkLimits;
  36100. /**
  36101. * Gets the camera class name.
  36102. * @returns the class name
  36103. */
  36104. getClassName(): string;
  36105. }
  36106. /**
  36107. * Arc Rotate version of the follow camera.
  36108. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36109. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36110. */
  36111. export class ArcFollowCamera extends TargetCamera {
  36112. /** The longitudinal angle of the camera */
  36113. alpha: number;
  36114. /** The latitudinal angle of the camera */
  36115. beta: number;
  36116. /** The radius of the camera from its target */
  36117. radius: number;
  36118. /** Define the camera target (the messh it should follow) */
  36119. target: Nullable<AbstractMesh>;
  36120. private _cartesianCoordinates;
  36121. /**
  36122. * Instantiates a new ArcFollowCamera
  36123. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36124. * @param name Define the name of the camera
  36125. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36126. * @param beta Define the rotation angle of the camera around the elevation axis
  36127. * @param radius Define the radius of the camera from its target point
  36128. * @param target Define the target of the camera
  36129. * @param scene Define the scene the camera belongs to
  36130. */
  36131. constructor(name: string,
  36132. /** The longitudinal angle of the camera */
  36133. alpha: number,
  36134. /** The latitudinal angle of the camera */
  36135. beta: number,
  36136. /** The radius of the camera from its target */
  36137. radius: number,
  36138. /** Define the camera target (the messh it should follow) */
  36139. target: Nullable<AbstractMesh>, scene: Scene);
  36140. private _follow;
  36141. /** @hidden */
  36142. _checkInputs(): void;
  36143. /**
  36144. * Returns the class name of the object.
  36145. * It is mostly used internally for serialization purposes.
  36146. */
  36147. getClassName(): string;
  36148. }
  36149. }
  36150. declare module BABYLON {
  36151. /**
  36152. * 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,
  36153. * which still works and will still be found in many Playgrounds.
  36154. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36155. */
  36156. export class UniversalCamera extends TouchCamera {
  36157. /**
  36158. * Defines the gamepad rotation sensiblity.
  36159. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36160. */
  36161. gamepadAngularSensibility: number;
  36162. /**
  36163. * Defines the gamepad move sensiblity.
  36164. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36165. */
  36166. gamepadMoveSensibility: number;
  36167. /**
  36168. * 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,
  36169. * which still works and will still be found in many Playgrounds.
  36170. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36171. * @param name Define the name of the camera in the scene
  36172. * @param position Define the start position of the camera in the scene
  36173. * @param scene Define the scene the camera belongs to
  36174. */
  36175. constructor(name: string, position: Vector3, scene: Scene);
  36176. /**
  36177. * Gets the current object class name.
  36178. * @return the class name
  36179. */
  36180. getClassName(): string;
  36181. }
  36182. }
  36183. declare module BABYLON {
  36184. /**
  36185. * This represents a FPS type of camera. This is only here for back compat purpose.
  36186. * Please use the UniversalCamera instead as both are identical.
  36187. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36188. */
  36189. export class GamepadCamera extends UniversalCamera {
  36190. /**
  36191. * Instantiates a new Gamepad Camera
  36192. * This represents a FPS type of camera. This is only here for back compat purpose.
  36193. * Please use the UniversalCamera instead as both are identical.
  36194. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36195. * @param name Define the name of the camera in the scene
  36196. * @param position Define the start position of the camera in the scene
  36197. * @param scene Define the scene the camera belongs to
  36198. */
  36199. constructor(name: string, position: Vector3, scene: Scene);
  36200. /**
  36201. * Gets the current object class name.
  36202. * @return the class name
  36203. */
  36204. getClassName(): string;
  36205. }
  36206. }
  36207. declare module BABYLON {
  36208. /** @hidden */
  36209. export var passPixelShader: {
  36210. name: string;
  36211. shader: string;
  36212. };
  36213. }
  36214. declare module BABYLON {
  36215. /** @hidden */
  36216. export var passCubePixelShader: {
  36217. name: string;
  36218. shader: string;
  36219. };
  36220. }
  36221. declare module BABYLON {
  36222. /**
  36223. * PassPostProcess which produces an output the same as it's input
  36224. */
  36225. export class PassPostProcess extends PostProcess {
  36226. /**
  36227. * Creates the PassPostProcess
  36228. * @param name The name of the effect.
  36229. * @param options The required width/height ratio to downsize to before computing the render pass.
  36230. * @param camera The camera to apply the render pass to.
  36231. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36232. * @param engine The engine which the post process will be applied. (default: current engine)
  36233. * @param reusable If the post process can be reused on the same frame. (default: false)
  36234. * @param textureType The type of texture to be used when performing the post processing.
  36235. * @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)
  36236. */
  36237. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36238. }
  36239. /**
  36240. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  36241. */
  36242. export class PassCubePostProcess extends PostProcess {
  36243. private _face;
  36244. /**
  36245. * Gets or sets the cube face to display.
  36246. * * 0 is +X
  36247. * * 1 is -X
  36248. * * 2 is +Y
  36249. * * 3 is -Y
  36250. * * 4 is +Z
  36251. * * 5 is -Z
  36252. */
  36253. face: number;
  36254. /**
  36255. * Creates the PassCubePostProcess
  36256. * @param name The name of the effect.
  36257. * @param options The required width/height ratio to downsize to before computing the render pass.
  36258. * @param camera The camera to apply the render pass to.
  36259. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36260. * @param engine The engine which the post process will be applied. (default: current engine)
  36261. * @param reusable If the post process can be reused on the same frame. (default: false)
  36262. * @param textureType The type of texture to be used when performing the post processing.
  36263. * @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)
  36264. */
  36265. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36266. }
  36267. }
  36268. declare module BABYLON {
  36269. /** @hidden */
  36270. export var anaglyphPixelShader: {
  36271. name: string;
  36272. shader: string;
  36273. };
  36274. }
  36275. declare module BABYLON {
  36276. /**
  36277. * Postprocess used to generate anaglyphic rendering
  36278. */
  36279. export class AnaglyphPostProcess extends PostProcess {
  36280. private _passedProcess;
  36281. /**
  36282. * Creates a new AnaglyphPostProcess
  36283. * @param name defines postprocess name
  36284. * @param options defines creation options or target ratio scale
  36285. * @param rigCameras defines cameras using this postprocess
  36286. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  36287. * @param engine defines hosting engine
  36288. * @param reusable defines if the postprocess will be reused multiple times per frame
  36289. */
  36290. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  36291. }
  36292. }
  36293. declare module BABYLON {
  36294. /**
  36295. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  36296. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36297. */
  36298. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  36299. /**
  36300. * Creates a new AnaglyphArcRotateCamera
  36301. * @param name defines camera name
  36302. * @param alpha defines alpha angle (in radians)
  36303. * @param beta defines beta angle (in radians)
  36304. * @param radius defines radius
  36305. * @param target defines camera target
  36306. * @param interaxialDistance defines distance between each color axis
  36307. * @param scene defines the hosting scene
  36308. */
  36309. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  36310. /**
  36311. * Gets camera class name
  36312. * @returns AnaglyphArcRotateCamera
  36313. */
  36314. getClassName(): string;
  36315. }
  36316. }
  36317. declare module BABYLON {
  36318. /**
  36319. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  36320. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36321. */
  36322. export class AnaglyphFreeCamera extends FreeCamera {
  36323. /**
  36324. * Creates a new AnaglyphFreeCamera
  36325. * @param name defines camera name
  36326. * @param position defines initial position
  36327. * @param interaxialDistance defines distance between each color axis
  36328. * @param scene defines the hosting scene
  36329. */
  36330. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36331. /**
  36332. * Gets camera class name
  36333. * @returns AnaglyphFreeCamera
  36334. */
  36335. getClassName(): string;
  36336. }
  36337. }
  36338. declare module BABYLON {
  36339. /**
  36340. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  36341. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36342. */
  36343. export class AnaglyphGamepadCamera extends GamepadCamera {
  36344. /**
  36345. * Creates a new AnaglyphGamepadCamera
  36346. * @param name defines camera name
  36347. * @param position defines initial position
  36348. * @param interaxialDistance defines distance between each color axis
  36349. * @param scene defines the hosting scene
  36350. */
  36351. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36352. /**
  36353. * Gets camera class name
  36354. * @returns AnaglyphGamepadCamera
  36355. */
  36356. getClassName(): string;
  36357. }
  36358. }
  36359. declare module BABYLON {
  36360. /**
  36361. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  36362. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36363. */
  36364. export class AnaglyphUniversalCamera extends UniversalCamera {
  36365. /**
  36366. * Creates a new AnaglyphUniversalCamera
  36367. * @param name defines camera name
  36368. * @param position defines initial position
  36369. * @param interaxialDistance defines distance between each color axis
  36370. * @param scene defines the hosting scene
  36371. */
  36372. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36373. /**
  36374. * Gets camera class name
  36375. * @returns AnaglyphUniversalCamera
  36376. */
  36377. getClassName(): string;
  36378. }
  36379. }
  36380. declare module BABYLON {
  36381. /** @hidden */
  36382. export var stereoscopicInterlacePixelShader: {
  36383. name: string;
  36384. shader: string;
  36385. };
  36386. }
  36387. declare module BABYLON {
  36388. /**
  36389. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  36390. */
  36391. export class StereoscopicInterlacePostProcess extends PostProcess {
  36392. private _stepSize;
  36393. private _passedProcess;
  36394. /**
  36395. * Initializes a StereoscopicInterlacePostProcess
  36396. * @param name The name of the effect.
  36397. * @param rigCameras The rig cameras to be appled to the post process
  36398. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  36399. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36400. * @param engine The engine which the post process will be applied. (default: current engine)
  36401. * @param reusable If the post process can be reused on the same frame. (default: false)
  36402. */
  36403. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36404. }
  36405. }
  36406. declare module BABYLON {
  36407. /**
  36408. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  36409. * @see http://doc.babylonjs.com/features/cameras
  36410. */
  36411. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  36412. /**
  36413. * Creates a new StereoscopicArcRotateCamera
  36414. * @param name defines camera name
  36415. * @param alpha defines alpha angle (in radians)
  36416. * @param beta defines beta angle (in radians)
  36417. * @param radius defines radius
  36418. * @param target defines camera target
  36419. * @param interaxialDistance defines distance between each color axis
  36420. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36421. * @param scene defines the hosting scene
  36422. */
  36423. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36424. /**
  36425. * Gets camera class name
  36426. * @returns StereoscopicArcRotateCamera
  36427. */
  36428. getClassName(): string;
  36429. }
  36430. }
  36431. declare module BABYLON {
  36432. /**
  36433. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  36434. * @see http://doc.babylonjs.com/features/cameras
  36435. */
  36436. export class StereoscopicFreeCamera extends FreeCamera {
  36437. /**
  36438. * Creates a new StereoscopicFreeCamera
  36439. * @param name defines camera name
  36440. * @param position defines initial position
  36441. * @param interaxialDistance defines distance between each color axis
  36442. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36443. * @param scene defines the hosting scene
  36444. */
  36445. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36446. /**
  36447. * Gets camera class name
  36448. * @returns StereoscopicFreeCamera
  36449. */
  36450. getClassName(): string;
  36451. }
  36452. }
  36453. declare module BABYLON {
  36454. /**
  36455. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  36456. * @see http://doc.babylonjs.com/features/cameras
  36457. */
  36458. export class StereoscopicGamepadCamera extends GamepadCamera {
  36459. /**
  36460. * Creates a new StereoscopicGamepadCamera
  36461. * @param name defines camera name
  36462. * @param position defines initial position
  36463. * @param interaxialDistance defines distance between each color axis
  36464. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36465. * @param scene defines the hosting scene
  36466. */
  36467. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36468. /**
  36469. * Gets camera class name
  36470. * @returns StereoscopicGamepadCamera
  36471. */
  36472. getClassName(): string;
  36473. }
  36474. }
  36475. declare module BABYLON {
  36476. /**
  36477. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  36478. * @see http://doc.babylonjs.com/features/cameras
  36479. */
  36480. export class StereoscopicUniversalCamera extends UniversalCamera {
  36481. /**
  36482. * Creates a new StereoscopicUniversalCamera
  36483. * @param name defines camera name
  36484. * @param position defines initial position
  36485. * @param interaxialDistance defines distance between each color axis
  36486. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36487. * @param scene defines the hosting scene
  36488. */
  36489. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36490. /**
  36491. * Gets camera class name
  36492. * @returns StereoscopicUniversalCamera
  36493. */
  36494. getClassName(): string;
  36495. }
  36496. }
  36497. declare module BABYLON {
  36498. /**
  36499. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  36500. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  36501. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  36502. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  36503. */
  36504. export class VirtualJoysticksCamera extends FreeCamera {
  36505. /**
  36506. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  36507. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  36508. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  36509. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  36510. * @param name Define the name of the camera in the scene
  36511. * @param position Define the start position of the camera in the scene
  36512. * @param scene Define the scene the camera belongs to
  36513. */
  36514. constructor(name: string, position: Vector3, scene: Scene);
  36515. /**
  36516. * Gets the current object class name.
  36517. * @return the class name
  36518. */
  36519. getClassName(): string;
  36520. }
  36521. }
  36522. declare module BABYLON {
  36523. /**
  36524. * This represents all the required metrics to create a VR camera.
  36525. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  36526. */
  36527. export class VRCameraMetrics {
  36528. /**
  36529. * Define the horizontal resolution off the screen.
  36530. */
  36531. hResolution: number;
  36532. /**
  36533. * Define the vertical resolution off the screen.
  36534. */
  36535. vResolution: number;
  36536. /**
  36537. * Define the horizontal screen size.
  36538. */
  36539. hScreenSize: number;
  36540. /**
  36541. * Define the vertical screen size.
  36542. */
  36543. vScreenSize: number;
  36544. /**
  36545. * Define the vertical screen center position.
  36546. */
  36547. vScreenCenter: number;
  36548. /**
  36549. * Define the distance of the eyes to the screen.
  36550. */
  36551. eyeToScreenDistance: number;
  36552. /**
  36553. * Define the distance between both lenses
  36554. */
  36555. lensSeparationDistance: number;
  36556. /**
  36557. * Define the distance between both viewer's eyes.
  36558. */
  36559. interpupillaryDistance: number;
  36560. /**
  36561. * Define the distortion factor of the VR postprocess.
  36562. * Please, touch with care.
  36563. */
  36564. distortionK: number[];
  36565. /**
  36566. * Define the chromatic aberration correction factors for the VR post process.
  36567. */
  36568. chromaAbCorrection: number[];
  36569. /**
  36570. * Define the scale factor of the post process.
  36571. * The smaller the better but the slower.
  36572. */
  36573. postProcessScaleFactor: number;
  36574. /**
  36575. * Define an offset for the lens center.
  36576. */
  36577. lensCenterOffset: number;
  36578. /**
  36579. * Define if the current vr camera should compensate the distortion of the lense or not.
  36580. */
  36581. compensateDistortion: boolean;
  36582. /**
  36583. * Gets the rendering aspect ratio based on the provided resolutions.
  36584. */
  36585. readonly aspectRatio: number;
  36586. /**
  36587. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  36588. */
  36589. readonly aspectRatioFov: number;
  36590. /**
  36591. * @hidden
  36592. */
  36593. readonly leftHMatrix: Matrix;
  36594. /**
  36595. * @hidden
  36596. */
  36597. readonly rightHMatrix: Matrix;
  36598. /**
  36599. * @hidden
  36600. */
  36601. readonly leftPreViewMatrix: Matrix;
  36602. /**
  36603. * @hidden
  36604. */
  36605. readonly rightPreViewMatrix: Matrix;
  36606. /**
  36607. * Get the default VRMetrics based on the most generic setup.
  36608. * @returns the default vr metrics
  36609. */
  36610. static GetDefault(): VRCameraMetrics;
  36611. }
  36612. }
  36613. declare module BABYLON {
  36614. /** @hidden */
  36615. export var vrDistortionCorrectionPixelShader: {
  36616. name: string;
  36617. shader: string;
  36618. };
  36619. }
  36620. declare module BABYLON {
  36621. /**
  36622. * VRDistortionCorrectionPostProcess used for mobile VR
  36623. */
  36624. export class VRDistortionCorrectionPostProcess extends PostProcess {
  36625. private _isRightEye;
  36626. private _distortionFactors;
  36627. private _postProcessScaleFactor;
  36628. private _lensCenterOffset;
  36629. private _scaleIn;
  36630. private _scaleFactor;
  36631. private _lensCenter;
  36632. /**
  36633. * Initializes the VRDistortionCorrectionPostProcess
  36634. * @param name The name of the effect.
  36635. * @param camera The camera to apply the render pass to.
  36636. * @param isRightEye If this is for the right eye distortion
  36637. * @param vrMetrics All the required metrics for the VR camera
  36638. */
  36639. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  36640. }
  36641. }
  36642. declare module BABYLON {
  36643. /**
  36644. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  36645. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  36646. */
  36647. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  36648. /**
  36649. * Creates a new VRDeviceOrientationArcRotateCamera
  36650. * @param name defines camera name
  36651. * @param alpha defines the camera rotation along the logitudinal axis
  36652. * @param beta defines the camera rotation along the latitudinal axis
  36653. * @param radius defines the camera distance from its target
  36654. * @param target defines the camera target
  36655. * @param scene defines the scene the camera belongs to
  36656. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  36657. * @param vrCameraMetrics defines the vr metrics associated to the camera
  36658. */
  36659. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  36660. /**
  36661. * Gets camera class name
  36662. * @returns VRDeviceOrientationArcRotateCamera
  36663. */
  36664. getClassName(): string;
  36665. }
  36666. }
  36667. declare module BABYLON {
  36668. /**
  36669. * Camera used to simulate VR rendering (based on FreeCamera)
  36670. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  36671. */
  36672. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  36673. /**
  36674. * Creates a new VRDeviceOrientationFreeCamera
  36675. * @param name defines camera name
  36676. * @param position defines the start position of the camera
  36677. * @param scene defines the scene the camera belongs to
  36678. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  36679. * @param vrCameraMetrics defines the vr metrics associated to the camera
  36680. */
  36681. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  36682. /**
  36683. * Gets camera class name
  36684. * @returns VRDeviceOrientationFreeCamera
  36685. */
  36686. getClassName(): string;
  36687. }
  36688. }
  36689. declare module BABYLON {
  36690. /**
  36691. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  36692. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  36693. */
  36694. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  36695. /**
  36696. * Creates a new VRDeviceOrientationGamepadCamera
  36697. * @param name defines camera name
  36698. * @param position defines the start position of the camera
  36699. * @param scene defines the scene the camera belongs to
  36700. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  36701. * @param vrCameraMetrics defines the vr metrics associated to the camera
  36702. */
  36703. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  36704. /**
  36705. * Gets camera class name
  36706. * @returns VRDeviceOrientationGamepadCamera
  36707. */
  36708. getClassName(): string;
  36709. }
  36710. }
  36711. declare module BABYLON {
  36712. /**
  36713. * Defines supported buttons for XBox360 compatible gamepads
  36714. */
  36715. export enum Xbox360Button {
  36716. /** A */
  36717. A = 0,
  36718. /** B */
  36719. B = 1,
  36720. /** X */
  36721. X = 2,
  36722. /** Y */
  36723. Y = 3,
  36724. /** Start */
  36725. Start = 4,
  36726. /** Back */
  36727. Back = 5,
  36728. /** Left button */
  36729. LB = 6,
  36730. /** Right button */
  36731. RB = 7,
  36732. /** Left stick */
  36733. LeftStick = 8,
  36734. /** Right stick */
  36735. RightStick = 9
  36736. }
  36737. /** Defines values for XBox360 DPad */
  36738. export enum Xbox360Dpad {
  36739. /** Up */
  36740. Up = 0,
  36741. /** Down */
  36742. Down = 1,
  36743. /** Left */
  36744. Left = 2,
  36745. /** Right */
  36746. Right = 3
  36747. }
  36748. /**
  36749. * Defines a XBox360 gamepad
  36750. */
  36751. export class Xbox360Pad extends Gamepad {
  36752. private _leftTrigger;
  36753. private _rightTrigger;
  36754. private _onlefttriggerchanged;
  36755. private _onrighttriggerchanged;
  36756. private _onbuttondown;
  36757. private _onbuttonup;
  36758. private _ondpaddown;
  36759. private _ondpadup;
  36760. /** Observable raised when a button is pressed */
  36761. onButtonDownObservable: Observable<Xbox360Button>;
  36762. /** Observable raised when a button is released */
  36763. onButtonUpObservable: Observable<Xbox360Button>;
  36764. /** Observable raised when a pad is pressed */
  36765. onPadDownObservable: Observable<Xbox360Dpad>;
  36766. /** Observable raised when a pad is released */
  36767. onPadUpObservable: Observable<Xbox360Dpad>;
  36768. private _buttonA;
  36769. private _buttonB;
  36770. private _buttonX;
  36771. private _buttonY;
  36772. private _buttonBack;
  36773. private _buttonStart;
  36774. private _buttonLB;
  36775. private _buttonRB;
  36776. private _buttonLeftStick;
  36777. private _buttonRightStick;
  36778. private _dPadUp;
  36779. private _dPadDown;
  36780. private _dPadLeft;
  36781. private _dPadRight;
  36782. private _isXboxOnePad;
  36783. /**
  36784. * Creates a new XBox360 gamepad object
  36785. * @param id defines the id of this gamepad
  36786. * @param index defines its index
  36787. * @param gamepad defines the internal HTML gamepad object
  36788. * @param xboxOne defines if it is a XBox One gamepad
  36789. */
  36790. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  36791. /**
  36792. * Defines the callback to call when left trigger is pressed
  36793. * @param callback defines the callback to use
  36794. */
  36795. onlefttriggerchanged(callback: (value: number) => void): void;
  36796. /**
  36797. * Defines the callback to call when right trigger is pressed
  36798. * @param callback defines the callback to use
  36799. */
  36800. onrighttriggerchanged(callback: (value: number) => void): void;
  36801. /**
  36802. * Gets the left trigger value
  36803. */
  36804. /**
  36805. * Sets the left trigger value
  36806. */
  36807. leftTrigger: number;
  36808. /**
  36809. * Gets the right trigger value
  36810. */
  36811. /**
  36812. * Sets the right trigger value
  36813. */
  36814. rightTrigger: number;
  36815. /**
  36816. * Defines the callback to call when a button is pressed
  36817. * @param callback defines the callback to use
  36818. */
  36819. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  36820. /**
  36821. * Defines the callback to call when a button is released
  36822. * @param callback defines the callback to use
  36823. */
  36824. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  36825. /**
  36826. * Defines the callback to call when a pad is pressed
  36827. * @param callback defines the callback to use
  36828. */
  36829. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  36830. /**
  36831. * Defines the callback to call when a pad is released
  36832. * @param callback defines the callback to use
  36833. */
  36834. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  36835. private _setButtonValue;
  36836. private _setDPadValue;
  36837. /**
  36838. * Gets the value of the `A` button
  36839. */
  36840. /**
  36841. * Sets the value of the `A` button
  36842. */
  36843. buttonA: number;
  36844. /**
  36845. * Gets the value of the `B` button
  36846. */
  36847. /**
  36848. * Sets the value of the `B` button
  36849. */
  36850. buttonB: number;
  36851. /**
  36852. * Gets the value of the `X` button
  36853. */
  36854. /**
  36855. * Sets the value of the `X` button
  36856. */
  36857. buttonX: number;
  36858. /**
  36859. * Gets the value of the `Y` button
  36860. */
  36861. /**
  36862. * Sets the value of the `Y` button
  36863. */
  36864. buttonY: number;
  36865. /**
  36866. * Gets the value of the `Start` button
  36867. */
  36868. /**
  36869. * Sets the value of the `Start` button
  36870. */
  36871. buttonStart: number;
  36872. /**
  36873. * Gets the value of the `Back` button
  36874. */
  36875. /**
  36876. * Sets the value of the `Back` button
  36877. */
  36878. buttonBack: number;
  36879. /**
  36880. * Gets the value of the `Left` button
  36881. */
  36882. /**
  36883. * Sets the value of the `Left` button
  36884. */
  36885. buttonLB: number;
  36886. /**
  36887. * Gets the value of the `Right` button
  36888. */
  36889. /**
  36890. * Sets the value of the `Right` button
  36891. */
  36892. buttonRB: number;
  36893. /**
  36894. * Gets the value of the Left joystick
  36895. */
  36896. /**
  36897. * Sets the value of the Left joystick
  36898. */
  36899. buttonLeftStick: number;
  36900. /**
  36901. * Gets the value of the Right joystick
  36902. */
  36903. /**
  36904. * Sets the value of the Right joystick
  36905. */
  36906. buttonRightStick: number;
  36907. /**
  36908. * Gets the value of D-pad up
  36909. */
  36910. /**
  36911. * Sets the value of D-pad up
  36912. */
  36913. dPadUp: number;
  36914. /**
  36915. * Gets the value of D-pad down
  36916. */
  36917. /**
  36918. * Sets the value of D-pad down
  36919. */
  36920. dPadDown: number;
  36921. /**
  36922. * Gets the value of D-pad left
  36923. */
  36924. /**
  36925. * Sets the value of D-pad left
  36926. */
  36927. dPadLeft: number;
  36928. /**
  36929. * Gets the value of D-pad right
  36930. */
  36931. /**
  36932. * Sets the value of D-pad right
  36933. */
  36934. dPadRight: number;
  36935. /**
  36936. * Force the gamepad to synchronize with device values
  36937. */
  36938. update(): void;
  36939. /**
  36940. * Disposes the gamepad
  36941. */
  36942. dispose(): void;
  36943. }
  36944. }
  36945. declare module BABYLON {
  36946. /**
  36947. * Base class of materials working in push mode in babylon JS
  36948. * @hidden
  36949. */
  36950. export class PushMaterial extends Material {
  36951. protected _activeEffect: Effect;
  36952. protected _normalMatrix: Matrix;
  36953. /**
  36954. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  36955. * This means that the material can keep using a previous shader while a new one is being compiled.
  36956. * This is mostly used when shader parallel compilation is supported (true by default)
  36957. */
  36958. allowShaderHotSwapping: boolean;
  36959. constructor(name: string, scene: Scene);
  36960. getEffect(): Effect;
  36961. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  36962. /**
  36963. * Binds the given world matrix to the active effect
  36964. *
  36965. * @param world the matrix to bind
  36966. */
  36967. bindOnlyWorldMatrix(world: Matrix): void;
  36968. /**
  36969. * Binds the given normal matrix to the active effect
  36970. *
  36971. * @param normalMatrix the matrix to bind
  36972. */
  36973. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  36974. bind(world: Matrix, mesh?: Mesh): void;
  36975. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  36976. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  36977. }
  36978. }
  36979. declare module BABYLON {
  36980. /**
  36981. * This groups all the flags used to control the materials channel.
  36982. */
  36983. export class MaterialFlags {
  36984. private static _DiffuseTextureEnabled;
  36985. /**
  36986. * Are diffuse textures enabled in the application.
  36987. */
  36988. static DiffuseTextureEnabled: boolean;
  36989. private static _AmbientTextureEnabled;
  36990. /**
  36991. * Are ambient textures enabled in the application.
  36992. */
  36993. static AmbientTextureEnabled: boolean;
  36994. private static _OpacityTextureEnabled;
  36995. /**
  36996. * Are opacity textures enabled in the application.
  36997. */
  36998. static OpacityTextureEnabled: boolean;
  36999. private static _ReflectionTextureEnabled;
  37000. /**
  37001. * Are reflection textures enabled in the application.
  37002. */
  37003. static ReflectionTextureEnabled: boolean;
  37004. private static _EmissiveTextureEnabled;
  37005. /**
  37006. * Are emissive textures enabled in the application.
  37007. */
  37008. static EmissiveTextureEnabled: boolean;
  37009. private static _SpecularTextureEnabled;
  37010. /**
  37011. * Are specular textures enabled in the application.
  37012. */
  37013. static SpecularTextureEnabled: boolean;
  37014. private static _BumpTextureEnabled;
  37015. /**
  37016. * Are bump textures enabled in the application.
  37017. */
  37018. static BumpTextureEnabled: boolean;
  37019. private static _LightmapTextureEnabled;
  37020. /**
  37021. * Are lightmap textures enabled in the application.
  37022. */
  37023. static LightmapTextureEnabled: boolean;
  37024. private static _RefractionTextureEnabled;
  37025. /**
  37026. * Are refraction textures enabled in the application.
  37027. */
  37028. static RefractionTextureEnabled: boolean;
  37029. private static _ColorGradingTextureEnabled;
  37030. /**
  37031. * Are color grading textures enabled in the application.
  37032. */
  37033. static ColorGradingTextureEnabled: boolean;
  37034. private static _FresnelEnabled;
  37035. /**
  37036. * Are fresnels enabled in the application.
  37037. */
  37038. static FresnelEnabled: boolean;
  37039. }
  37040. }
  37041. declare module BABYLON {
  37042. /** @hidden */
  37043. export var defaultFragmentDeclaration: {
  37044. name: string;
  37045. shader: string;
  37046. };
  37047. }
  37048. declare module BABYLON {
  37049. /** @hidden */
  37050. export var defaultUboDeclaration: {
  37051. name: string;
  37052. shader: string;
  37053. };
  37054. }
  37055. declare module BABYLON {
  37056. /** @hidden */
  37057. export var lightFragmentDeclaration: {
  37058. name: string;
  37059. shader: string;
  37060. };
  37061. }
  37062. declare module BABYLON {
  37063. /** @hidden */
  37064. export var lightUboDeclaration: {
  37065. name: string;
  37066. shader: string;
  37067. };
  37068. }
  37069. declare module BABYLON {
  37070. /** @hidden */
  37071. export var lightsFragmentFunctions: {
  37072. name: string;
  37073. shader: string;
  37074. };
  37075. }
  37076. declare module BABYLON {
  37077. /** @hidden */
  37078. export var shadowsFragmentFunctions: {
  37079. name: string;
  37080. shader: string;
  37081. };
  37082. }
  37083. declare module BABYLON {
  37084. /** @hidden */
  37085. export var fresnelFunction: {
  37086. name: string;
  37087. shader: string;
  37088. };
  37089. }
  37090. declare module BABYLON {
  37091. /** @hidden */
  37092. export var reflectionFunction: {
  37093. name: string;
  37094. shader: string;
  37095. };
  37096. }
  37097. declare module BABYLON {
  37098. /** @hidden */
  37099. export var bumpFragmentFunctions: {
  37100. name: string;
  37101. shader: string;
  37102. };
  37103. }
  37104. declare module BABYLON {
  37105. /** @hidden */
  37106. export var logDepthDeclaration: {
  37107. name: string;
  37108. shader: string;
  37109. };
  37110. }
  37111. declare module BABYLON {
  37112. /** @hidden */
  37113. export var bumpFragment: {
  37114. name: string;
  37115. shader: string;
  37116. };
  37117. }
  37118. declare module BABYLON {
  37119. /** @hidden */
  37120. export var depthPrePass: {
  37121. name: string;
  37122. shader: string;
  37123. };
  37124. }
  37125. declare module BABYLON {
  37126. /** @hidden */
  37127. export var lightFragment: {
  37128. name: string;
  37129. shader: string;
  37130. };
  37131. }
  37132. declare module BABYLON {
  37133. /** @hidden */
  37134. export var logDepthFragment: {
  37135. name: string;
  37136. shader: string;
  37137. };
  37138. }
  37139. declare module BABYLON {
  37140. /** @hidden */
  37141. export var defaultPixelShader: {
  37142. name: string;
  37143. shader: string;
  37144. };
  37145. }
  37146. declare module BABYLON {
  37147. /** @hidden */
  37148. export var defaultVertexDeclaration: {
  37149. name: string;
  37150. shader: string;
  37151. };
  37152. }
  37153. declare module BABYLON {
  37154. /** @hidden */
  37155. export var bumpVertexDeclaration: {
  37156. name: string;
  37157. shader: string;
  37158. };
  37159. }
  37160. declare module BABYLON {
  37161. /** @hidden */
  37162. export var bumpVertex: {
  37163. name: string;
  37164. shader: string;
  37165. };
  37166. }
  37167. declare module BABYLON {
  37168. /** @hidden */
  37169. export var fogVertex: {
  37170. name: string;
  37171. shader: string;
  37172. };
  37173. }
  37174. declare module BABYLON {
  37175. /** @hidden */
  37176. export var shadowsVertex: {
  37177. name: string;
  37178. shader: string;
  37179. };
  37180. }
  37181. declare module BABYLON {
  37182. /** @hidden */
  37183. export var pointCloudVertex: {
  37184. name: string;
  37185. shader: string;
  37186. };
  37187. }
  37188. declare module BABYLON {
  37189. /** @hidden */
  37190. export var logDepthVertex: {
  37191. name: string;
  37192. shader: string;
  37193. };
  37194. }
  37195. declare module BABYLON {
  37196. /** @hidden */
  37197. export var defaultVertexShader: {
  37198. name: string;
  37199. shader: string;
  37200. };
  37201. }
  37202. declare module BABYLON {
  37203. /** @hidden */
  37204. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  37205. MAINUV1: boolean;
  37206. MAINUV2: boolean;
  37207. DIFFUSE: boolean;
  37208. DIFFUSEDIRECTUV: number;
  37209. AMBIENT: boolean;
  37210. AMBIENTDIRECTUV: number;
  37211. OPACITY: boolean;
  37212. OPACITYDIRECTUV: number;
  37213. OPACITYRGB: boolean;
  37214. REFLECTION: boolean;
  37215. EMISSIVE: boolean;
  37216. EMISSIVEDIRECTUV: number;
  37217. SPECULAR: boolean;
  37218. SPECULARDIRECTUV: number;
  37219. BUMP: boolean;
  37220. BUMPDIRECTUV: number;
  37221. PARALLAX: boolean;
  37222. PARALLAXOCCLUSION: boolean;
  37223. SPECULAROVERALPHA: boolean;
  37224. CLIPPLANE: boolean;
  37225. CLIPPLANE2: boolean;
  37226. CLIPPLANE3: boolean;
  37227. CLIPPLANE4: boolean;
  37228. ALPHATEST: boolean;
  37229. DEPTHPREPASS: boolean;
  37230. ALPHAFROMDIFFUSE: boolean;
  37231. POINTSIZE: boolean;
  37232. FOG: boolean;
  37233. SPECULARTERM: boolean;
  37234. DIFFUSEFRESNEL: boolean;
  37235. OPACITYFRESNEL: boolean;
  37236. REFLECTIONFRESNEL: boolean;
  37237. REFRACTIONFRESNEL: boolean;
  37238. EMISSIVEFRESNEL: boolean;
  37239. FRESNEL: boolean;
  37240. NORMAL: boolean;
  37241. UV1: boolean;
  37242. UV2: boolean;
  37243. VERTEXCOLOR: boolean;
  37244. VERTEXALPHA: boolean;
  37245. NUM_BONE_INFLUENCERS: number;
  37246. BonesPerMesh: number;
  37247. BONETEXTURE: boolean;
  37248. INSTANCES: boolean;
  37249. GLOSSINESS: boolean;
  37250. ROUGHNESS: boolean;
  37251. EMISSIVEASILLUMINATION: boolean;
  37252. LINKEMISSIVEWITHDIFFUSE: boolean;
  37253. REFLECTIONFRESNELFROMSPECULAR: boolean;
  37254. LIGHTMAP: boolean;
  37255. LIGHTMAPDIRECTUV: number;
  37256. OBJECTSPACE_NORMALMAP: boolean;
  37257. USELIGHTMAPASSHADOWMAP: boolean;
  37258. REFLECTIONMAP_3D: boolean;
  37259. REFLECTIONMAP_SPHERICAL: boolean;
  37260. REFLECTIONMAP_PLANAR: boolean;
  37261. REFLECTIONMAP_CUBIC: boolean;
  37262. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  37263. REFLECTIONMAP_PROJECTION: boolean;
  37264. REFLECTIONMAP_SKYBOX: boolean;
  37265. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  37266. REFLECTIONMAP_EXPLICIT: boolean;
  37267. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  37268. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  37269. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  37270. INVERTCUBICMAP: boolean;
  37271. LOGARITHMICDEPTH: boolean;
  37272. REFRACTION: boolean;
  37273. REFRACTIONMAP_3D: boolean;
  37274. REFLECTIONOVERALPHA: boolean;
  37275. TWOSIDEDLIGHTING: boolean;
  37276. SHADOWFLOAT: boolean;
  37277. MORPHTARGETS: boolean;
  37278. MORPHTARGETS_NORMAL: boolean;
  37279. MORPHTARGETS_TANGENT: boolean;
  37280. NUM_MORPH_INFLUENCERS: number;
  37281. NONUNIFORMSCALING: boolean;
  37282. PREMULTIPLYALPHA: boolean;
  37283. IMAGEPROCESSING: boolean;
  37284. VIGNETTE: boolean;
  37285. VIGNETTEBLENDMODEMULTIPLY: boolean;
  37286. VIGNETTEBLENDMODEOPAQUE: boolean;
  37287. TONEMAPPING: boolean;
  37288. TONEMAPPING_ACES: boolean;
  37289. CONTRAST: boolean;
  37290. COLORCURVES: boolean;
  37291. COLORGRADING: boolean;
  37292. COLORGRADING3D: boolean;
  37293. SAMPLER3DGREENDEPTH: boolean;
  37294. SAMPLER3DBGRMAP: boolean;
  37295. IMAGEPROCESSINGPOSTPROCESS: boolean;
  37296. /**
  37297. * If the reflection texture on this material is in linear color space
  37298. * @hidden
  37299. */
  37300. IS_REFLECTION_LINEAR: boolean;
  37301. /**
  37302. * If the refraction texture on this material is in linear color space
  37303. * @hidden
  37304. */
  37305. IS_REFRACTION_LINEAR: boolean;
  37306. EXPOSURE: boolean;
  37307. constructor();
  37308. setReflectionMode(modeToEnable: string): void;
  37309. }
  37310. /**
  37311. * This is the default material used in Babylon. It is the best trade off between quality
  37312. * and performances.
  37313. * @see http://doc.babylonjs.com/babylon101/materials
  37314. */
  37315. export class StandardMaterial extends PushMaterial {
  37316. private _diffuseTexture;
  37317. /**
  37318. * The basic texture of the material as viewed under a light.
  37319. */
  37320. diffuseTexture: Nullable<BaseTexture>;
  37321. private _ambientTexture;
  37322. /**
  37323. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  37324. */
  37325. ambientTexture: Nullable<BaseTexture>;
  37326. private _opacityTexture;
  37327. /**
  37328. * Define the transparency of the material from a texture.
  37329. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  37330. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  37331. */
  37332. opacityTexture: Nullable<BaseTexture>;
  37333. private _reflectionTexture;
  37334. /**
  37335. * Define the texture used to display the reflection.
  37336. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37337. */
  37338. reflectionTexture: Nullable<BaseTexture>;
  37339. private _emissiveTexture;
  37340. /**
  37341. * Define texture of the material as if self lit.
  37342. * This will be mixed in the final result even in the absence of light.
  37343. */
  37344. emissiveTexture: Nullable<BaseTexture>;
  37345. private _specularTexture;
  37346. /**
  37347. * Define how the color and intensity of the highlight given by the light in the material.
  37348. */
  37349. specularTexture: Nullable<BaseTexture>;
  37350. private _bumpTexture;
  37351. /**
  37352. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  37353. * 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.
  37354. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  37355. */
  37356. bumpTexture: Nullable<BaseTexture>;
  37357. private _lightmapTexture;
  37358. /**
  37359. * Complex lighting can be computationally expensive to compute at runtime.
  37360. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  37361. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  37362. */
  37363. lightmapTexture: Nullable<BaseTexture>;
  37364. private _refractionTexture;
  37365. /**
  37366. * Define the texture used to display the refraction.
  37367. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37368. */
  37369. refractionTexture: Nullable<BaseTexture>;
  37370. /**
  37371. * The color of the material lit by the environmental background lighting.
  37372. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  37373. */
  37374. ambientColor: Color3;
  37375. /**
  37376. * The basic color of the material as viewed under a light.
  37377. */
  37378. diffuseColor: Color3;
  37379. /**
  37380. * Define how the color and intensity of the highlight given by the light in the material.
  37381. */
  37382. specularColor: Color3;
  37383. /**
  37384. * Define the color of the material as if self lit.
  37385. * This will be mixed in the final result even in the absence of light.
  37386. */
  37387. emissiveColor: Color3;
  37388. /**
  37389. * Defines how sharp are the highlights in the material.
  37390. * The bigger the value the sharper giving a more glossy feeling to the result.
  37391. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  37392. */
  37393. specularPower: number;
  37394. private _useAlphaFromDiffuseTexture;
  37395. /**
  37396. * Does the transparency come from the diffuse texture alpha channel.
  37397. */
  37398. useAlphaFromDiffuseTexture: boolean;
  37399. private _useEmissiveAsIllumination;
  37400. /**
  37401. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  37402. */
  37403. useEmissiveAsIllumination: boolean;
  37404. private _linkEmissiveWithDiffuse;
  37405. /**
  37406. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  37407. * the emissive level when the final color is close to one.
  37408. */
  37409. linkEmissiveWithDiffuse: boolean;
  37410. private _useSpecularOverAlpha;
  37411. /**
  37412. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  37413. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  37414. */
  37415. useSpecularOverAlpha: boolean;
  37416. private _useReflectionOverAlpha;
  37417. /**
  37418. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  37419. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  37420. */
  37421. useReflectionOverAlpha: boolean;
  37422. private _disableLighting;
  37423. /**
  37424. * Does lights from the scene impacts this material.
  37425. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  37426. */
  37427. disableLighting: boolean;
  37428. private _useObjectSpaceNormalMap;
  37429. /**
  37430. * Allows using an object space normal map (instead of tangent space).
  37431. */
  37432. useObjectSpaceNormalMap: boolean;
  37433. private _useParallax;
  37434. /**
  37435. * Is parallax enabled or not.
  37436. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  37437. */
  37438. useParallax: boolean;
  37439. private _useParallaxOcclusion;
  37440. /**
  37441. * Is parallax occlusion enabled or not.
  37442. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  37443. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  37444. */
  37445. useParallaxOcclusion: boolean;
  37446. /**
  37447. * 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.
  37448. */
  37449. parallaxScaleBias: number;
  37450. private _roughness;
  37451. /**
  37452. * Helps to define how blurry the reflections should appears in the material.
  37453. */
  37454. roughness: number;
  37455. /**
  37456. * In case of refraction, define the value of the indice of refraction.
  37457. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37458. */
  37459. indexOfRefraction: number;
  37460. /**
  37461. * Invert the refraction texture alongside the y axis.
  37462. * It can be useful with procedural textures or probe for instance.
  37463. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37464. */
  37465. invertRefractionY: boolean;
  37466. /**
  37467. * Defines the alpha limits in alpha test mode.
  37468. */
  37469. alphaCutOff: number;
  37470. private _useLightmapAsShadowmap;
  37471. /**
  37472. * In case of light mapping, define whether the map contains light or shadow informations.
  37473. */
  37474. useLightmapAsShadowmap: boolean;
  37475. private _diffuseFresnelParameters;
  37476. /**
  37477. * Define the diffuse fresnel parameters of the material.
  37478. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37479. */
  37480. diffuseFresnelParameters: FresnelParameters;
  37481. private _opacityFresnelParameters;
  37482. /**
  37483. * Define the opacity fresnel parameters of the material.
  37484. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37485. */
  37486. opacityFresnelParameters: FresnelParameters;
  37487. private _reflectionFresnelParameters;
  37488. /**
  37489. * Define the reflection fresnel parameters of the material.
  37490. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37491. */
  37492. reflectionFresnelParameters: FresnelParameters;
  37493. private _refractionFresnelParameters;
  37494. /**
  37495. * Define the refraction fresnel parameters of the material.
  37496. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37497. */
  37498. refractionFresnelParameters: FresnelParameters;
  37499. private _emissiveFresnelParameters;
  37500. /**
  37501. * Define the emissive fresnel parameters of the material.
  37502. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37503. */
  37504. emissiveFresnelParameters: FresnelParameters;
  37505. private _useReflectionFresnelFromSpecular;
  37506. /**
  37507. * If true automatically deducts the fresnels values from the material specularity.
  37508. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37509. */
  37510. useReflectionFresnelFromSpecular: boolean;
  37511. private _useGlossinessFromSpecularMapAlpha;
  37512. /**
  37513. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  37514. */
  37515. useGlossinessFromSpecularMapAlpha: boolean;
  37516. private _maxSimultaneousLights;
  37517. /**
  37518. * Defines the maximum number of lights that can be used in the material
  37519. */
  37520. maxSimultaneousLights: number;
  37521. private _invertNormalMapX;
  37522. /**
  37523. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  37524. */
  37525. invertNormalMapX: boolean;
  37526. private _invertNormalMapY;
  37527. /**
  37528. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  37529. */
  37530. invertNormalMapY: boolean;
  37531. private _twoSidedLighting;
  37532. /**
  37533. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  37534. */
  37535. twoSidedLighting: boolean;
  37536. /**
  37537. * Default configuration related to image processing available in the standard Material.
  37538. */
  37539. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  37540. /**
  37541. * Gets the image processing configuration used either in this material.
  37542. */
  37543. /**
  37544. * Sets the Default image processing configuration used either in the this material.
  37545. *
  37546. * If sets to null, the scene one is in use.
  37547. */
  37548. imageProcessingConfiguration: ImageProcessingConfiguration;
  37549. /**
  37550. * Keep track of the image processing observer to allow dispose and replace.
  37551. */
  37552. private _imageProcessingObserver;
  37553. /**
  37554. * Attaches a new image processing configuration to the Standard Material.
  37555. * @param configuration
  37556. */
  37557. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  37558. /**
  37559. * Gets wether the color curves effect is enabled.
  37560. */
  37561. /**
  37562. * Sets wether the color curves effect is enabled.
  37563. */
  37564. cameraColorCurvesEnabled: boolean;
  37565. /**
  37566. * Gets wether the color grading effect is enabled.
  37567. */
  37568. /**
  37569. * Gets wether the color grading effect is enabled.
  37570. */
  37571. cameraColorGradingEnabled: boolean;
  37572. /**
  37573. * Gets wether tonemapping is enabled or not.
  37574. */
  37575. /**
  37576. * Sets wether tonemapping is enabled or not
  37577. */
  37578. cameraToneMappingEnabled: boolean;
  37579. /**
  37580. * The camera exposure used on this material.
  37581. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  37582. * This corresponds to a photographic exposure.
  37583. */
  37584. /**
  37585. * The camera exposure used on this material.
  37586. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  37587. * This corresponds to a photographic exposure.
  37588. */
  37589. cameraExposure: number;
  37590. /**
  37591. * Gets The camera contrast used on this material.
  37592. */
  37593. /**
  37594. * Sets The camera contrast used on this material.
  37595. */
  37596. cameraContrast: number;
  37597. /**
  37598. * Gets the Color Grading 2D Lookup Texture.
  37599. */
  37600. /**
  37601. * Sets the Color Grading 2D Lookup Texture.
  37602. */
  37603. cameraColorGradingTexture: Nullable<BaseTexture>;
  37604. /**
  37605. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  37606. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  37607. * 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;
  37608. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  37609. */
  37610. /**
  37611. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  37612. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  37613. * 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;
  37614. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  37615. */
  37616. cameraColorCurves: Nullable<ColorCurves>;
  37617. /**
  37618. * Custom callback helping to override the default shader used in the material.
  37619. */
  37620. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  37621. protected _renderTargets: SmartArray<RenderTargetTexture>;
  37622. protected _worldViewProjectionMatrix: Matrix;
  37623. protected _globalAmbientColor: Color3;
  37624. protected _useLogarithmicDepth: boolean;
  37625. /**
  37626. * Instantiates a new standard material.
  37627. * This is the default material used in Babylon. It is the best trade off between quality
  37628. * and performances.
  37629. * @see http://doc.babylonjs.com/babylon101/materials
  37630. * @param name Define the name of the material in the scene
  37631. * @param scene Define the scene the material belong to
  37632. */
  37633. constructor(name: string, scene: Scene);
  37634. /**
  37635. * Gets a boolean indicating that current material needs to register RTT
  37636. */
  37637. readonly hasRenderTargetTextures: boolean;
  37638. /**
  37639. * Gets the current class name of the material e.g. "StandardMaterial"
  37640. * Mainly use in serialization.
  37641. * @returns the class name
  37642. */
  37643. getClassName(): string;
  37644. /**
  37645. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  37646. * You can try switching to logarithmic depth.
  37647. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  37648. */
  37649. useLogarithmicDepth: boolean;
  37650. /**
  37651. * Specifies if the material will require alpha blending
  37652. * @returns a boolean specifying if alpha blending is needed
  37653. */
  37654. needAlphaBlending(): boolean;
  37655. /**
  37656. * Specifies if this material should be rendered in alpha test mode
  37657. * @returns a boolean specifying if an alpha test is needed.
  37658. */
  37659. needAlphaTesting(): boolean;
  37660. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  37661. /**
  37662. * Get the texture used for alpha test purpose.
  37663. * @returns the diffuse texture in case of the standard material.
  37664. */
  37665. getAlphaTestTexture(): Nullable<BaseTexture>;
  37666. /**
  37667. * Get if the submesh is ready to be used and all its information available.
  37668. * Child classes can use it to update shaders
  37669. * @param mesh defines the mesh to check
  37670. * @param subMesh defines which submesh to check
  37671. * @param useInstances specifies that instances should be used
  37672. * @returns a boolean indicating that the submesh is ready or not
  37673. */
  37674. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  37675. /**
  37676. * Builds the material UBO layouts.
  37677. * Used internally during the effect preparation.
  37678. */
  37679. buildUniformLayout(): void;
  37680. /**
  37681. * Unbinds the material from the mesh
  37682. */
  37683. unbind(): void;
  37684. /**
  37685. * Binds the submesh to this material by preparing the effect and shader to draw
  37686. * @param world defines the world transformation matrix
  37687. * @param mesh defines the mesh containing the submesh
  37688. * @param subMesh defines the submesh to bind the material to
  37689. */
  37690. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  37691. /**
  37692. * Get the list of animatables in the material.
  37693. * @returns the list of animatables object used in the material
  37694. */
  37695. getAnimatables(): IAnimatable[];
  37696. /**
  37697. * Gets the active textures from the material
  37698. * @returns an array of textures
  37699. */
  37700. getActiveTextures(): BaseTexture[];
  37701. /**
  37702. * Specifies if the material uses a texture
  37703. * @param texture defines the texture to check against the material
  37704. * @returns a boolean specifying if the material uses the texture
  37705. */
  37706. hasTexture(texture: BaseTexture): boolean;
  37707. /**
  37708. * Disposes the material
  37709. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  37710. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  37711. */
  37712. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  37713. /**
  37714. * Makes a duplicate of the material, and gives it a new name
  37715. * @param name defines the new name for the duplicated material
  37716. * @returns the cloned material
  37717. */
  37718. clone(name: string): StandardMaterial;
  37719. /**
  37720. * Serializes this material in a JSON representation
  37721. * @returns the serialized material object
  37722. */
  37723. serialize(): any;
  37724. /**
  37725. * Creates a standard material from parsed material data
  37726. * @param source defines the JSON representation of the material
  37727. * @param scene defines the hosting scene
  37728. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  37729. * @returns a new standard material
  37730. */
  37731. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  37732. /**
  37733. * Are diffuse textures enabled in the application.
  37734. */
  37735. static DiffuseTextureEnabled: boolean;
  37736. /**
  37737. * Are ambient textures enabled in the application.
  37738. */
  37739. static AmbientTextureEnabled: boolean;
  37740. /**
  37741. * Are opacity textures enabled in the application.
  37742. */
  37743. static OpacityTextureEnabled: boolean;
  37744. /**
  37745. * Are reflection textures enabled in the application.
  37746. */
  37747. static ReflectionTextureEnabled: boolean;
  37748. /**
  37749. * Are emissive textures enabled in the application.
  37750. */
  37751. static EmissiveTextureEnabled: boolean;
  37752. /**
  37753. * Are specular textures enabled in the application.
  37754. */
  37755. static SpecularTextureEnabled: boolean;
  37756. /**
  37757. * Are bump textures enabled in the application.
  37758. */
  37759. static BumpTextureEnabled: boolean;
  37760. /**
  37761. * Are lightmap textures enabled in the application.
  37762. */
  37763. static LightmapTextureEnabled: boolean;
  37764. /**
  37765. * Are refraction textures enabled in the application.
  37766. */
  37767. static RefractionTextureEnabled: boolean;
  37768. /**
  37769. * Are color grading textures enabled in the application.
  37770. */
  37771. static ColorGradingTextureEnabled: boolean;
  37772. /**
  37773. * Are fresnels enabled in the application.
  37774. */
  37775. static FresnelEnabled: boolean;
  37776. }
  37777. }
  37778. declare module BABYLON {
  37779. /**
  37780. * A class extending Texture allowing drawing on a texture
  37781. * @see http://doc.babylonjs.com/how_to/dynamictexture
  37782. */
  37783. export class DynamicTexture extends Texture {
  37784. private _generateMipMaps;
  37785. private _canvas;
  37786. private _context;
  37787. private _engine;
  37788. /**
  37789. * Creates a DynamicTexture
  37790. * @param name defines the name of the texture
  37791. * @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
  37792. * @param scene defines the scene where you want the texture
  37793. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  37794. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  37795. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  37796. */
  37797. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  37798. /**
  37799. * Get the current class name of the texture useful for serialization or dynamic coding.
  37800. * @returns "DynamicTexture"
  37801. */
  37802. getClassName(): string;
  37803. /**
  37804. * Gets the current state of canRescale
  37805. */
  37806. readonly canRescale: boolean;
  37807. private _recreate;
  37808. /**
  37809. * Scales the texture
  37810. * @param ratio the scale factor to apply to both width and height
  37811. */
  37812. scale(ratio: number): void;
  37813. /**
  37814. * Resizes the texture
  37815. * @param width the new width
  37816. * @param height the new height
  37817. */
  37818. scaleTo(width: number, height: number): void;
  37819. /**
  37820. * Gets the context of the canvas used by the texture
  37821. * @returns the canvas context of the dynamic texture
  37822. */
  37823. getContext(): CanvasRenderingContext2D;
  37824. /**
  37825. * Clears the texture
  37826. */
  37827. clear(): void;
  37828. /**
  37829. * Updates the texture
  37830. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  37831. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  37832. */
  37833. update(invertY?: boolean, premulAlpha?: boolean): void;
  37834. /**
  37835. * Draws text onto the texture
  37836. * @param text defines the text to be drawn
  37837. * @param x defines the placement of the text from the left
  37838. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  37839. * @param font defines the font to be used with font-style, font-size, font-name
  37840. * @param color defines the color used for the text
  37841. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  37842. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  37843. * @param update defines whether texture is immediately update (default is true)
  37844. */
  37845. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  37846. /**
  37847. * Clones the texture
  37848. * @returns the clone of the texture.
  37849. */
  37850. clone(): DynamicTexture;
  37851. /**
  37852. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  37853. * @returns a serialized dynamic texture object
  37854. */
  37855. serialize(): any;
  37856. /** @hidden */
  37857. _rebuild(): void;
  37858. }
  37859. }
  37860. declare module BABYLON {
  37861. /** @hidden */
  37862. export var imageProcessingPixelShader: {
  37863. name: string;
  37864. shader: string;
  37865. };
  37866. }
  37867. declare module BABYLON {
  37868. /**
  37869. * ImageProcessingPostProcess
  37870. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  37871. */
  37872. export class ImageProcessingPostProcess extends PostProcess {
  37873. /**
  37874. * Default configuration related to image processing available in the PBR Material.
  37875. */
  37876. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  37877. /**
  37878. * Gets the image processing configuration used either in this material.
  37879. */
  37880. /**
  37881. * Sets the Default image processing configuration used either in the this material.
  37882. *
  37883. * If sets to null, the scene one is in use.
  37884. */
  37885. imageProcessingConfiguration: ImageProcessingConfiguration;
  37886. /**
  37887. * Keep track of the image processing observer to allow dispose and replace.
  37888. */
  37889. private _imageProcessingObserver;
  37890. /**
  37891. * Attaches a new image processing configuration to the PBR Material.
  37892. * @param configuration
  37893. */
  37894. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  37895. /**
  37896. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  37897. */
  37898. /**
  37899. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  37900. */
  37901. colorCurves: Nullable<ColorCurves>;
  37902. /**
  37903. * Gets wether the color curves effect is enabled.
  37904. */
  37905. /**
  37906. * Sets wether the color curves effect is enabled.
  37907. */
  37908. colorCurvesEnabled: boolean;
  37909. /**
  37910. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  37911. */
  37912. /**
  37913. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  37914. */
  37915. colorGradingTexture: Nullable<BaseTexture>;
  37916. /**
  37917. * Gets wether the color grading effect is enabled.
  37918. */
  37919. /**
  37920. * Gets wether the color grading effect is enabled.
  37921. */
  37922. colorGradingEnabled: boolean;
  37923. /**
  37924. * Gets exposure used in the effect.
  37925. */
  37926. /**
  37927. * Sets exposure used in the effect.
  37928. */
  37929. exposure: number;
  37930. /**
  37931. * Gets wether tonemapping is enabled or not.
  37932. */
  37933. /**
  37934. * Sets wether tonemapping is enabled or not
  37935. */
  37936. toneMappingEnabled: boolean;
  37937. /**
  37938. * Gets contrast used in the effect.
  37939. */
  37940. /**
  37941. * Sets contrast used in the effect.
  37942. */
  37943. contrast: number;
  37944. /**
  37945. * Gets Vignette stretch size.
  37946. */
  37947. /**
  37948. * Sets Vignette stretch size.
  37949. */
  37950. vignetteStretch: number;
  37951. /**
  37952. * Gets Vignette centre X Offset.
  37953. */
  37954. /**
  37955. * Sets Vignette centre X Offset.
  37956. */
  37957. vignetteCentreX: number;
  37958. /**
  37959. * Gets Vignette centre Y Offset.
  37960. */
  37961. /**
  37962. * Sets Vignette centre Y Offset.
  37963. */
  37964. vignetteCentreY: number;
  37965. /**
  37966. * Gets Vignette weight or intensity of the vignette effect.
  37967. */
  37968. /**
  37969. * Sets Vignette weight or intensity of the vignette effect.
  37970. */
  37971. vignetteWeight: number;
  37972. /**
  37973. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  37974. * if vignetteEnabled is set to true.
  37975. */
  37976. /**
  37977. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  37978. * if vignetteEnabled is set to true.
  37979. */
  37980. vignetteColor: Color4;
  37981. /**
  37982. * Gets Camera field of view used by the Vignette effect.
  37983. */
  37984. /**
  37985. * Sets Camera field of view used by the Vignette effect.
  37986. */
  37987. vignetteCameraFov: number;
  37988. /**
  37989. * Gets the vignette blend mode allowing different kind of effect.
  37990. */
  37991. /**
  37992. * Sets the vignette blend mode allowing different kind of effect.
  37993. */
  37994. vignetteBlendMode: number;
  37995. /**
  37996. * Gets wether the vignette effect is enabled.
  37997. */
  37998. /**
  37999. * Sets wether the vignette effect is enabled.
  38000. */
  38001. vignetteEnabled: boolean;
  38002. private _fromLinearSpace;
  38003. /**
  38004. * Gets wether the input of the processing is in Gamma or Linear Space.
  38005. */
  38006. /**
  38007. * Sets wether the input of the processing is in Gamma or Linear Space.
  38008. */
  38009. fromLinearSpace: boolean;
  38010. /**
  38011. * Defines cache preventing GC.
  38012. */
  38013. private _defines;
  38014. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  38015. /**
  38016. * "ImageProcessingPostProcess"
  38017. * @returns "ImageProcessingPostProcess"
  38018. */
  38019. getClassName(): string;
  38020. protected _updateParameters(): void;
  38021. dispose(camera?: Camera): void;
  38022. }
  38023. }
  38024. declare module BABYLON {
  38025. /**
  38026. * Class containing static functions to help procedurally build meshes
  38027. */
  38028. export class GroundBuilder {
  38029. /**
  38030. * Creates a ground mesh
  38031. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  38032. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  38033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38034. * @param name defines the name of the mesh
  38035. * @param options defines the options used to create the mesh
  38036. * @param scene defines the hosting scene
  38037. * @returns the ground mesh
  38038. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  38039. */
  38040. static CreateGround(name: string, options: {
  38041. width?: number;
  38042. height?: number;
  38043. subdivisions?: number;
  38044. subdivisionsX?: number;
  38045. subdivisionsY?: number;
  38046. updatable?: boolean;
  38047. }, scene: any): Mesh;
  38048. /**
  38049. * Creates a tiled ground mesh
  38050. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  38051. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  38052. * * 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
  38053. * * 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
  38054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38055. * @param name defines the name of the mesh
  38056. * @param options defines the options used to create the mesh
  38057. * @param scene defines the hosting scene
  38058. * @returns the tiled ground mesh
  38059. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  38060. */
  38061. static CreateTiledGround(name: string, options: {
  38062. xmin: number;
  38063. zmin: number;
  38064. xmax: number;
  38065. zmax: number;
  38066. subdivisions?: {
  38067. w: number;
  38068. h: number;
  38069. };
  38070. precision?: {
  38071. w: number;
  38072. h: number;
  38073. };
  38074. updatable?: boolean;
  38075. }, scene: Scene): Mesh;
  38076. /**
  38077. * Creates a ground mesh from a height map
  38078. * * The parameter `url` sets the URL of the height map image resource.
  38079. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  38080. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  38081. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  38082. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  38083. * * 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.
  38084. * * 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).
  38085. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  38086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38087. * @param name defines the name of the mesh
  38088. * @param url defines the url to the height map
  38089. * @param options defines the options used to create the mesh
  38090. * @param scene defines the hosting scene
  38091. * @returns the ground mesh
  38092. * @see https://doc.babylonjs.com/babylon101/height_map
  38093. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  38094. */
  38095. static CreateGroundFromHeightMap(name: string, url: string, options: {
  38096. width?: number;
  38097. height?: number;
  38098. subdivisions?: number;
  38099. minHeight?: number;
  38100. maxHeight?: number;
  38101. colorFilter?: Color3;
  38102. alphaFilter?: number;
  38103. updatable?: boolean;
  38104. onReady?: (mesh: GroundMesh) => void;
  38105. }, scene: Scene): GroundMesh;
  38106. }
  38107. }
  38108. declare module BABYLON {
  38109. /**
  38110. * Class containing static functions to help procedurally build meshes
  38111. */
  38112. export class TorusBuilder {
  38113. /**
  38114. * Creates a torus mesh
  38115. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  38116. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  38117. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  38118. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38119. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38121. * @param name defines the name of the mesh
  38122. * @param options defines the options used to create the mesh
  38123. * @param scene defines the hosting scene
  38124. * @returns the torus mesh
  38125. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  38126. */
  38127. static CreateTorus(name: string, options: {
  38128. diameter?: number;
  38129. thickness?: number;
  38130. tessellation?: number;
  38131. updatable?: boolean;
  38132. sideOrientation?: number;
  38133. frontUVs?: Vector4;
  38134. backUVs?: Vector4;
  38135. }, scene: any): Mesh;
  38136. }
  38137. }
  38138. declare module BABYLON {
  38139. /**
  38140. * Class containing static functions to help procedurally build meshes
  38141. */
  38142. export class CylinderBuilder {
  38143. /**
  38144. * Creates a cylinder or a cone mesh
  38145. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  38146. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  38147. * * 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.
  38148. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  38149. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  38150. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  38151. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  38152. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  38153. * * 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).
  38154. * * 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
  38155. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  38156. * * 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
  38157. * * 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.
  38158. * * If `enclose` is false, a ring surface is one element.
  38159. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  38160. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  38161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38162. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38164. * @param name defines the name of the mesh
  38165. * @param options defines the options used to create the mesh
  38166. * @param scene defines the hosting scene
  38167. * @returns the cylinder mesh
  38168. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  38169. */
  38170. static CreateCylinder(name: string, options: {
  38171. height?: number;
  38172. diameterTop?: number;
  38173. diameterBottom?: number;
  38174. diameter?: number;
  38175. tessellation?: number;
  38176. subdivisions?: number;
  38177. arc?: number;
  38178. faceColors?: Color4[];
  38179. faceUV?: Vector4[];
  38180. updatable?: boolean;
  38181. hasRings?: boolean;
  38182. enclose?: boolean;
  38183. sideOrientation?: number;
  38184. frontUVs?: Vector4;
  38185. backUVs?: Vector4;
  38186. }, scene: any): Mesh;
  38187. }
  38188. }
  38189. declare module BABYLON {
  38190. /**
  38191. * Options to modify the vr teleportation behavior.
  38192. */
  38193. export interface VRTeleportationOptions {
  38194. /**
  38195. * The name of the mesh which should be used as the teleportation floor. (default: null)
  38196. */
  38197. floorMeshName?: string;
  38198. /**
  38199. * A list of meshes to be used as the teleportation floor. (default: empty)
  38200. */
  38201. floorMeshes?: Mesh[];
  38202. }
  38203. /**
  38204. * Options to modify the vr experience helper's behavior.
  38205. */
  38206. export interface VRExperienceHelperOptions extends WebVROptions {
  38207. /**
  38208. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  38209. */
  38210. createDeviceOrientationCamera?: boolean;
  38211. /**
  38212. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  38213. */
  38214. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  38215. /**
  38216. * Uses the main button on the controller to toggle the laser casted. (default: true)
  38217. */
  38218. laserToggle?: boolean;
  38219. /**
  38220. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  38221. */
  38222. floorMeshes?: Mesh[];
  38223. }
  38224. /**
  38225. * Helps to quickly add VR support to an existing scene.
  38226. * See http://doc.babylonjs.com/how_to/webvr_helper
  38227. */
  38228. export class VRExperienceHelper {
  38229. /** Options to modify the vr experience helper's behavior. */
  38230. webVROptions: VRExperienceHelperOptions;
  38231. private _scene;
  38232. private _position;
  38233. private _btnVR;
  38234. private _btnVRDisplayed;
  38235. private _webVRsupported;
  38236. private _webVRready;
  38237. private _webVRrequesting;
  38238. private _webVRpresenting;
  38239. private _hasEnteredVR;
  38240. private _fullscreenVRpresenting;
  38241. private _canvas;
  38242. private _webVRCamera;
  38243. private _vrDeviceOrientationCamera;
  38244. private _deviceOrientationCamera;
  38245. private _existingCamera;
  38246. private _onKeyDown;
  38247. private _onVrDisplayPresentChange;
  38248. private _onVRDisplayChanged;
  38249. private _onVRRequestPresentStart;
  38250. private _onVRRequestPresentComplete;
  38251. /**
  38252. * Observable raised when entering VR.
  38253. */
  38254. onEnteringVRObservable: Observable<VRExperienceHelper>;
  38255. /**
  38256. * Observable raised when exiting VR.
  38257. */
  38258. onExitingVRObservable: Observable<VRExperienceHelper>;
  38259. /**
  38260. * Observable raised when controller mesh is loaded.
  38261. */
  38262. onControllerMeshLoadedObservable: Observable<WebVRController>;
  38263. /** Return this.onEnteringVRObservable
  38264. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  38265. */
  38266. readonly onEnteringVR: Observable<VRExperienceHelper>;
  38267. /** Return this.onExitingVRObservable
  38268. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  38269. */
  38270. readonly onExitingVR: Observable<VRExperienceHelper>;
  38271. /** Return this.onControllerMeshLoadedObservable
  38272. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  38273. */
  38274. readonly onControllerMeshLoaded: Observable<WebVRController>;
  38275. private _rayLength;
  38276. private _useCustomVRButton;
  38277. private _teleportationRequested;
  38278. private _teleportActive;
  38279. private _floorMeshName;
  38280. private _floorMeshesCollection;
  38281. private _rotationAllowed;
  38282. private _teleportBackwardsVector;
  38283. private _teleportationTarget;
  38284. private _isDefaultTeleportationTarget;
  38285. private _postProcessMove;
  38286. private _teleportationFillColor;
  38287. private _teleportationBorderColor;
  38288. private _rotationAngle;
  38289. private _haloCenter;
  38290. private _cameraGazer;
  38291. private _padSensibilityUp;
  38292. private _padSensibilityDown;
  38293. private _leftController;
  38294. private _rightController;
  38295. /**
  38296. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  38297. */
  38298. onNewMeshSelected: Observable<AbstractMesh>;
  38299. /**
  38300. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  38301. */
  38302. onNewMeshPicked: Observable<PickingInfo>;
  38303. private _circleEase;
  38304. /**
  38305. * Observable raised before camera teleportation
  38306. */
  38307. onBeforeCameraTeleport: Observable<Vector3>;
  38308. /**
  38309. * Observable raised after camera teleportation
  38310. */
  38311. onAfterCameraTeleport: Observable<Vector3>;
  38312. /**
  38313. * Observable raised when current selected mesh gets unselected
  38314. */
  38315. onSelectedMeshUnselected: Observable<AbstractMesh>;
  38316. private _raySelectionPredicate;
  38317. /**
  38318. * To be optionaly changed by user to define custom ray selection
  38319. */
  38320. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  38321. /**
  38322. * To be optionaly changed by user to define custom selection logic (after ray selection)
  38323. */
  38324. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  38325. /**
  38326. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  38327. */
  38328. teleportationEnabled: boolean;
  38329. private _defaultHeight;
  38330. private _teleportationInitialized;
  38331. private _interactionsEnabled;
  38332. private _interactionsRequested;
  38333. private _displayGaze;
  38334. private _displayLaserPointer;
  38335. /**
  38336. * The mesh used to display where the user is going to teleport.
  38337. */
  38338. /**
  38339. * Sets the mesh to be used to display where the user is going to teleport.
  38340. */
  38341. teleportationTarget: Mesh;
  38342. /**
  38343. * 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
  38344. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  38345. * See http://doc.babylonjs.com/resources/baking_transformations
  38346. */
  38347. gazeTrackerMesh: Mesh;
  38348. /**
  38349. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  38350. */
  38351. updateGazeTrackerScale: boolean;
  38352. /**
  38353. * If the gaze trackers color should be updated when selecting meshes
  38354. */
  38355. updateGazeTrackerColor: boolean;
  38356. /**
  38357. * The gaze tracking mesh corresponding to the left controller
  38358. */
  38359. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  38360. /**
  38361. * The gaze tracking mesh corresponding to the right controller
  38362. */
  38363. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  38364. /**
  38365. * If the ray of the gaze should be displayed.
  38366. */
  38367. /**
  38368. * Sets if the ray of the gaze should be displayed.
  38369. */
  38370. displayGaze: boolean;
  38371. /**
  38372. * If the ray of the LaserPointer should be displayed.
  38373. */
  38374. /**
  38375. * Sets if the ray of the LaserPointer should be displayed.
  38376. */
  38377. displayLaserPointer: boolean;
  38378. /**
  38379. * The deviceOrientationCamera used as the camera when not in VR.
  38380. */
  38381. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  38382. /**
  38383. * Based on the current WebVR support, returns the current VR camera used.
  38384. */
  38385. readonly currentVRCamera: Nullable<Camera>;
  38386. /**
  38387. * The webVRCamera which is used when in VR.
  38388. */
  38389. readonly webVRCamera: WebVRFreeCamera;
  38390. /**
  38391. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  38392. */
  38393. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  38394. private readonly _teleportationRequestInitiated;
  38395. /**
  38396. * Instantiates a VRExperienceHelper.
  38397. * Helps to quickly add VR support to an existing scene.
  38398. * @param scene The scene the VRExperienceHelper belongs to.
  38399. * @param webVROptions Options to modify the vr experience helper's behavior.
  38400. */
  38401. constructor(scene: Scene,
  38402. /** Options to modify the vr experience helper's behavior. */
  38403. webVROptions?: VRExperienceHelperOptions);
  38404. private _onDefaultMeshLoaded;
  38405. private _onResize;
  38406. private _onFullscreenChange;
  38407. /**
  38408. * Gets a value indicating if we are currently in VR mode.
  38409. */
  38410. readonly isInVRMode: boolean;
  38411. private onVrDisplayPresentChange;
  38412. private onVRDisplayChanged;
  38413. private moveButtonToBottomRight;
  38414. private displayVRButton;
  38415. private updateButtonVisibility;
  38416. private _cachedAngularSensibility;
  38417. /**
  38418. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  38419. * Otherwise, will use the fullscreen API.
  38420. */
  38421. enterVR(): void;
  38422. /**
  38423. * Attempt to exit VR, or fullscreen.
  38424. */
  38425. exitVR(): void;
  38426. /**
  38427. * The position of the vr experience helper.
  38428. */
  38429. /**
  38430. * Sets the position of the vr experience helper.
  38431. */
  38432. position: Vector3;
  38433. /**
  38434. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  38435. */
  38436. enableInteractions(): void;
  38437. private readonly _noControllerIsActive;
  38438. private beforeRender;
  38439. private _isTeleportationFloor;
  38440. /**
  38441. * Adds a floor mesh to be used for teleportation.
  38442. * @param floorMesh the mesh to be used for teleportation.
  38443. */
  38444. addFloorMesh(floorMesh: Mesh): void;
  38445. /**
  38446. * Removes a floor mesh from being used for teleportation.
  38447. * @param floorMesh the mesh to be removed.
  38448. */
  38449. removeFloorMesh(floorMesh: Mesh): void;
  38450. /**
  38451. * Enables interactions and teleportation using the VR controllers and gaze.
  38452. * @param vrTeleportationOptions options to modify teleportation behavior.
  38453. */
  38454. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  38455. private _onNewGamepadConnected;
  38456. private _tryEnableInteractionOnController;
  38457. private _onNewGamepadDisconnected;
  38458. private _enableInteractionOnController;
  38459. private _checkTeleportWithRay;
  38460. private _checkRotate;
  38461. private _checkTeleportBackwards;
  38462. private _enableTeleportationOnController;
  38463. private _createTeleportationCircles;
  38464. private _displayTeleportationTarget;
  38465. private _hideTeleportationTarget;
  38466. private _rotateCamera;
  38467. private _moveTeleportationSelectorTo;
  38468. private _workingVector;
  38469. private _workingQuaternion;
  38470. private _workingMatrix;
  38471. /**
  38472. * Teleports the users feet to the desired location
  38473. * @param location The location where the user's feet should be placed
  38474. */
  38475. teleportCamera(location: Vector3): void;
  38476. private _convertNormalToDirectionOfRay;
  38477. private _castRayAndSelectObject;
  38478. private _notifySelectedMeshUnselected;
  38479. /**
  38480. * Sets the color of the laser ray from the vr controllers.
  38481. * @param color new color for the ray.
  38482. */
  38483. changeLaserColor(color: Color3): void;
  38484. /**
  38485. * Sets the color of the ray from the vr headsets gaze.
  38486. * @param color new color for the ray.
  38487. */
  38488. changeGazeColor(color: Color3): void;
  38489. /**
  38490. * Exits VR and disposes of the vr experience helper
  38491. */
  38492. dispose(): void;
  38493. /**
  38494. * Gets the name of the VRExperienceHelper class
  38495. * @returns "VRExperienceHelper"
  38496. */
  38497. getClassName(): string;
  38498. }
  38499. }
  38500. declare module BABYLON {
  38501. /**
  38502. * Manages an XRSession
  38503. * @see https://doc.babylonjs.com/how_to/webxr
  38504. */
  38505. export class WebXRSessionManager implements IDisposable {
  38506. private scene;
  38507. /**
  38508. * Fires every time a new xrFrame arrives which can be used to update the camera
  38509. */
  38510. onXRFrameObservable: Observable<any>;
  38511. /**
  38512. * Fires when the xr session is ended either by the device or manually done
  38513. */
  38514. onXRSessionEnded: Observable<any>;
  38515. /** @hidden */
  38516. _xrSession: XRSession;
  38517. /** @hidden */
  38518. _frameOfReference: XRFrameOfReference;
  38519. /** @hidden */
  38520. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  38521. /** @hidden */
  38522. _currentXRFrame: Nullable<XRFrame>;
  38523. private _xrNavigator;
  38524. private _xrDevice;
  38525. private _tmpMatrix;
  38526. /**
  38527. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  38528. * @param scene The scene which the session should be created for
  38529. */
  38530. constructor(scene: Scene);
  38531. /**
  38532. * Initializes the manager
  38533. * After initialization enterXR can be called to start an XR session
  38534. * @returns Promise which resolves after it is initialized
  38535. */
  38536. initializeAsync(): Promise<void>;
  38537. /**
  38538. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  38539. * @param sessionCreationOptions xr options to create the session with
  38540. * @param frameOfReferenceType option to configure how the xr pose is expressed
  38541. * @returns Promise which resolves after it enters XR
  38542. */
  38543. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  38544. /**
  38545. * Stops the xrSession and restores the renderloop
  38546. * @returns Promise which resolves after it exits XR
  38547. */
  38548. exitXRAsync(): Promise<void>;
  38549. /**
  38550. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  38551. * @param ray ray to cast into the environment
  38552. * @returns Promise which resolves with a collision point in the environment if it exists
  38553. */
  38554. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  38555. /**
  38556. * Checks if a session would be supported for the creation options specified
  38557. * @param options creation options to check if they are supported
  38558. * @returns true if supported
  38559. */
  38560. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  38561. /**
  38562. * @hidden
  38563. * Converts the render layer of xrSession to a render target
  38564. * @param session session to create render target for
  38565. * @param scene scene the new render target should be created for
  38566. */
  38567. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  38568. /**
  38569. * Disposes of the session manager
  38570. */
  38571. dispose(): void;
  38572. }
  38573. }
  38574. declare module BABYLON {
  38575. /**
  38576. * WebXR Camera which holds the views for the xrSession
  38577. * @see https://doc.babylonjs.com/how_to/webxr
  38578. */
  38579. export class WebXRCamera extends FreeCamera {
  38580. private static _TmpMatrix;
  38581. /**
  38582. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  38583. * @param name the name of the camera
  38584. * @param scene the scene to add the camera to
  38585. */
  38586. constructor(name: string, scene: Scene);
  38587. private _updateNumberOfRigCameras;
  38588. /** @hidden */
  38589. _updateForDualEyeDebugging(pupilDistance?: number): void;
  38590. /**
  38591. * Updates the cameras position from the current pose information of the XR session
  38592. * @param xrSessionManager the session containing pose information
  38593. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  38594. */
  38595. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  38596. }
  38597. }
  38598. declare module BABYLON {
  38599. /**
  38600. * States of the webXR experience
  38601. */
  38602. export enum WebXRState {
  38603. /**
  38604. * Transitioning to being in XR mode
  38605. */
  38606. ENTERING_XR = 0,
  38607. /**
  38608. * Transitioning to non XR mode
  38609. */
  38610. EXITING_XR = 1,
  38611. /**
  38612. * In XR mode and presenting
  38613. */
  38614. IN_XR = 2,
  38615. /**
  38616. * Not entered XR mode
  38617. */
  38618. NOT_IN_XR = 3
  38619. }
  38620. /**
  38621. * Helper class used to enable XR
  38622. * @see https://doc.babylonjs.com/how_to/webxr
  38623. */
  38624. export class WebXRExperienceHelper implements IDisposable {
  38625. private scene;
  38626. /**
  38627. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  38628. */
  38629. container: AbstractMesh;
  38630. /**
  38631. * Camera used to render xr content
  38632. */
  38633. camera: WebXRCamera;
  38634. /**
  38635. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  38636. */
  38637. state: WebXRState;
  38638. private _setState;
  38639. private static _TmpVector;
  38640. /**
  38641. * Fires when the state of the experience helper has changed
  38642. */
  38643. onStateChangedObservable: Observable<WebXRState>;
  38644. /** @hidden */
  38645. _sessionManager: WebXRSessionManager;
  38646. private _nonVRCamera;
  38647. private _originalSceneAutoClear;
  38648. private _supported;
  38649. /**
  38650. * Creates the experience helper
  38651. * @param scene the scene to attach the experience helper to
  38652. * @returns a promise for the experience helper
  38653. */
  38654. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  38655. /**
  38656. * Creates a WebXRExperienceHelper
  38657. * @param scene The scene the helper should be created in
  38658. */
  38659. private constructor();
  38660. /**
  38661. * Exits XR mode and returns the scene to its original state
  38662. * @returns promise that resolves after xr mode has exited
  38663. */
  38664. exitXRAsync(): Promise<void>;
  38665. /**
  38666. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  38667. * @param sessionCreationOptions options for the XR session
  38668. * @param frameOfReference frame of reference of the XR session
  38669. * @returns promise that resolves after xr mode has entered
  38670. */
  38671. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  38672. /**
  38673. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  38674. * @param ray ray to cast into the environment
  38675. * @returns Promise which resolves with a collision point in the environment if it exists
  38676. */
  38677. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  38678. /**
  38679. * Updates the global position of the camera by moving the camera's container
  38680. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  38681. * @param position The desired global position of the camera
  38682. */
  38683. setPositionOfCameraUsingContainer(position: Vector3): void;
  38684. /**
  38685. * Rotates the xr camera by rotating the camera's container around the camera's position
  38686. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  38687. * @param rotation the desired quaternion rotation to apply to the camera
  38688. */
  38689. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  38690. /**
  38691. * Checks if the creation options are supported by the xr session
  38692. * @param options creation options
  38693. * @returns true if supported
  38694. */
  38695. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  38696. /**
  38697. * Disposes of the experience helper
  38698. */
  38699. dispose(): void;
  38700. }
  38701. }
  38702. declare module BABYLON {
  38703. /**
  38704. * Button which can be used to enter a different mode of XR
  38705. */
  38706. export class WebXREnterExitUIButton {
  38707. /** button element */
  38708. element: HTMLElement;
  38709. /** XR initialization options for the button */
  38710. initializationOptions: XRSessionCreationOptions;
  38711. /**
  38712. * Creates a WebXREnterExitUIButton
  38713. * @param element button element
  38714. * @param initializationOptions XR initialization options for the button
  38715. */
  38716. constructor(
  38717. /** button element */
  38718. element: HTMLElement,
  38719. /** XR initialization options for the button */
  38720. initializationOptions: XRSessionCreationOptions);
  38721. /**
  38722. * Overwritable function which can be used to update the button's visuals when the state changes
  38723. * @param activeButton the current active button in the UI
  38724. */
  38725. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  38726. }
  38727. /**
  38728. * Options to create the webXR UI
  38729. */
  38730. export class WebXREnterExitUIOptions {
  38731. /**
  38732. * Context to enter xr with
  38733. */
  38734. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  38735. /**
  38736. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  38737. */
  38738. customButtons?: Array<WebXREnterExitUIButton>;
  38739. }
  38740. /**
  38741. * UI to allow the user to enter/exit XR mode
  38742. */
  38743. export class WebXREnterExitUI implements IDisposable {
  38744. private scene;
  38745. private _overlay;
  38746. private _buttons;
  38747. private _activeButton;
  38748. /**
  38749. * Fired every time the active button is changed.
  38750. *
  38751. * When xr is entered via a button that launches xr that button will be the callback parameter
  38752. *
  38753. * When exiting xr the callback parameter will be null)
  38754. */
  38755. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  38756. /**
  38757. * Creates UI to allow the user to enter/exit XR mode
  38758. * @param scene the scene to add the ui to
  38759. * @param helper the xr experience helper to enter/exit xr with
  38760. * @param options options to configure the UI
  38761. * @returns the created ui
  38762. */
  38763. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  38764. private constructor();
  38765. private _updateButtons;
  38766. /**
  38767. * Disposes of the object
  38768. */
  38769. dispose(): void;
  38770. }
  38771. }
  38772. declare module BABYLON {
  38773. /**
  38774. * Represents an XR input
  38775. */
  38776. export class WebXRController {
  38777. /**
  38778. * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if thats the case only the pointer from the head will be availible
  38779. */
  38780. grip?: AbstractMesh;
  38781. /**
  38782. * Pointer which can be used to select objects or attach a visible laser to
  38783. */
  38784. pointer: AbstractMesh;
  38785. /**
  38786. * Creates the controller
  38787. * @see https://doc.babylonjs.com/how_to/webxr
  38788. * @param scene the scene which the controller should be associated to
  38789. */
  38790. constructor(scene: Scene);
  38791. /**
  38792. * Disposes of the object
  38793. */
  38794. dispose(): void;
  38795. }
  38796. /**
  38797. * XR input used to track XR inputs such as controllers/rays
  38798. */
  38799. export class WebXRInput implements IDisposable {
  38800. private helper;
  38801. /**
  38802. * XR controllers being tracked
  38803. */
  38804. controllers: Array<WebXRController>;
  38805. private _tmpMatrix;
  38806. private _frameObserver;
  38807. /**
  38808. * Initializes the WebXRInput
  38809. * @param helper experience helper which the input should be created for
  38810. */
  38811. constructor(helper: WebXRExperienceHelper);
  38812. /**
  38813. * Disposes of the object
  38814. */
  38815. dispose(): void;
  38816. }
  38817. }
  38818. declare module BABYLON {
  38819. /**
  38820. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  38821. */
  38822. export class WebXRManagedOutputCanvas implements IDisposable {
  38823. private _canvas;
  38824. /**
  38825. * xrpresent context of the canvas which can be used to display/mirror xr content
  38826. */
  38827. canvasContext: Nullable<WebGLRenderingContext>;
  38828. /**
  38829. * Initializes the canvas to be added/removed upon entering/exiting xr
  38830. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  38831. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  38832. */
  38833. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  38834. /**
  38835. * Disposes of the object
  38836. */
  38837. dispose(): void;
  38838. private _setManagedOutputCanvas;
  38839. private _addCanvas;
  38840. private _removeCanvas;
  38841. }
  38842. }
  38843. declare module BABYLON {
  38844. /**
  38845. * Contains an array of blocks representing the octree
  38846. */
  38847. export interface IOctreeContainer<T> {
  38848. /**
  38849. * Blocks within the octree
  38850. */
  38851. blocks: Array<OctreeBlock<T>>;
  38852. }
  38853. /**
  38854. * Class used to store a cell in an octree
  38855. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38856. */
  38857. export class OctreeBlock<T> {
  38858. /**
  38859. * Gets the content of the current block
  38860. */
  38861. entries: T[];
  38862. /**
  38863. * Gets the list of block children
  38864. */
  38865. blocks: Array<OctreeBlock<T>>;
  38866. private _depth;
  38867. private _maxDepth;
  38868. private _capacity;
  38869. private _minPoint;
  38870. private _maxPoint;
  38871. private _boundingVectors;
  38872. private _creationFunc;
  38873. /**
  38874. * Creates a new block
  38875. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  38876. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  38877. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  38878. * @param depth defines the current depth of this block in the octree
  38879. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  38880. * @param creationFunc defines a callback to call when an element is added to the block
  38881. */
  38882. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  38883. /**
  38884. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  38885. */
  38886. readonly capacity: number;
  38887. /**
  38888. * Gets the minimum vector (in world space) of the block's bounding box
  38889. */
  38890. readonly minPoint: Vector3;
  38891. /**
  38892. * Gets the maximum vector (in world space) of the block's bounding box
  38893. */
  38894. readonly maxPoint: Vector3;
  38895. /**
  38896. * Add a new element to this block
  38897. * @param entry defines the element to add
  38898. */
  38899. addEntry(entry: T): void;
  38900. /**
  38901. * Remove an element from this block
  38902. * @param entry defines the element to remove
  38903. */
  38904. removeEntry(entry: T): void;
  38905. /**
  38906. * Add an array of elements to this block
  38907. * @param entries defines the array of elements to add
  38908. */
  38909. addEntries(entries: T[]): void;
  38910. /**
  38911. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  38912. * @param frustumPlanes defines the frustum planes to test
  38913. * @param selection defines the array to store current content if selection is positive
  38914. * @param allowDuplicate defines if the selection array can contains duplicated entries
  38915. */
  38916. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  38917. /**
  38918. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  38919. * @param sphereCenter defines the bounding sphere center
  38920. * @param sphereRadius defines the bounding sphere radius
  38921. * @param selection defines the array to store current content if selection is positive
  38922. * @param allowDuplicate defines if the selection array can contains duplicated entries
  38923. */
  38924. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  38925. /**
  38926. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  38927. * @param ray defines the ray to test with
  38928. * @param selection defines the array to store current content if selection is positive
  38929. */
  38930. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  38931. /**
  38932. * Subdivide the content into child blocks (this block will then be empty)
  38933. */
  38934. createInnerBlocks(): void;
  38935. /**
  38936. * @hidden
  38937. */
  38938. 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;
  38939. }
  38940. }
  38941. declare module BABYLON {
  38942. /**
  38943. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  38944. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38945. */
  38946. export class Octree<T> {
  38947. /** 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.) */
  38948. maxDepth: number;
  38949. /**
  38950. * Blocks within the octree containing objects
  38951. */
  38952. blocks: Array<OctreeBlock<T>>;
  38953. /**
  38954. * Content stored in the octree
  38955. */
  38956. dynamicContent: T[];
  38957. private _maxBlockCapacity;
  38958. private _selectionContent;
  38959. private _creationFunc;
  38960. /**
  38961. * Creates a octree
  38962. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  38963. * @param creationFunc function to be used to instatiate the octree
  38964. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  38965. * @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.)
  38966. */
  38967. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  38968. /** 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.) */
  38969. maxDepth?: number);
  38970. /**
  38971. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  38972. * @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);
  38973. * @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);
  38974. * @param entries meshes to be added to the octree blocks
  38975. */
  38976. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  38977. /**
  38978. * Adds a mesh to the octree
  38979. * @param entry Mesh to add to the octree
  38980. */
  38981. addMesh(entry: T): void;
  38982. /**
  38983. * Remove an element from the octree
  38984. * @param entry defines the element to remove
  38985. */
  38986. removeMesh(entry: T): void;
  38987. /**
  38988. * Selects an array of meshes within the frustum
  38989. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  38990. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  38991. * @returns array of meshes within the frustum
  38992. */
  38993. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  38994. /**
  38995. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  38996. * @param sphereCenter defines the bounding sphere center
  38997. * @param sphereRadius defines the bounding sphere radius
  38998. * @param allowDuplicate defines if the selection array can contains duplicated entries
  38999. * @returns an array of objects that intersect the sphere
  39000. */
  39001. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  39002. /**
  39003. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  39004. * @param ray defines the ray to test with
  39005. * @returns array of intersected objects
  39006. */
  39007. intersectsRay(ray: Ray): SmartArray<T>;
  39008. /**
  39009. * Adds a mesh into the octree block if it intersects the block
  39010. */
  39011. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  39012. /**
  39013. * Adds a submesh into the octree block if it intersects the block
  39014. */
  39015. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  39016. }
  39017. }
  39018. declare module BABYLON {
  39019. interface Scene {
  39020. /**
  39021. * @hidden
  39022. * Backing Filed
  39023. */
  39024. _selectionOctree: Octree<AbstractMesh>;
  39025. /**
  39026. * Gets the octree used to boost mesh selection (picking)
  39027. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39028. */
  39029. selectionOctree: Octree<AbstractMesh>;
  39030. /**
  39031. * Creates or updates the octree used to boost selection (picking)
  39032. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39033. * @param maxCapacity defines the maximum capacity per leaf
  39034. * @param maxDepth defines the maximum depth of the octree
  39035. * @returns an octree of AbstractMesh
  39036. */
  39037. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  39038. }
  39039. interface AbstractMesh {
  39040. /**
  39041. * @hidden
  39042. * Backing Field
  39043. */
  39044. _submeshesOctree: Octree<SubMesh>;
  39045. /**
  39046. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  39047. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  39048. * @param maxCapacity defines the maximum size of each block (64 by default)
  39049. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  39050. * @returns the new octree
  39051. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  39052. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39053. */
  39054. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  39055. }
  39056. /**
  39057. * Defines the octree scene component responsible to manage any octrees
  39058. * in a given scene.
  39059. */
  39060. export class OctreeSceneComponent {
  39061. /**
  39062. * The component name helpfull to identify the component in the list of scene components.
  39063. */
  39064. readonly name: string;
  39065. /**
  39066. * The scene the component belongs to.
  39067. */
  39068. scene: Scene;
  39069. /**
  39070. * Indicates if the meshes have been checked to make sure they are isEnabled()
  39071. */
  39072. readonly checksIsEnabled: boolean;
  39073. /**
  39074. * Creates a new instance of the component for the given scene
  39075. * @param scene Defines the scene to register the component in
  39076. */
  39077. constructor(scene: Scene);
  39078. /**
  39079. * Registers the component in a given scene
  39080. */
  39081. register(): void;
  39082. /**
  39083. * Return the list of active meshes
  39084. * @returns the list of active meshes
  39085. */
  39086. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39087. /**
  39088. * Return the list of active sub meshes
  39089. * @param mesh The mesh to get the candidates sub meshes from
  39090. * @returns the list of active sub meshes
  39091. */
  39092. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39093. private _tempRay;
  39094. /**
  39095. * Return the list of sub meshes intersecting with a given local ray
  39096. * @param mesh defines the mesh to find the submesh for
  39097. * @param localRay defines the ray in local space
  39098. * @returns the list of intersecting sub meshes
  39099. */
  39100. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  39101. /**
  39102. * Return the list of sub meshes colliding with a collider
  39103. * @param mesh defines the mesh to find the submesh for
  39104. * @param collider defines the collider to evaluate the collision against
  39105. * @returns the list of colliding sub meshes
  39106. */
  39107. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  39108. /**
  39109. * Rebuilds the elements related to this component in case of
  39110. * context lost for instance.
  39111. */
  39112. rebuild(): void;
  39113. /**
  39114. * Disposes the component and the associated ressources.
  39115. */
  39116. dispose(): void;
  39117. }
  39118. }
  39119. declare module BABYLON {
  39120. /**
  39121. * Class containing static functions to help procedurally build meshes
  39122. */
  39123. export class LinesBuilder {
  39124. /**
  39125. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  39126. * * 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
  39127. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  39128. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  39129. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  39130. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  39131. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  39132. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  39133. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  39134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39135. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  39136. * @param name defines the name of the new line system
  39137. * @param options defines the options used to create the line system
  39138. * @param scene defines the hosting scene
  39139. * @returns a new line system mesh
  39140. */
  39141. static CreateLineSystem(name: string, options: {
  39142. lines: Vector3[][];
  39143. updatable?: boolean;
  39144. instance?: Nullable<LinesMesh>;
  39145. colors?: Nullable<Color4[][]>;
  39146. useVertexAlpha?: boolean;
  39147. }, scene: Nullable<Scene>): LinesMesh;
  39148. /**
  39149. * Creates a line mesh
  39150. * 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
  39151. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  39152. * * The parameter `points` is an array successive Vector3
  39153. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  39154. * * The optional parameter `colors` is an array of successive Color4, one per line point
  39155. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  39156. * * When updating an instance, remember that only point positions can change, not the number of points
  39157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39158. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  39159. * @param name defines the name of the new line system
  39160. * @param options defines the options used to create the line system
  39161. * @param scene defines the hosting scene
  39162. * @returns a new line mesh
  39163. */
  39164. static CreateLines(name: string, options: {
  39165. points: Vector3[];
  39166. updatable?: boolean;
  39167. instance?: Nullable<LinesMesh>;
  39168. colors?: Color4[];
  39169. useVertexAlpha?: boolean;
  39170. }, scene?: Nullable<Scene>): LinesMesh;
  39171. /**
  39172. * Creates a dashed line mesh
  39173. * * 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
  39174. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  39175. * * The parameter `points` is an array successive Vector3
  39176. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  39177. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  39178. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  39179. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  39180. * * When updating an instance, remember that only point positions can change, not the number of points
  39181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39182. * @param name defines the name of the mesh
  39183. * @param options defines the options used to create the mesh
  39184. * @param scene defines the hosting scene
  39185. * @returns the dashed line mesh
  39186. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  39187. */
  39188. static CreateDashedLines(name: string, options: {
  39189. points: Vector3[];
  39190. dashSize?: number;
  39191. gapSize?: number;
  39192. dashNb?: number;
  39193. updatable?: boolean;
  39194. instance?: LinesMesh;
  39195. }, scene?: Nullable<Scene>): LinesMesh;
  39196. }
  39197. }
  39198. declare module BABYLON {
  39199. /**
  39200. * Renders a layer on top of an existing scene
  39201. */
  39202. export class UtilityLayerRenderer implements IDisposable {
  39203. /** the original scene that will be rendered on top of */
  39204. originalScene: Scene;
  39205. private _pointerCaptures;
  39206. private _lastPointerEvents;
  39207. private static _DefaultUtilityLayer;
  39208. private static _DefaultKeepDepthUtilityLayer;
  39209. /**
  39210. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  39211. */
  39212. pickUtilitySceneFirst: boolean;
  39213. /**
  39214. * 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)
  39215. */
  39216. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  39217. /**
  39218. * 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)
  39219. */
  39220. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  39221. /**
  39222. * The scene that is rendered on top of the original scene
  39223. */
  39224. utilityLayerScene: Scene;
  39225. /**
  39226. * If the utility layer should automatically be rendered on top of existing scene
  39227. */
  39228. shouldRender: boolean;
  39229. /**
  39230. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  39231. */
  39232. onlyCheckPointerDownEvents: boolean;
  39233. /**
  39234. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  39235. */
  39236. processAllEvents: boolean;
  39237. /**
  39238. * Observable raised when the pointer move from the utility layer scene to the main scene
  39239. */
  39240. onPointerOutObservable: Observable<number>;
  39241. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  39242. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  39243. private _afterRenderObserver;
  39244. private _sceneDisposeObserver;
  39245. private _originalPointerObserver;
  39246. /**
  39247. * Instantiates a UtilityLayerRenderer
  39248. * @param originalScene the original scene that will be rendered on top of
  39249. * @param handleEvents boolean indicating if the utility layer should handle events
  39250. */
  39251. constructor(
  39252. /** the original scene that will be rendered on top of */
  39253. originalScene: Scene, handleEvents?: boolean);
  39254. private _notifyObservers;
  39255. /**
  39256. * Renders the utility layers scene on top of the original scene
  39257. */
  39258. render(): void;
  39259. /**
  39260. * Disposes of the renderer
  39261. */
  39262. dispose(): void;
  39263. private _updateCamera;
  39264. }
  39265. }
  39266. declare module BABYLON {
  39267. /**
  39268. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  39269. */
  39270. export class Gizmo implements IDisposable {
  39271. /** The utility layer the gizmo will be added to */
  39272. gizmoLayer: UtilityLayerRenderer;
  39273. /**
  39274. * The root mesh of the gizmo
  39275. */
  39276. protected _rootMesh: Mesh;
  39277. private _attachedMesh;
  39278. /**
  39279. * Ratio for the scale of the gizmo (Default: 1)
  39280. */
  39281. scaleRatio: number;
  39282. private _tmpMatrix;
  39283. /**
  39284. * If a custom mesh has been set (Default: false)
  39285. */
  39286. protected _customMeshSet: boolean;
  39287. /**
  39288. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  39289. * * When set, interactions will be enabled
  39290. */
  39291. attachedMesh: Nullable<AbstractMesh>;
  39292. /**
  39293. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  39294. * @param mesh The mesh to replace the default mesh of the gizmo
  39295. */
  39296. setCustomMesh(mesh: Mesh): void;
  39297. /**
  39298. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  39299. */
  39300. updateGizmoRotationToMatchAttachedMesh: boolean;
  39301. /**
  39302. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  39303. */
  39304. updateGizmoPositionToMatchAttachedMesh: boolean;
  39305. /**
  39306. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  39307. */
  39308. protected _updateScale: boolean;
  39309. protected _interactionsEnabled: boolean;
  39310. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  39311. private _beforeRenderObserver;
  39312. /**
  39313. * Creates a gizmo
  39314. * @param gizmoLayer The utility layer the gizmo will be added to
  39315. */
  39316. constructor(
  39317. /** The utility layer the gizmo will be added to */
  39318. gizmoLayer?: UtilityLayerRenderer);
  39319. private _tempVector;
  39320. /**
  39321. * @hidden
  39322. * Updates the gizmo to match the attached mesh's position/rotation
  39323. */
  39324. protected _update(): void;
  39325. /**
  39326. * Disposes of the gizmo
  39327. */
  39328. dispose(): void;
  39329. }
  39330. }
  39331. declare module BABYLON {
  39332. /**
  39333. * Single axis drag gizmo
  39334. */
  39335. export class AxisDragGizmo extends Gizmo {
  39336. /**
  39337. * Drag behavior responsible for the gizmos dragging interactions
  39338. */
  39339. dragBehavior: PointerDragBehavior;
  39340. private _pointerObserver;
  39341. /**
  39342. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39343. */
  39344. snapDistance: number;
  39345. /**
  39346. * Event that fires each time the gizmo snaps to a new location.
  39347. * * snapDistance is the the change in distance
  39348. */
  39349. onSnapObservable: Observable<{
  39350. snapDistance: number;
  39351. }>;
  39352. /** @hidden */
  39353. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  39354. /** @hidden */
  39355. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  39356. /**
  39357. * Creates an AxisDragGizmo
  39358. * @param gizmoLayer The utility layer the gizmo will be added to
  39359. * @param dragAxis The axis which the gizmo will be able to drag on
  39360. * @param color The color of the gizmo
  39361. */
  39362. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  39363. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  39364. /**
  39365. * Disposes of the gizmo
  39366. */
  39367. dispose(): void;
  39368. }
  39369. }
  39370. declare module BABYLON.Debug {
  39371. /**
  39372. * The Axes viewer will show 3 axes in a specific point in space
  39373. */
  39374. export class AxesViewer {
  39375. private _xAxis;
  39376. private _yAxis;
  39377. private _zAxis;
  39378. private _scaleLinesFactor;
  39379. private _instanced;
  39380. /**
  39381. * Gets the hosting scene
  39382. */
  39383. scene: Scene;
  39384. /**
  39385. * Gets or sets a number used to scale line length
  39386. */
  39387. scaleLines: number;
  39388. /** Gets the node hierarchy used to render x-axis */
  39389. readonly xAxis: TransformNode;
  39390. /** Gets the node hierarchy used to render y-axis */
  39391. readonly yAxis: TransformNode;
  39392. /** Gets the node hierarchy used to render z-axis */
  39393. readonly zAxis: TransformNode;
  39394. /**
  39395. * Creates a new AxesViewer
  39396. * @param scene defines the hosting scene
  39397. * @param scaleLines defines a number used to scale line length (1 by default)
  39398. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  39399. * @param xAxis defines the node hierarchy used to render the x-axis
  39400. * @param yAxis defines the node hierarchy used to render the y-axis
  39401. * @param zAxis defines the node hierarchy used to render the z-axis
  39402. */
  39403. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  39404. /**
  39405. * Force the viewer to update
  39406. * @param position defines the position of the viewer
  39407. * @param xaxis defines the x axis of the viewer
  39408. * @param yaxis defines the y axis of the viewer
  39409. * @param zaxis defines the z axis of the viewer
  39410. */
  39411. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  39412. /**
  39413. * Creates an instance of this axes viewer.
  39414. * @returns a new axes viewer with instanced meshes
  39415. */
  39416. createInstance(): AxesViewer;
  39417. /** Releases resources */
  39418. dispose(): void;
  39419. private static _SetRenderingGroupId;
  39420. }
  39421. }
  39422. declare module BABYLON.Debug {
  39423. /**
  39424. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  39425. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  39426. */
  39427. export class BoneAxesViewer extends AxesViewer {
  39428. /**
  39429. * Gets or sets the target mesh where to display the axes viewer
  39430. */
  39431. mesh: Nullable<Mesh>;
  39432. /**
  39433. * Gets or sets the target bone where to display the axes viewer
  39434. */
  39435. bone: Nullable<Bone>;
  39436. /** Gets current position */
  39437. pos: Vector3;
  39438. /** Gets direction of X axis */
  39439. xaxis: Vector3;
  39440. /** Gets direction of Y axis */
  39441. yaxis: Vector3;
  39442. /** Gets direction of Z axis */
  39443. zaxis: Vector3;
  39444. /**
  39445. * Creates a new BoneAxesViewer
  39446. * @param scene defines the hosting scene
  39447. * @param bone defines the target bone
  39448. * @param mesh defines the target mesh
  39449. * @param scaleLines defines a scaling factor for line length (1 by default)
  39450. */
  39451. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  39452. /**
  39453. * Force the viewer to update
  39454. */
  39455. update(): void;
  39456. /** Releases resources */
  39457. dispose(): void;
  39458. }
  39459. }
  39460. declare module BABYLON {
  39461. /**
  39462. * Interface used to define scene explorer extensibility option
  39463. */
  39464. export interface IExplorerExtensibilityOption {
  39465. /**
  39466. * Define the option label
  39467. */
  39468. label: string;
  39469. /**
  39470. * Defines the action to execute on click
  39471. */
  39472. action: (entity: any) => void;
  39473. }
  39474. /**
  39475. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  39476. */
  39477. export interface IExplorerExtensibilityGroup {
  39478. /**
  39479. * Defines a predicate to test if a given type mut be extended
  39480. */
  39481. predicate: (entity: any) => boolean;
  39482. /**
  39483. * Gets the list of options added to a type
  39484. */
  39485. entries: IExplorerExtensibilityOption[];
  39486. }
  39487. /**
  39488. * Interface used to define the options to use to create the Inspector
  39489. */
  39490. export interface IInspectorOptions {
  39491. /**
  39492. * Display in overlay mode (default: false)
  39493. */
  39494. overlay?: boolean;
  39495. /**
  39496. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  39497. */
  39498. globalRoot?: HTMLElement;
  39499. /**
  39500. * Display the Scene explorer
  39501. */
  39502. showExplorer?: boolean;
  39503. /**
  39504. * Display the property inspector
  39505. */
  39506. showInspector?: boolean;
  39507. /**
  39508. * Display in embed mode (both panes on the right)
  39509. */
  39510. embedMode?: boolean;
  39511. /**
  39512. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  39513. */
  39514. handleResize?: boolean;
  39515. /**
  39516. * Allow the panes to popup (default: true)
  39517. */
  39518. enablePopup?: boolean;
  39519. /**
  39520. * Allow the panes to be closed by users (default: true)
  39521. */
  39522. enableClose?: boolean;
  39523. /**
  39524. * Optional list of extensibility entries
  39525. */
  39526. explorerExtensibility?: IExplorerExtensibilityGroup[];
  39527. }
  39528. interface Scene {
  39529. /**
  39530. * @hidden
  39531. * Backing field
  39532. */
  39533. _debugLayer: DebugLayer;
  39534. /**
  39535. * Gets the debug layer (aka Inspector) associated with the scene
  39536. * @see http://doc.babylonjs.com/features/playground_debuglayer
  39537. */
  39538. debugLayer: DebugLayer;
  39539. }
  39540. /**
  39541. * The debug layer (aka Inspector) is the go to tool in order to better understand
  39542. * what is happening in your scene
  39543. * @see http://doc.babylonjs.com/features/playground_debuglayer
  39544. */
  39545. export class DebugLayer {
  39546. /**
  39547. * Define the url to get the inspector script from.
  39548. * By default it uses the babylonjs CDN.
  39549. * @ignoreNaming
  39550. */
  39551. static InspectorURL: string;
  39552. private _scene;
  39553. private BJSINSPECTOR;
  39554. /**
  39555. * Observable triggered when a property is changed through the inspector.
  39556. */
  39557. onPropertyChangedObservable: Observable<{
  39558. object: any;
  39559. property: string;
  39560. value: any;
  39561. initialValue: any;
  39562. }>;
  39563. /**
  39564. * Instantiates a new debug layer.
  39565. * The debug layer (aka Inspector) is the go to tool in order to better understand
  39566. * what is happening in your scene
  39567. * @see http://doc.babylonjs.com/features/playground_debuglayer
  39568. * @param scene Defines the scene to inspect
  39569. */
  39570. constructor(scene: Scene);
  39571. /** Creates the inspector window. */
  39572. private _createInspector;
  39573. /** Get the inspector from bundle or global */
  39574. private _getGlobalInspector;
  39575. /**
  39576. * Get if the inspector is visible or not.
  39577. * @returns true if visible otherwise, false
  39578. */
  39579. isVisible(): boolean;
  39580. /**
  39581. * Hide the inspector and close its window.
  39582. */
  39583. hide(): void;
  39584. /**
  39585. * Launch the debugLayer.
  39586. * @param config Define the configuration of the inspector
  39587. */
  39588. show(config?: IInspectorOptions): void;
  39589. }
  39590. }
  39591. declare module BABYLON {
  39592. /**
  39593. * Class containing static functions to help procedurally build meshes
  39594. */
  39595. export class BoxBuilder {
  39596. /**
  39597. * Creates a box mesh
  39598. * * The parameter `size` sets the size (float) of each box side (default 1)
  39599. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  39600. * * 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)
  39601. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  39602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39603. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39605. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  39606. * @param name defines the name of the mesh
  39607. * @param options defines the options used to create the mesh
  39608. * @param scene defines the hosting scene
  39609. * @returns the box mesh
  39610. */
  39611. static CreateBox(name: string, options: {
  39612. size?: number;
  39613. width?: number;
  39614. height?: number;
  39615. depth?: number;
  39616. faceUV?: Vector4[];
  39617. faceColors?: Color4[];
  39618. sideOrientation?: number;
  39619. frontUVs?: Vector4;
  39620. backUVs?: Vector4;
  39621. updatable?: boolean;
  39622. }, scene?: Nullable<Scene>): Mesh;
  39623. }
  39624. }
  39625. declare module BABYLON {
  39626. /**
  39627. * Class containing static functions to help procedurally build meshes
  39628. */
  39629. export class SphereBuilder {
  39630. /**
  39631. * Creates a sphere mesh
  39632. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  39633. * * 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`)
  39634. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  39635. * * 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
  39636. * * 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)
  39637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39640. * @param name defines the name of the mesh
  39641. * @param options defines the options used to create the mesh
  39642. * @param scene defines the hosting scene
  39643. * @returns the sphere mesh
  39644. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  39645. */
  39646. static CreateSphere(name: string, options: {
  39647. segments?: number;
  39648. diameter?: number;
  39649. diameterX?: number;
  39650. diameterY?: number;
  39651. diameterZ?: number;
  39652. arc?: number;
  39653. slice?: number;
  39654. sideOrientation?: number;
  39655. frontUVs?: Vector4;
  39656. backUVs?: Vector4;
  39657. updatable?: boolean;
  39658. }, scene: any): Mesh;
  39659. }
  39660. }
  39661. declare module BABYLON.Debug {
  39662. /**
  39663. * Used to show the physics impostor around the specific mesh
  39664. */
  39665. export class PhysicsViewer {
  39666. /** @hidden */
  39667. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  39668. /** @hidden */
  39669. protected _meshes: Array<Nullable<AbstractMesh>>;
  39670. /** @hidden */
  39671. protected _scene: Nullable<Scene>;
  39672. /** @hidden */
  39673. protected _numMeshes: number;
  39674. /** @hidden */
  39675. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  39676. private _renderFunction;
  39677. private _utilityLayer;
  39678. private _debugBoxMesh;
  39679. private _debugSphereMesh;
  39680. private _debugMaterial;
  39681. /**
  39682. * Creates a new PhysicsViewer
  39683. * @param scene defines the hosting scene
  39684. */
  39685. constructor(scene: Scene);
  39686. /** @hidden */
  39687. protected _updateDebugMeshes(): void;
  39688. /**
  39689. * Renders a specified physic impostor
  39690. * @param impostor defines the impostor to render
  39691. * @returns the new debug mesh used to render the impostor
  39692. */
  39693. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  39694. /**
  39695. * Hides a specified physic impostor
  39696. * @param impostor defines the impostor to hide
  39697. */
  39698. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  39699. private _getDebugMaterial;
  39700. private _getDebugBoxMesh;
  39701. private _getDebugSphereMesh;
  39702. private _getDebugMesh;
  39703. /** Releases all resources */
  39704. dispose(): void;
  39705. }
  39706. }
  39707. declare module BABYLON {
  39708. /**
  39709. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  39710. * in order to better appreciate the issue one might have.
  39711. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  39712. */
  39713. export class RayHelper {
  39714. /**
  39715. * Defines the ray we are currently tryin to visualize.
  39716. */
  39717. ray: Nullable<Ray>;
  39718. private _renderPoints;
  39719. private _renderLine;
  39720. private _renderFunction;
  39721. private _scene;
  39722. private _updateToMeshFunction;
  39723. private _attachedToMesh;
  39724. private _meshSpaceDirection;
  39725. private _meshSpaceOrigin;
  39726. /**
  39727. * Helper function to create a colored helper in a scene in one line.
  39728. * @param ray Defines the ray we are currently tryin to visualize
  39729. * @param scene Defines the scene the ray is used in
  39730. * @param color Defines the color we want to see the ray in
  39731. * @returns The newly created ray helper.
  39732. */
  39733. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  39734. /**
  39735. * Instantiate a new ray helper.
  39736. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  39737. * in order to better appreciate the issue one might have.
  39738. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  39739. * @param ray Defines the ray we are currently tryin to visualize
  39740. */
  39741. constructor(ray: Ray);
  39742. /**
  39743. * Shows the ray we are willing to debug.
  39744. * @param scene Defines the scene the ray needs to be rendered in
  39745. * @param color Defines the color the ray needs to be rendered in
  39746. */
  39747. show(scene: Scene, color?: Color3): void;
  39748. /**
  39749. * Hides the ray we are debugging.
  39750. */
  39751. hide(): void;
  39752. private _render;
  39753. /**
  39754. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  39755. * @param mesh Defines the mesh we want the helper attached to
  39756. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  39757. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  39758. * @param length Defines the length of the ray
  39759. */
  39760. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  39761. /**
  39762. * Detach the ray helper from the mesh it has previously been attached to.
  39763. */
  39764. detachFromMesh(): void;
  39765. private _updateToMesh;
  39766. /**
  39767. * Dispose the helper and release its associated resources.
  39768. */
  39769. dispose(): void;
  39770. }
  39771. }
  39772. declare module BABYLON.Debug {
  39773. /**
  39774. * Class used to render a debug view of a given skeleton
  39775. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  39776. */
  39777. export class SkeletonViewer {
  39778. /** defines the skeleton to render */
  39779. skeleton: Skeleton;
  39780. /** defines the mesh attached to the skeleton */
  39781. mesh: AbstractMesh;
  39782. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  39783. autoUpdateBonesMatrices: boolean;
  39784. /** defines the rendering group id to use with the viewer */
  39785. renderingGroupId: number;
  39786. /** Gets or sets the color used to render the skeleton */
  39787. color: Color3;
  39788. private _scene;
  39789. private _debugLines;
  39790. private _debugMesh;
  39791. private _isEnabled;
  39792. private _renderFunction;
  39793. private _utilityLayer;
  39794. /**
  39795. * Returns the mesh used to render the bones
  39796. */
  39797. readonly debugMesh: Nullable<LinesMesh>;
  39798. /**
  39799. * Creates a new SkeletonViewer
  39800. * @param skeleton defines the skeleton to render
  39801. * @param mesh defines the mesh attached to the skeleton
  39802. * @param scene defines the hosting scene
  39803. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  39804. * @param renderingGroupId defines the rendering group id to use with the viewer
  39805. */
  39806. constructor(
  39807. /** defines the skeleton to render */
  39808. skeleton: Skeleton,
  39809. /** defines the mesh attached to the skeleton */
  39810. mesh: AbstractMesh, scene: Scene,
  39811. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  39812. autoUpdateBonesMatrices?: boolean,
  39813. /** defines the rendering group id to use with the viewer */
  39814. renderingGroupId?: number);
  39815. /** Gets or sets a boolean indicating if the viewer is enabled */
  39816. isEnabled: boolean;
  39817. private _getBonePosition;
  39818. private _getLinesForBonesWithLength;
  39819. private _getLinesForBonesNoLength;
  39820. /** Update the viewer to sync with current skeleton state */
  39821. update(): void;
  39822. /** Release associated resources */
  39823. dispose(): void;
  39824. }
  39825. }
  39826. declare module BABYLON {
  39827. /**
  39828. * Options to create the null engine
  39829. */
  39830. export class NullEngineOptions {
  39831. /**
  39832. * Render width (Default: 512)
  39833. */
  39834. renderWidth: number;
  39835. /**
  39836. * Render height (Default: 256)
  39837. */
  39838. renderHeight: number;
  39839. /**
  39840. * Texture size (Default: 512)
  39841. */
  39842. textureSize: number;
  39843. /**
  39844. * If delta time between frames should be constant
  39845. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39846. */
  39847. deterministicLockstep: boolean;
  39848. /**
  39849. * Maximum about of steps between frames (Default: 4)
  39850. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39851. */
  39852. lockstepMaxSteps: number;
  39853. }
  39854. /**
  39855. * The null engine class provides support for headless version of babylon.js.
  39856. * This can be used in server side scenario or for testing purposes
  39857. */
  39858. export class NullEngine extends Engine {
  39859. private _options;
  39860. /**
  39861. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39862. */
  39863. isDeterministicLockStep(): boolean;
  39864. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  39865. getLockstepMaxSteps(): number;
  39866. /**
  39867. * Sets hardware scaling, used to save performance if needed
  39868. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39869. */
  39870. getHardwareScalingLevel(): number;
  39871. constructor(options?: NullEngineOptions);
  39872. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  39873. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  39874. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  39875. getRenderWidth(useScreen?: boolean): number;
  39876. getRenderHeight(useScreen?: boolean): number;
  39877. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  39878. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  39879. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  39880. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  39881. bindSamplers(effect: Effect): void;
  39882. enableEffect(effect: Effect): void;
  39883. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  39884. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  39885. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  39886. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  39887. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  39888. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  39889. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  39890. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  39891. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  39892. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  39893. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  39894. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  39895. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  39896. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  39897. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  39898. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  39899. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  39900. setFloat(uniform: WebGLUniformLocation, value: number): void;
  39901. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  39902. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  39903. setBool(uniform: WebGLUniformLocation, bool: number): void;
  39904. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  39905. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  39906. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  39907. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  39908. bindBuffers(vertexBuffers: {
  39909. [key: string]: VertexBuffer;
  39910. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  39911. wipeCaches(bruteForce?: boolean): void;
  39912. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39913. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39914. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39915. /** @hidden */
  39916. _createTexture(): WebGLTexture;
  39917. /** @hidden */
  39918. _releaseTexture(texture: InternalTexture): void;
  39919. 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;
  39920. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  39921. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  39922. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  39923. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  39924. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  39925. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  39926. areAllEffectsReady(): boolean;
  39927. /**
  39928. * @hidden
  39929. * Get the current error code of the webGL context
  39930. * @returns the error code
  39931. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  39932. */
  39933. getError(): number;
  39934. /** @hidden */
  39935. _getUnpackAlignement(): number;
  39936. /** @hidden */
  39937. _unpackFlipY(value: boolean): void;
  39938. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  39939. /**
  39940. * Updates a dynamic vertex buffer.
  39941. * @param vertexBuffer the vertex buffer to update
  39942. * @param data the data used to update the vertex buffer
  39943. * @param byteOffset the byte offset of the data (optional)
  39944. * @param byteLength the byte length of the data (optional)
  39945. */
  39946. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  39947. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  39948. /** @hidden */
  39949. _bindTexture(channel: number, texture: InternalTexture): void;
  39950. /** @hidden */
  39951. _releaseBuffer(buffer: WebGLBuffer): boolean;
  39952. releaseEffects(): void;
  39953. displayLoadingUI(): void;
  39954. hideLoadingUI(): void;
  39955. /** @hidden */
  39956. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39957. /** @hidden */
  39958. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39959. /** @hidden */
  39960. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39961. /** @hidden */
  39962. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  39963. }
  39964. }
  39965. declare module BABYLON {
  39966. /** @hidden */
  39967. export class _OcclusionDataStorage {
  39968. /** @hidden */
  39969. occlusionInternalRetryCounter: number;
  39970. /** @hidden */
  39971. isOcclusionQueryInProgress: boolean;
  39972. /** @hidden */
  39973. isOccluded: boolean;
  39974. /** @hidden */
  39975. occlusionRetryCount: number;
  39976. /** @hidden */
  39977. occlusionType: number;
  39978. /** @hidden */
  39979. occlusionQueryAlgorithmType: number;
  39980. }
  39981. interface Engine {
  39982. /**
  39983. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  39984. * @return the new query
  39985. */
  39986. createQuery(): WebGLQuery;
  39987. /**
  39988. * Delete and release a webGL query
  39989. * @param query defines the query to delete
  39990. * @return the current engine
  39991. */
  39992. deleteQuery(query: WebGLQuery): Engine;
  39993. /**
  39994. * Check if a given query has resolved and got its value
  39995. * @param query defines the query to check
  39996. * @returns true if the query got its value
  39997. */
  39998. isQueryResultAvailable(query: WebGLQuery): boolean;
  39999. /**
  40000. * Gets the value of a given query
  40001. * @param query defines the query to check
  40002. * @returns the value of the query
  40003. */
  40004. getQueryResult(query: WebGLQuery): number;
  40005. /**
  40006. * Initiates an occlusion query
  40007. * @param algorithmType defines the algorithm to use
  40008. * @param query defines the query to use
  40009. * @returns the current engine
  40010. * @see http://doc.babylonjs.com/features/occlusionquery
  40011. */
  40012. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  40013. /**
  40014. * Ends an occlusion query
  40015. * @see http://doc.babylonjs.com/features/occlusionquery
  40016. * @param algorithmType defines the algorithm to use
  40017. * @returns the current engine
  40018. */
  40019. endOcclusionQuery(algorithmType: number): Engine;
  40020. /**
  40021. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  40022. * Please note that only one query can be issued at a time
  40023. * @returns a time token used to track the time span
  40024. */
  40025. startTimeQuery(): Nullable<_TimeToken>;
  40026. /**
  40027. * Ends a time query
  40028. * @param token defines the token used to measure the time span
  40029. * @returns the time spent (in ns)
  40030. */
  40031. endTimeQuery(token: _TimeToken): int;
  40032. /** @hidden */
  40033. _currentNonTimestampToken: Nullable<_TimeToken>;
  40034. /** @hidden */
  40035. _createTimeQuery(): WebGLQuery;
  40036. /** @hidden */
  40037. _deleteTimeQuery(query: WebGLQuery): void;
  40038. /** @hidden */
  40039. _getGlAlgorithmType(algorithmType: number): number;
  40040. /** @hidden */
  40041. _getTimeQueryResult(query: WebGLQuery): any;
  40042. /** @hidden */
  40043. _getTimeQueryAvailability(query: WebGLQuery): any;
  40044. }
  40045. interface AbstractMesh {
  40046. /**
  40047. * Backing filed
  40048. * @hidden
  40049. */
  40050. __occlusionDataStorage: _OcclusionDataStorage;
  40051. /**
  40052. * Access property
  40053. * @hidden
  40054. */
  40055. _occlusionDataStorage: _OcclusionDataStorage;
  40056. /**
  40057. * 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.
  40058. * The default value is -1 which means don't break the query and wait till the result
  40059. * @see http://doc.babylonjs.com/features/occlusionquery
  40060. */
  40061. occlusionRetryCount: number;
  40062. /**
  40063. * 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:
  40064. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  40065. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  40066. * * 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.
  40067. * @see http://doc.babylonjs.com/features/occlusionquery
  40068. */
  40069. occlusionType: number;
  40070. /**
  40071. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  40072. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  40073. * * 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.
  40074. * @see http://doc.babylonjs.com/features/occlusionquery
  40075. */
  40076. occlusionQueryAlgorithmType: number;
  40077. /**
  40078. * 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
  40079. * @see http://doc.babylonjs.com/features/occlusionquery
  40080. */
  40081. isOccluded: boolean;
  40082. /**
  40083. * Flag to check the progress status of the query
  40084. * @see http://doc.babylonjs.com/features/occlusionquery
  40085. */
  40086. isOcclusionQueryInProgress: boolean;
  40087. }
  40088. }
  40089. declare module BABYLON {
  40090. /** @hidden */
  40091. export var _forceTransformFeedbackToBundle: boolean;
  40092. interface Engine {
  40093. /**
  40094. * Creates a webGL transform feedback object
  40095. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  40096. * @returns the webGL transform feedback object
  40097. */
  40098. createTransformFeedback(): WebGLTransformFeedback;
  40099. /**
  40100. * Delete a webGL transform feedback object
  40101. * @param value defines the webGL transform feedback object to delete
  40102. */
  40103. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  40104. /**
  40105. * Bind a webGL transform feedback object to the webgl context
  40106. * @param value defines the webGL transform feedback object to bind
  40107. */
  40108. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  40109. /**
  40110. * Begins a transform feedback operation
  40111. * @param usePoints defines if points or triangles must be used
  40112. */
  40113. beginTransformFeedback(usePoints: boolean): void;
  40114. /**
  40115. * Ends a transform feedback operation
  40116. */
  40117. endTransformFeedback(): void;
  40118. /**
  40119. * Specify the varyings to use with transform feedback
  40120. * @param program defines the associated webGL program
  40121. * @param value defines the list of strings representing the varying names
  40122. */
  40123. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  40124. /**
  40125. * Bind a webGL buffer for a transform feedback operation
  40126. * @param value defines the webGL buffer to bind
  40127. */
  40128. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  40129. }
  40130. }
  40131. declare module BABYLON {
  40132. /**
  40133. * Gather the list of clipboard event types as constants.
  40134. */
  40135. export class ClipboardEventTypes {
  40136. /**
  40137. * The clipboard event is fired when a copy command is active (pressed).
  40138. */
  40139. static readonly COPY: number;
  40140. /**
  40141. * The clipboard event is fired when a cut command is active (pressed).
  40142. */
  40143. static readonly CUT: number;
  40144. /**
  40145. * The clipboard event is fired when a paste command is active (pressed).
  40146. */
  40147. static readonly PASTE: number;
  40148. }
  40149. /**
  40150. * This class is used to store clipboard related info for the onClipboardObservable event.
  40151. */
  40152. export class ClipboardInfo {
  40153. /**
  40154. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40155. */
  40156. type: number;
  40157. /**
  40158. * Defines the related dom event
  40159. */
  40160. event: ClipboardEvent;
  40161. /**
  40162. *Creates an instance of ClipboardInfo.
  40163. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  40164. * @param event Defines the related dom event
  40165. */
  40166. constructor(
  40167. /**
  40168. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40169. */
  40170. type: number,
  40171. /**
  40172. * Defines the related dom event
  40173. */
  40174. event: ClipboardEvent);
  40175. /**
  40176. * Get the clipboard event's type from the keycode.
  40177. * @param keyCode Defines the keyCode for the current keyboard event.
  40178. * @return {number}
  40179. */
  40180. static GetTypeFromCharacter(keyCode: number): number;
  40181. }
  40182. }
  40183. declare module BABYLON {
  40184. /**
  40185. * Class used to represent data loading progression
  40186. */
  40187. export class SceneLoaderProgressEvent {
  40188. /** defines if data length to load can be evaluated */
  40189. readonly lengthComputable: boolean;
  40190. /** defines the loaded data length */
  40191. readonly loaded: number;
  40192. /** defines the data length to load */
  40193. readonly total: number;
  40194. /**
  40195. * Create a new progress event
  40196. * @param lengthComputable defines if data length to load can be evaluated
  40197. * @param loaded defines the loaded data length
  40198. * @param total defines the data length to load
  40199. */
  40200. constructor(
  40201. /** defines if data length to load can be evaluated */
  40202. lengthComputable: boolean,
  40203. /** defines the loaded data length */
  40204. loaded: number,
  40205. /** defines the data length to load */
  40206. total: number);
  40207. /**
  40208. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  40209. * @param event defines the source event
  40210. * @returns a new SceneLoaderProgressEvent
  40211. */
  40212. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  40213. }
  40214. /**
  40215. * Interface used by SceneLoader plugins to define supported file extensions
  40216. */
  40217. export interface ISceneLoaderPluginExtensions {
  40218. /**
  40219. * Defines the list of supported extensions
  40220. */
  40221. [extension: string]: {
  40222. isBinary: boolean;
  40223. };
  40224. }
  40225. /**
  40226. * Interface used by SceneLoader plugin factory
  40227. */
  40228. export interface ISceneLoaderPluginFactory {
  40229. /**
  40230. * Defines the name of the factory
  40231. */
  40232. name: string;
  40233. /**
  40234. * Function called to create a new plugin
  40235. * @return the new plugin
  40236. */
  40237. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  40238. /**
  40239. * Boolean indicating if the plugin can direct load specific data
  40240. */
  40241. canDirectLoad?: (data: string) => boolean;
  40242. }
  40243. /**
  40244. * Interface used to define a SceneLoader plugin
  40245. */
  40246. export interface ISceneLoaderPlugin {
  40247. /**
  40248. * The friendly name of this plugin.
  40249. */
  40250. name: string;
  40251. /**
  40252. * The file extensions supported by this plugin.
  40253. */
  40254. extensions: string | ISceneLoaderPluginExtensions;
  40255. /**
  40256. * Import meshes into a scene.
  40257. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40258. * @param scene The scene to import into
  40259. * @param data The data to import
  40260. * @param rootUrl The root url for scene and resources
  40261. * @param meshes The meshes array to import into
  40262. * @param particleSystems The particle systems array to import into
  40263. * @param skeletons The skeletons array to import into
  40264. * @param onError The callback when import fails
  40265. * @returns True if successful or false otherwise
  40266. */
  40267. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  40268. /**
  40269. * Load into a scene.
  40270. * @param scene The scene to load into
  40271. * @param data The data to import
  40272. * @param rootUrl The root url for scene and resources
  40273. * @param onError The callback when import fails
  40274. * @returns true if successful or false otherwise
  40275. */
  40276. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  40277. /**
  40278. * The callback that returns true if the data can be directly loaded.
  40279. */
  40280. canDirectLoad?: (data: string) => boolean;
  40281. /**
  40282. * The callback that allows custom handling of the root url based on the response url.
  40283. */
  40284. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40285. /**
  40286. * Load into an asset container.
  40287. * @param scene The scene to load into
  40288. * @param data The data to import
  40289. * @param rootUrl The root url for scene and resources
  40290. * @param onError The callback when import fails
  40291. * @returns The loaded asset container
  40292. */
  40293. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  40294. }
  40295. /**
  40296. * Interface used to define an async SceneLoader plugin
  40297. */
  40298. export interface ISceneLoaderPluginAsync {
  40299. /**
  40300. * The friendly name of this plugin.
  40301. */
  40302. name: string;
  40303. /**
  40304. * The file extensions supported by this plugin.
  40305. */
  40306. extensions: string | ISceneLoaderPluginExtensions;
  40307. /**
  40308. * Import meshes into a scene.
  40309. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40310. * @param scene The scene to import into
  40311. * @param data The data to import
  40312. * @param rootUrl The root url for scene and resources
  40313. * @param onProgress The callback when the load progresses
  40314. * @param fileName Defines the name of the file to load
  40315. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  40316. */
  40317. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  40318. meshes: AbstractMesh[];
  40319. particleSystems: IParticleSystem[];
  40320. skeletons: Skeleton[];
  40321. animationGroups: AnimationGroup[];
  40322. }>;
  40323. /**
  40324. * Load into a scene.
  40325. * @param scene The scene to load into
  40326. * @param data The data to import
  40327. * @param rootUrl The root url for scene and resources
  40328. * @param onProgress The callback when the load progresses
  40329. * @param fileName Defines the name of the file to load
  40330. * @returns Nothing
  40331. */
  40332. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  40333. /**
  40334. * The callback that returns true if the data can be directly loaded.
  40335. */
  40336. canDirectLoad?: (data: string) => boolean;
  40337. /**
  40338. * The callback that allows custom handling of the root url based on the response url.
  40339. */
  40340. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40341. /**
  40342. * Load into an asset container.
  40343. * @param scene The scene to load into
  40344. * @param data The data to import
  40345. * @param rootUrl The root url for scene and resources
  40346. * @param onProgress The callback when the load progresses
  40347. * @param fileName Defines the name of the file to load
  40348. * @returns The loaded asset container
  40349. */
  40350. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  40351. }
  40352. /**
  40353. * Class used to load scene from various file formats using registered plugins
  40354. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  40355. */
  40356. export class SceneLoader {
  40357. /**
  40358. * No logging while loading
  40359. */
  40360. static readonly NO_LOGGING: number;
  40361. /**
  40362. * Minimal logging while loading
  40363. */
  40364. static readonly MINIMAL_LOGGING: number;
  40365. /**
  40366. * Summary logging while loading
  40367. */
  40368. static readonly SUMMARY_LOGGING: number;
  40369. /**
  40370. * Detailled logging while loading
  40371. */
  40372. static readonly DETAILED_LOGGING: number;
  40373. /**
  40374. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  40375. */
  40376. static ForceFullSceneLoadingForIncremental: boolean;
  40377. /**
  40378. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  40379. */
  40380. static ShowLoadingScreen: boolean;
  40381. /**
  40382. * Defines the current logging level (while loading the scene)
  40383. * @ignorenaming
  40384. */
  40385. static loggingLevel: number;
  40386. /**
  40387. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  40388. */
  40389. static CleanBoneMatrixWeights: boolean;
  40390. /**
  40391. * Event raised when a plugin is used to load a scene
  40392. */
  40393. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  40394. private static _registeredPlugins;
  40395. private static _getDefaultPlugin;
  40396. private static _getPluginForExtension;
  40397. private static _getPluginForDirectLoad;
  40398. private static _getPluginForFilename;
  40399. private static _getDirectLoad;
  40400. private static _loadData;
  40401. private static _getFileInfo;
  40402. /**
  40403. * Gets a plugin that can load the given extension
  40404. * @param extension defines the extension to load
  40405. * @returns a plugin or null if none works
  40406. */
  40407. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  40408. /**
  40409. * Gets a boolean indicating that the given extension can be loaded
  40410. * @param extension defines the extension to load
  40411. * @returns true if the extension is supported
  40412. */
  40413. static IsPluginForExtensionAvailable(extension: string): boolean;
  40414. /**
  40415. * Adds a new plugin to the list of registered plugins
  40416. * @param plugin defines the plugin to add
  40417. */
  40418. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  40419. /**
  40420. * Import meshes into a scene
  40421. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40422. * @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)
  40423. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  40424. * @param scene the instance of BABYLON.Scene to append to
  40425. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  40426. * @param onProgress a callback with a progress event for each file being loaded
  40427. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40428. * @param pluginExtension the extension used to determine the plugin
  40429. * @returns The loaded plugin
  40430. */
  40431. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  40432. /**
  40433. * Import meshes into a scene
  40434. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40435. * @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)
  40436. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  40437. * @param scene the instance of BABYLON.Scene to append to
  40438. * @param onProgress a callback with a progress event for each file being loaded
  40439. * @param pluginExtension the extension used to determine the plugin
  40440. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  40441. */
  40442. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  40443. meshes: AbstractMesh[];
  40444. particleSystems: IParticleSystem[];
  40445. skeletons: Skeleton[];
  40446. animationGroups: AnimationGroup[];
  40447. }>;
  40448. /**
  40449. * Load a scene
  40450. * @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)
  40451. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  40452. * @param engine is the instance of BABYLON.Engine to use to create the scene
  40453. * @param onSuccess a callback with the scene when import succeeds
  40454. * @param onProgress a callback with a progress event for each file being loaded
  40455. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40456. * @param pluginExtension the extension used to determine the plugin
  40457. * @returns The loaded plugin
  40458. */
  40459. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  40460. /**
  40461. * Load a scene
  40462. * @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)
  40463. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  40464. * @param engine is the instance of BABYLON.Engine to use to create the scene
  40465. * @param onProgress a callback with a progress event for each file being loaded
  40466. * @param pluginExtension the extension used to determine the plugin
  40467. * @returns The loaded scene
  40468. */
  40469. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  40470. /**
  40471. * Append a scene
  40472. * @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)
  40473. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  40474. * @param scene is the instance of BABYLON.Scene to append to
  40475. * @param onSuccess a callback with the scene when import succeeds
  40476. * @param onProgress a callback with a progress event for each file being loaded
  40477. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40478. * @param pluginExtension the extension used to determine the plugin
  40479. * @returns The loaded plugin
  40480. */
  40481. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  40482. /**
  40483. * Append a scene
  40484. * @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)
  40485. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  40486. * @param scene is the instance of BABYLON.Scene to append to
  40487. * @param onProgress a callback with a progress event for each file being loaded
  40488. * @param pluginExtension the extension used to determine the plugin
  40489. * @returns The given scene
  40490. */
  40491. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  40492. /**
  40493. * Load a scene into an asset container
  40494. * @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)
  40495. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  40496. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40497. * @param onSuccess a callback with the scene when import succeeds
  40498. * @param onProgress a callback with a progress event for each file being loaded
  40499. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40500. * @param pluginExtension the extension used to determine the plugin
  40501. * @returns The loaded plugin
  40502. */
  40503. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  40504. /**
  40505. * Load a scene into an asset container
  40506. * @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)
  40507. * @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)
  40508. * @param scene is the instance of Scene to append to
  40509. * @param onProgress a callback with a progress event for each file being loaded
  40510. * @param pluginExtension the extension used to determine the plugin
  40511. * @returns The loaded asset container
  40512. */
  40513. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  40514. }
  40515. }
  40516. declare module BABYLON {
  40517. /**
  40518. * Google Daydream controller
  40519. */
  40520. export class DaydreamController extends WebVRController {
  40521. /**
  40522. * Base Url for the controller model.
  40523. */
  40524. static MODEL_BASE_URL: string;
  40525. /**
  40526. * File name for the controller model.
  40527. */
  40528. static MODEL_FILENAME: string;
  40529. /**
  40530. * Gamepad Id prefix used to identify Daydream Controller.
  40531. */
  40532. static readonly GAMEPAD_ID_PREFIX: string;
  40533. /**
  40534. * Creates a new DaydreamController from a gamepad
  40535. * @param vrGamepad the gamepad that the controller should be created from
  40536. */
  40537. constructor(vrGamepad: any);
  40538. /**
  40539. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40540. * @param scene scene in which to add meshes
  40541. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40542. */
  40543. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40544. /**
  40545. * Called once for each button that changed state since the last frame
  40546. * @param buttonIdx Which button index changed
  40547. * @param state New state of the button
  40548. * @param changes Which properties on the state changed since last frame
  40549. */
  40550. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40551. }
  40552. }
  40553. declare module BABYLON {
  40554. /**
  40555. * Gear VR Controller
  40556. */
  40557. export class GearVRController extends WebVRController {
  40558. /**
  40559. * Base Url for the controller model.
  40560. */
  40561. static MODEL_BASE_URL: string;
  40562. /**
  40563. * File name for the controller model.
  40564. */
  40565. static MODEL_FILENAME: string;
  40566. /**
  40567. * Gamepad Id prefix used to identify this controller.
  40568. */
  40569. static readonly GAMEPAD_ID_PREFIX: string;
  40570. private readonly _buttonIndexToObservableNameMap;
  40571. /**
  40572. * Creates a new GearVRController from a gamepad
  40573. * @param vrGamepad the gamepad that the controller should be created from
  40574. */
  40575. constructor(vrGamepad: any);
  40576. /**
  40577. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40578. * @param scene scene in which to add meshes
  40579. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40580. */
  40581. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40582. /**
  40583. * Called once for each button that changed state since the last frame
  40584. * @param buttonIdx Which button index changed
  40585. * @param state New state of the button
  40586. * @param changes Which properties on the state changed since last frame
  40587. */
  40588. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40589. }
  40590. }
  40591. declare module BABYLON {
  40592. /**
  40593. * Generic Controller
  40594. */
  40595. export class GenericController extends WebVRController {
  40596. /**
  40597. * Base Url for the controller model.
  40598. */
  40599. static readonly MODEL_BASE_URL: string;
  40600. /**
  40601. * File name for the controller model.
  40602. */
  40603. static readonly MODEL_FILENAME: string;
  40604. /**
  40605. * Creates a new GenericController from a gamepad
  40606. * @param vrGamepad the gamepad that the controller should be created from
  40607. */
  40608. constructor(vrGamepad: any);
  40609. /**
  40610. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40611. * @param scene scene in which to add meshes
  40612. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40613. */
  40614. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40615. /**
  40616. * Called once for each button that changed state since the last frame
  40617. * @param buttonIdx Which button index changed
  40618. * @param state New state of the button
  40619. * @param changes Which properties on the state changed since last frame
  40620. */
  40621. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40622. }
  40623. }
  40624. declare module BABYLON {
  40625. /**
  40626. * Oculus Touch Controller
  40627. */
  40628. export class OculusTouchController extends WebVRController {
  40629. /**
  40630. * Base Url for the controller model.
  40631. */
  40632. static MODEL_BASE_URL: string;
  40633. /**
  40634. * File name for the left controller model.
  40635. */
  40636. static MODEL_LEFT_FILENAME: string;
  40637. /**
  40638. * File name for the right controller model.
  40639. */
  40640. static MODEL_RIGHT_FILENAME: string;
  40641. /**
  40642. * Fired when the secondary trigger on this controller is modified
  40643. */
  40644. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  40645. /**
  40646. * Fired when the thumb rest on this controller is modified
  40647. */
  40648. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  40649. /**
  40650. * Creates a new OculusTouchController from a gamepad
  40651. * @param vrGamepad the gamepad that the controller should be created from
  40652. */
  40653. constructor(vrGamepad: any);
  40654. /**
  40655. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40656. * @param scene scene in which to add meshes
  40657. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40658. */
  40659. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40660. /**
  40661. * Fired when the A button on this controller is modified
  40662. */
  40663. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40664. /**
  40665. * Fired when the B button on this controller is modified
  40666. */
  40667. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40668. /**
  40669. * Fired when the X button on this controller is modified
  40670. */
  40671. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40672. /**
  40673. * Fired when the Y button on this controller is modified
  40674. */
  40675. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40676. /**
  40677. * Called once for each button that changed state since the last frame
  40678. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  40679. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  40680. * 2) secondary trigger (same)
  40681. * 3) A (right) X (left), touch, pressed = value
  40682. * 4) B / Y
  40683. * 5) thumb rest
  40684. * @param buttonIdx Which button index changed
  40685. * @param state New state of the button
  40686. * @param changes Which properties on the state changed since last frame
  40687. */
  40688. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40689. }
  40690. }
  40691. declare module BABYLON {
  40692. /**
  40693. * Vive Controller
  40694. */
  40695. export class ViveController extends WebVRController {
  40696. /**
  40697. * Base Url for the controller model.
  40698. */
  40699. static MODEL_BASE_URL: string;
  40700. /**
  40701. * File name for the controller model.
  40702. */
  40703. static MODEL_FILENAME: string;
  40704. /**
  40705. * Creates a new ViveController from a gamepad
  40706. * @param vrGamepad the gamepad that the controller should be created from
  40707. */
  40708. constructor(vrGamepad: any);
  40709. /**
  40710. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40711. * @param scene scene in which to add meshes
  40712. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40713. */
  40714. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40715. /**
  40716. * Fired when the left button on this controller is modified
  40717. */
  40718. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40719. /**
  40720. * Fired when the right button on this controller is modified
  40721. */
  40722. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40723. /**
  40724. * Fired when the menu button on this controller is modified
  40725. */
  40726. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40727. /**
  40728. * Called once for each button that changed state since the last frame
  40729. * Vive mapping:
  40730. * 0: touchpad
  40731. * 1: trigger
  40732. * 2: left AND right buttons
  40733. * 3: menu button
  40734. * @param buttonIdx Which button index changed
  40735. * @param state New state of the button
  40736. * @param changes Which properties on the state changed since last frame
  40737. */
  40738. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40739. }
  40740. }
  40741. declare module BABYLON {
  40742. /**
  40743. * Defines the WindowsMotionController object that the state of the windows motion controller
  40744. */
  40745. export class WindowsMotionController extends WebVRController {
  40746. /**
  40747. * The base url used to load the left and right controller models
  40748. */
  40749. static MODEL_BASE_URL: string;
  40750. /**
  40751. * The name of the left controller model file
  40752. */
  40753. static MODEL_LEFT_FILENAME: string;
  40754. /**
  40755. * The name of the right controller model file
  40756. */
  40757. static MODEL_RIGHT_FILENAME: string;
  40758. /**
  40759. * The controller name prefix for this controller type
  40760. */
  40761. static readonly GAMEPAD_ID_PREFIX: string;
  40762. /**
  40763. * The controller id pattern for this controller type
  40764. */
  40765. private static readonly GAMEPAD_ID_PATTERN;
  40766. private _loadedMeshInfo;
  40767. private readonly _mapping;
  40768. /**
  40769. * Fired when the trackpad on this controller is clicked
  40770. */
  40771. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  40772. /**
  40773. * Fired when the trackpad on this controller is modified
  40774. */
  40775. onTrackpadValuesChangedObservable: Observable<StickValues>;
  40776. /**
  40777. * The current x and y values of this controller's trackpad
  40778. */
  40779. trackpad: StickValues;
  40780. /**
  40781. * Creates a new WindowsMotionController from a gamepad
  40782. * @param vrGamepad the gamepad that the controller should be created from
  40783. */
  40784. constructor(vrGamepad: any);
  40785. /**
  40786. * Fired when the trigger on this controller is modified
  40787. */
  40788. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40789. /**
  40790. * Fired when the menu button on this controller is modified
  40791. */
  40792. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40793. /**
  40794. * Fired when the grip button on this controller is modified
  40795. */
  40796. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40797. /**
  40798. * Fired when the thumbstick button on this controller is modified
  40799. */
  40800. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40801. /**
  40802. * Fired when the touchpad button on this controller is modified
  40803. */
  40804. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40805. /**
  40806. * Fired when the touchpad values on this controller are modified
  40807. */
  40808. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  40809. private _updateTrackpad;
  40810. /**
  40811. * Called once per frame by the engine.
  40812. */
  40813. update(): void;
  40814. /**
  40815. * Called once for each button that changed state since the last frame
  40816. * @param buttonIdx Which button index changed
  40817. * @param state New state of the button
  40818. * @param changes Which properties on the state changed since last frame
  40819. */
  40820. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40821. /**
  40822. * Moves the buttons on the controller mesh based on their current state
  40823. * @param buttonName the name of the button to move
  40824. * @param buttonValue the value of the button which determines the buttons new position
  40825. */
  40826. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  40827. /**
  40828. * Moves the axis on the controller mesh based on its current state
  40829. * @param axis the index of the axis
  40830. * @param axisValue the value of the axis which determines the meshes new position
  40831. * @hidden
  40832. */
  40833. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  40834. /**
  40835. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40836. * @param scene scene in which to add meshes
  40837. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40838. */
  40839. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  40840. /**
  40841. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  40842. * can be transformed by button presses and axes values, based on this._mapping.
  40843. *
  40844. * @param scene scene in which the meshes exist
  40845. * @param meshes list of meshes that make up the controller model to process
  40846. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  40847. */
  40848. private processModel;
  40849. private createMeshInfo;
  40850. /**
  40851. * Gets the ray of the controller in the direction the controller is pointing
  40852. * @param length the length the resulting ray should be
  40853. * @returns a ray in the direction the controller is pointing
  40854. */
  40855. getForwardRay(length?: number): Ray;
  40856. /**
  40857. * Disposes of the controller
  40858. */
  40859. dispose(): void;
  40860. }
  40861. }
  40862. declare module BABYLON {
  40863. /**
  40864. * Manager for handling gamepads
  40865. */
  40866. export class GamepadManager {
  40867. private _scene?;
  40868. private _babylonGamepads;
  40869. private _oneGamepadConnected;
  40870. /** @hidden */
  40871. _isMonitoring: boolean;
  40872. private _gamepadEventSupported;
  40873. private _gamepadSupport;
  40874. /**
  40875. * observable to be triggered when the gamepad controller has been connected
  40876. */
  40877. onGamepadConnectedObservable: Observable<Gamepad>;
  40878. /**
  40879. * observable to be triggered when the gamepad controller has been disconnected
  40880. */
  40881. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40882. private _onGamepadConnectedEvent;
  40883. private _onGamepadDisconnectedEvent;
  40884. /**
  40885. * Initializes the gamepad manager
  40886. * @param _scene BabylonJS scene
  40887. */
  40888. constructor(_scene?: Scene | undefined);
  40889. /**
  40890. * The gamepads in the game pad manager
  40891. */
  40892. readonly gamepads: Gamepad[];
  40893. /**
  40894. * Get the gamepad controllers based on type
  40895. * @param type The type of gamepad controller
  40896. * @returns Nullable gamepad
  40897. */
  40898. getGamepadByType(type?: number): Nullable<Gamepad>;
  40899. /**
  40900. * Disposes the gamepad manager
  40901. */
  40902. dispose(): void;
  40903. private _addNewGamepad;
  40904. private _startMonitoringGamepads;
  40905. private _stopMonitoringGamepads;
  40906. /** @hidden */
  40907. _checkGamepadsStatus(): void;
  40908. private _updateGamepadObjects;
  40909. }
  40910. }
  40911. declare module BABYLON {
  40912. interface Scene {
  40913. /** @hidden */
  40914. _gamepadManager: Nullable<GamepadManager>;
  40915. /**
  40916. * Gets the gamepad manager associated with the scene
  40917. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40918. */
  40919. gamepadManager: GamepadManager;
  40920. }
  40921. /**
  40922. * Interface representing a free camera inputs manager
  40923. */
  40924. interface FreeCameraInputsManager {
  40925. /**
  40926. * Adds gamepad input support to the FreeCameraInputsManager.
  40927. * @returns the FreeCameraInputsManager
  40928. */
  40929. addGamepad(): FreeCameraInputsManager;
  40930. }
  40931. /**
  40932. * Interface representing an arc rotate camera inputs manager
  40933. */
  40934. interface ArcRotateCameraInputsManager {
  40935. /**
  40936. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40937. * @returns the camera inputs manager
  40938. */
  40939. addGamepad(): ArcRotateCameraInputsManager;
  40940. }
  40941. /**
  40942. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40943. */
  40944. export class GamepadSystemSceneComponent implements ISceneComponent {
  40945. /**
  40946. * The component name helpfull to identify the component in the list of scene components.
  40947. */
  40948. readonly name: string;
  40949. /**
  40950. * The scene the component belongs to.
  40951. */
  40952. scene: Scene;
  40953. /**
  40954. * Creates a new instance of the component for the given scene
  40955. * @param scene Defines the scene to register the component in
  40956. */
  40957. constructor(scene: Scene);
  40958. /**
  40959. * Registers the component in a given scene
  40960. */
  40961. register(): void;
  40962. /**
  40963. * Rebuilds the elements related to this component in case of
  40964. * context lost for instance.
  40965. */
  40966. rebuild(): void;
  40967. /**
  40968. * Disposes the component and the associated ressources
  40969. */
  40970. dispose(): void;
  40971. private _beforeCameraUpdate;
  40972. }
  40973. }
  40974. declare module BABYLON {
  40975. /**
  40976. * Single axis scale gizmo
  40977. */
  40978. export class AxisScaleGizmo extends Gizmo {
  40979. private _coloredMaterial;
  40980. /**
  40981. * Drag behavior responsible for the gizmos dragging interactions
  40982. */
  40983. dragBehavior: PointerDragBehavior;
  40984. private _pointerObserver;
  40985. /**
  40986. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40987. */
  40988. snapDistance: number;
  40989. /**
  40990. * Event that fires each time the gizmo snaps to a new location.
  40991. * * snapDistance is the the change in distance
  40992. */
  40993. onSnapObservable: Observable<{
  40994. snapDistance: number;
  40995. }>;
  40996. /**
  40997. * If the scaling operation should be done on all axis (default: false)
  40998. */
  40999. uniformScaling: boolean;
  41000. /**
  41001. * Creates an AxisScaleGizmo
  41002. * @param gizmoLayer The utility layer the gizmo will be added to
  41003. * @param dragAxis The axis which the gizmo will be able to scale on
  41004. * @param color The color of the gizmo
  41005. */
  41006. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41007. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41008. /**
  41009. * Disposes of the gizmo
  41010. */
  41011. dispose(): void;
  41012. /**
  41013. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41014. * @param mesh The mesh to replace the default mesh of the gizmo
  41015. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  41016. */
  41017. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  41018. }
  41019. }
  41020. declare module BABYLON {
  41021. /**
  41022. * Bounding box gizmo
  41023. */
  41024. export class BoundingBoxGizmo extends Gizmo {
  41025. private _lineBoundingBox;
  41026. private _rotateSpheresParent;
  41027. private _scaleBoxesParent;
  41028. private _boundingDimensions;
  41029. private _renderObserver;
  41030. private _pointerObserver;
  41031. private _scaleDragSpeed;
  41032. private _tmpQuaternion;
  41033. private _tmpVector;
  41034. private _tmpRotationMatrix;
  41035. /**
  41036. * 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)
  41037. */
  41038. ignoreChildren: boolean;
  41039. /**
  41040. * 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)
  41041. */
  41042. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  41043. /**
  41044. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  41045. */
  41046. rotationSphereSize: number;
  41047. /**
  41048. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  41049. */
  41050. scaleBoxSize: number;
  41051. /**
  41052. * 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)
  41053. */
  41054. fixedDragMeshScreenSize: boolean;
  41055. /**
  41056. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  41057. */
  41058. fixedDragMeshScreenSizeDistanceFactor: number;
  41059. /**
  41060. * Fired when a rotation sphere or scale box is dragged
  41061. */
  41062. onDragStartObservable: Observable<{}>;
  41063. /**
  41064. * Fired when a scale box is dragged
  41065. */
  41066. onScaleBoxDragObservable: Observable<{}>;
  41067. /**
  41068. * Fired when a scale box drag is ended
  41069. */
  41070. onScaleBoxDragEndObservable: Observable<{}>;
  41071. /**
  41072. * Fired when a rotation sphere is dragged
  41073. */
  41074. onRotationSphereDragObservable: Observable<{}>;
  41075. /**
  41076. * Fired when a rotation sphere drag is ended
  41077. */
  41078. onRotationSphereDragEndObservable: Observable<{}>;
  41079. /**
  41080. * 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)
  41081. */
  41082. scalePivot: Nullable<Vector3>;
  41083. private _anchorMesh;
  41084. private _existingMeshScale;
  41085. private _dragMesh;
  41086. private pointerDragBehavior;
  41087. /**
  41088. * Creates an BoundingBoxGizmo
  41089. * @param gizmoLayer The utility layer the gizmo will be added to
  41090. * @param color The color of the gizmo
  41091. */
  41092. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41093. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41094. private _selectNode;
  41095. /**
  41096. * Updates the bounding box information for the Gizmo
  41097. */
  41098. updateBoundingBox(): void;
  41099. private _updateRotationSpheres;
  41100. private _updateScaleBoxes;
  41101. /**
  41102. * Enables rotation on the specified axis and disables rotation on the others
  41103. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  41104. */
  41105. setEnabledRotationAxis(axis: string): void;
  41106. /**
  41107. * Enables/disables scaling
  41108. * @param enable if scaling should be enabled
  41109. */
  41110. setEnabledScaling(enable: boolean): void;
  41111. private _updateDummy;
  41112. /**
  41113. * Enables a pointer drag behavior on the bounding box of the gizmo
  41114. */
  41115. enableDragBehavior(): void;
  41116. /**
  41117. * Disposes of the gizmo
  41118. */
  41119. dispose(): void;
  41120. /**
  41121. * 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)
  41122. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  41123. * @returns the bounding box mesh with the passed in mesh as a child
  41124. */
  41125. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  41126. /**
  41127. * CustomMeshes are not supported by this gizmo
  41128. * @param mesh The mesh to replace the default mesh of the gizmo
  41129. */
  41130. setCustomMesh(mesh: Mesh): void;
  41131. }
  41132. }
  41133. declare module BABYLON {
  41134. /**
  41135. * Single plane rotation gizmo
  41136. */
  41137. export class PlaneRotationGizmo extends Gizmo {
  41138. /**
  41139. * Drag behavior responsible for the gizmos dragging interactions
  41140. */
  41141. dragBehavior: PointerDragBehavior;
  41142. private _pointerObserver;
  41143. /**
  41144. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  41145. */
  41146. snapDistance: number;
  41147. /**
  41148. * Event that fires each time the gizmo snaps to a new location.
  41149. * * snapDistance is the the change in distance
  41150. */
  41151. onSnapObservable: Observable<{
  41152. snapDistance: number;
  41153. }>;
  41154. /**
  41155. * Creates a PlaneRotationGizmo
  41156. * @param gizmoLayer The utility layer the gizmo will be added to
  41157. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  41158. * @param color The color of the gizmo
  41159. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41160. */
  41161. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41162. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41163. /**
  41164. * Disposes of the gizmo
  41165. */
  41166. dispose(): void;
  41167. }
  41168. }
  41169. declare module BABYLON {
  41170. /**
  41171. * Gizmo that enables rotating a mesh along 3 axis
  41172. */
  41173. export class RotationGizmo extends Gizmo {
  41174. /**
  41175. * Internal gizmo used for interactions on the x axis
  41176. */
  41177. xGizmo: PlaneRotationGizmo;
  41178. /**
  41179. * Internal gizmo used for interactions on the y axis
  41180. */
  41181. yGizmo: PlaneRotationGizmo;
  41182. /**
  41183. * Internal gizmo used for interactions on the z axis
  41184. */
  41185. zGizmo: PlaneRotationGizmo;
  41186. /** Fires an event when any of it's sub gizmos are dragged */
  41187. onDragStartObservable: Observable<{}>;
  41188. /** Fires an event when any of it's sub gizmos are released from dragging */
  41189. onDragEndObservable: Observable<{}>;
  41190. attachedMesh: Nullable<AbstractMesh>;
  41191. /**
  41192. * Creates a RotationGizmo
  41193. * @param gizmoLayer The utility layer the gizmo will be added to
  41194. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41195. */
  41196. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41197. updateGizmoRotationToMatchAttachedMesh: boolean;
  41198. /**
  41199. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41200. */
  41201. snapDistance: number;
  41202. /**
  41203. * Ratio for the scale of the gizmo (Default: 1)
  41204. */
  41205. scaleRatio: number;
  41206. /**
  41207. * Disposes of the gizmo
  41208. */
  41209. dispose(): void;
  41210. /**
  41211. * CustomMeshes are not supported by this gizmo
  41212. * @param mesh The mesh to replace the default mesh of the gizmo
  41213. */
  41214. setCustomMesh(mesh: Mesh): void;
  41215. }
  41216. }
  41217. declare module BABYLON {
  41218. /**
  41219. * Gizmo that enables dragging a mesh along 3 axis
  41220. */
  41221. export class PositionGizmo extends Gizmo {
  41222. /**
  41223. * Internal gizmo used for interactions on the x axis
  41224. */
  41225. xGizmo: AxisDragGizmo;
  41226. /**
  41227. * Internal gizmo used for interactions on the y axis
  41228. */
  41229. yGizmo: AxisDragGizmo;
  41230. /**
  41231. * Internal gizmo used for interactions on the z axis
  41232. */
  41233. zGizmo: AxisDragGizmo;
  41234. /** Fires an event when any of it's sub gizmos are dragged */
  41235. onDragStartObservable: Observable<{}>;
  41236. /** Fires an event when any of it's sub gizmos are released from dragging */
  41237. onDragEndObservable: Observable<{}>;
  41238. attachedMesh: Nullable<AbstractMesh>;
  41239. /**
  41240. * Creates a PositionGizmo
  41241. * @param gizmoLayer The utility layer the gizmo will be added to
  41242. */
  41243. constructor(gizmoLayer?: UtilityLayerRenderer);
  41244. updateGizmoRotationToMatchAttachedMesh: boolean;
  41245. /**
  41246. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41247. */
  41248. snapDistance: number;
  41249. /**
  41250. * Ratio for the scale of the gizmo (Default: 1)
  41251. */
  41252. scaleRatio: number;
  41253. /**
  41254. * Disposes of the gizmo
  41255. */
  41256. dispose(): void;
  41257. /**
  41258. * CustomMeshes are not supported by this gizmo
  41259. * @param mesh The mesh to replace the default mesh of the gizmo
  41260. */
  41261. setCustomMesh(mesh: Mesh): void;
  41262. }
  41263. }
  41264. declare module BABYLON {
  41265. /**
  41266. * Class containing static functions to help procedurally build meshes
  41267. */
  41268. export class PolyhedronBuilder {
  41269. /**
  41270. * Creates a polyhedron mesh
  41271. * * 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
  41272. * * The parameter `size` (positive float, default 1) sets the polygon size
  41273. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  41274. * * 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`
  41275. * * 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
  41276. * * 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)`)
  41277. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41278. * * 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
  41279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41280. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41282. * @param name defines the name of the mesh
  41283. * @param options defines the options used to create the mesh
  41284. * @param scene defines the hosting scene
  41285. * @returns the polyhedron mesh
  41286. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  41287. */
  41288. static CreatePolyhedron(name: string, options: {
  41289. type?: number;
  41290. size?: number;
  41291. sizeX?: number;
  41292. sizeY?: number;
  41293. sizeZ?: number;
  41294. custom?: any;
  41295. faceUV?: Vector4[];
  41296. faceColors?: Color4[];
  41297. flat?: boolean;
  41298. updatable?: boolean;
  41299. sideOrientation?: number;
  41300. frontUVs?: Vector4;
  41301. backUVs?: Vector4;
  41302. }, scene: Scene): Mesh;
  41303. }
  41304. }
  41305. declare module BABYLON {
  41306. /**
  41307. * Gizmo that enables scaling a mesh along 3 axis
  41308. */
  41309. export class ScaleGizmo extends Gizmo {
  41310. /**
  41311. * Internal gizmo used for interactions on the x axis
  41312. */
  41313. xGizmo: AxisScaleGizmo;
  41314. /**
  41315. * Internal gizmo used for interactions on the y axis
  41316. */
  41317. yGizmo: AxisScaleGizmo;
  41318. /**
  41319. * Internal gizmo used for interactions on the z axis
  41320. */
  41321. zGizmo: AxisScaleGizmo;
  41322. /**
  41323. * Internal gizmo used to scale all axis equally
  41324. */
  41325. uniformScaleGizmo: AxisScaleGizmo;
  41326. /** Fires an event when any of it's sub gizmos are dragged */
  41327. onDragStartObservable: Observable<{}>;
  41328. /** Fires an event when any of it's sub gizmos are released from dragging */
  41329. onDragEndObservable: Observable<{}>;
  41330. attachedMesh: Nullable<AbstractMesh>;
  41331. /**
  41332. * Creates a ScaleGizmo
  41333. * @param gizmoLayer The utility layer the gizmo will be added to
  41334. */
  41335. constructor(gizmoLayer?: UtilityLayerRenderer);
  41336. updateGizmoRotationToMatchAttachedMesh: boolean;
  41337. /**
  41338. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41339. */
  41340. snapDistance: number;
  41341. /**
  41342. * Ratio for the scale of the gizmo (Default: 1)
  41343. */
  41344. scaleRatio: number;
  41345. /**
  41346. * Disposes of the gizmo
  41347. */
  41348. dispose(): void;
  41349. }
  41350. }
  41351. declare module BABYLON {
  41352. /**
  41353. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  41354. */
  41355. export class GizmoManager implements IDisposable {
  41356. private scene;
  41357. /**
  41358. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  41359. */
  41360. gizmos: {
  41361. positionGizmo: Nullable<PositionGizmo>;
  41362. rotationGizmo: Nullable<RotationGizmo>;
  41363. scaleGizmo: Nullable<ScaleGizmo>;
  41364. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  41365. };
  41366. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  41367. clearGizmoOnEmptyPointerEvent: boolean;
  41368. /** Fires an event when the manager is attached to a mesh */
  41369. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  41370. private _gizmosEnabled;
  41371. private _pointerObserver;
  41372. private _attachedMesh;
  41373. private _boundingBoxColor;
  41374. private _defaultUtilityLayer;
  41375. private _defaultKeepDepthUtilityLayer;
  41376. /**
  41377. * When bounding box gizmo is enabled, this can be used to track drag/end events
  41378. */
  41379. boundingBoxDragBehavior: SixDofDragBehavior;
  41380. /**
  41381. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  41382. */
  41383. attachableMeshes: Nullable<Array<AbstractMesh>>;
  41384. /**
  41385. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  41386. */
  41387. usePointerToAttachGizmos: boolean;
  41388. /**
  41389. * Instatiates a gizmo manager
  41390. * @param scene the scene to overlay the gizmos on top of
  41391. */
  41392. constructor(scene: Scene);
  41393. /**
  41394. * Attaches a set of gizmos to the specified mesh
  41395. * @param mesh The mesh the gizmo's should be attached to
  41396. */
  41397. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  41398. /**
  41399. * If the position gizmo is enabled
  41400. */
  41401. positionGizmoEnabled: boolean;
  41402. /**
  41403. * If the rotation gizmo is enabled
  41404. */
  41405. rotationGizmoEnabled: boolean;
  41406. /**
  41407. * If the scale gizmo is enabled
  41408. */
  41409. scaleGizmoEnabled: boolean;
  41410. /**
  41411. * If the boundingBox gizmo is enabled
  41412. */
  41413. boundingBoxGizmoEnabled: boolean;
  41414. /**
  41415. * Disposes of the gizmo manager
  41416. */
  41417. dispose(): void;
  41418. }
  41419. }
  41420. declare module BABYLON {
  41421. /** @hidden */
  41422. export var backgroundFragmentDeclaration: {
  41423. name: string;
  41424. shader: string;
  41425. };
  41426. }
  41427. declare module BABYLON {
  41428. /** @hidden */
  41429. export var backgroundUboDeclaration: {
  41430. name: string;
  41431. shader: string;
  41432. };
  41433. }
  41434. declare module BABYLON {
  41435. /** @hidden */
  41436. export var backgroundPixelShader: {
  41437. name: string;
  41438. shader: string;
  41439. };
  41440. }
  41441. declare module BABYLON {
  41442. /** @hidden */
  41443. export var backgroundVertexDeclaration: {
  41444. name: string;
  41445. shader: string;
  41446. };
  41447. }
  41448. declare module BABYLON {
  41449. /** @hidden */
  41450. export var backgroundVertexShader: {
  41451. name: string;
  41452. shader: string;
  41453. };
  41454. }
  41455. declare module BABYLON {
  41456. /**
  41457. * Background material used to create an efficient environement around your scene.
  41458. */
  41459. export class BackgroundMaterial extends PushMaterial {
  41460. /**
  41461. * Standard reflectance value at parallel view angle.
  41462. */
  41463. static StandardReflectance0: number;
  41464. /**
  41465. * Standard reflectance value at grazing angle.
  41466. */
  41467. static StandardReflectance90: number;
  41468. protected _primaryColor: Color3;
  41469. /**
  41470. * Key light Color (multiply against the environement texture)
  41471. */
  41472. primaryColor: Color3;
  41473. protected __perceptualColor: Nullable<Color3>;
  41474. /**
  41475. * Experimental Internal Use Only.
  41476. *
  41477. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  41478. * This acts as a helper to set the primary color to a more "human friendly" value.
  41479. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  41480. * output color as close as possible from the chosen value.
  41481. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  41482. * part of lighting setup.)
  41483. */
  41484. _perceptualColor: Nullable<Color3>;
  41485. protected _primaryColorShadowLevel: float;
  41486. /**
  41487. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  41488. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  41489. */
  41490. primaryColorShadowLevel: float;
  41491. protected _primaryColorHighlightLevel: float;
  41492. /**
  41493. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  41494. * The primary color is used at the level chosen to define what the white area would look.
  41495. */
  41496. primaryColorHighlightLevel: float;
  41497. protected _reflectionTexture: Nullable<BaseTexture>;
  41498. /**
  41499. * Reflection Texture used in the material.
  41500. * Should be author in a specific way for the best result (refer to the documentation).
  41501. */
  41502. reflectionTexture: Nullable<BaseTexture>;
  41503. protected _reflectionBlur: float;
  41504. /**
  41505. * Reflection Texture level of blur.
  41506. *
  41507. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  41508. * texture twice.
  41509. */
  41510. reflectionBlur: float;
  41511. protected _diffuseTexture: Nullable<BaseTexture>;
  41512. /**
  41513. * Diffuse Texture used in the material.
  41514. * Should be author in a specific way for the best result (refer to the documentation).
  41515. */
  41516. diffuseTexture: Nullable<BaseTexture>;
  41517. protected _shadowLights: Nullable<IShadowLight[]>;
  41518. /**
  41519. * Specify the list of lights casting shadow on the material.
  41520. * All scene shadow lights will be included if null.
  41521. */
  41522. shadowLights: Nullable<IShadowLight[]>;
  41523. protected _shadowLevel: float;
  41524. /**
  41525. * Helps adjusting the shadow to a softer level if required.
  41526. * 0 means black shadows and 1 means no shadows.
  41527. */
  41528. shadowLevel: float;
  41529. protected _sceneCenter: Vector3;
  41530. /**
  41531. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  41532. * It is usually zero but might be interesting to modify according to your setup.
  41533. */
  41534. sceneCenter: Vector3;
  41535. protected _opacityFresnel: boolean;
  41536. /**
  41537. * This helps specifying that the material is falling off to the sky box at grazing angle.
  41538. * This helps ensuring a nice transition when the camera goes under the ground.
  41539. */
  41540. opacityFresnel: boolean;
  41541. protected _reflectionFresnel: boolean;
  41542. /**
  41543. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  41544. * This helps adding a mirror texture on the ground.
  41545. */
  41546. reflectionFresnel: boolean;
  41547. protected _reflectionFalloffDistance: number;
  41548. /**
  41549. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  41550. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  41551. */
  41552. reflectionFalloffDistance: number;
  41553. protected _reflectionAmount: number;
  41554. /**
  41555. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  41556. */
  41557. reflectionAmount: number;
  41558. protected _reflectionReflectance0: number;
  41559. /**
  41560. * This specifies the weight of the reflection at grazing angle.
  41561. */
  41562. reflectionReflectance0: number;
  41563. protected _reflectionReflectance90: number;
  41564. /**
  41565. * This specifies the weight of the reflection at a perpendicular point of view.
  41566. */
  41567. reflectionReflectance90: number;
  41568. /**
  41569. * Sets the reflection reflectance fresnel values according to the default standard
  41570. * empirically know to work well :-)
  41571. */
  41572. reflectionStandardFresnelWeight: number;
  41573. protected _useRGBColor: boolean;
  41574. /**
  41575. * Helps to directly use the maps channels instead of their level.
  41576. */
  41577. useRGBColor: boolean;
  41578. protected _enableNoise: boolean;
  41579. /**
  41580. * This helps reducing the banding effect that could occur on the background.
  41581. */
  41582. enableNoise: boolean;
  41583. /**
  41584. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  41585. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  41586. * Recommended to be keep at 1.0 except for special cases.
  41587. */
  41588. fovMultiplier: number;
  41589. private _fovMultiplier;
  41590. /**
  41591. * Enable the FOV adjustment feature controlled by fovMultiplier.
  41592. */
  41593. useEquirectangularFOV: boolean;
  41594. private _maxSimultaneousLights;
  41595. /**
  41596. * Number of Simultaneous lights allowed on the material.
  41597. */
  41598. maxSimultaneousLights: int;
  41599. /**
  41600. * Default configuration related to image processing available in the Background Material.
  41601. */
  41602. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41603. /**
  41604. * Keep track of the image processing observer to allow dispose and replace.
  41605. */
  41606. private _imageProcessingObserver;
  41607. /**
  41608. * Attaches a new image processing configuration to the PBR Material.
  41609. * @param configuration (if null the scene configuration will be use)
  41610. */
  41611. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41612. /**
  41613. * Gets the image processing configuration used either in this material.
  41614. */
  41615. /**
  41616. * Sets the Default image processing configuration used either in the this material.
  41617. *
  41618. * If sets to null, the scene one is in use.
  41619. */
  41620. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  41621. /**
  41622. * Gets wether the color curves effect is enabled.
  41623. */
  41624. /**
  41625. * Sets wether the color curves effect is enabled.
  41626. */
  41627. cameraColorCurvesEnabled: boolean;
  41628. /**
  41629. * Gets wether the color grading effect is enabled.
  41630. */
  41631. /**
  41632. * Gets wether the color grading effect is enabled.
  41633. */
  41634. cameraColorGradingEnabled: boolean;
  41635. /**
  41636. * Gets wether tonemapping is enabled or not.
  41637. */
  41638. /**
  41639. * Sets wether tonemapping is enabled or not
  41640. */
  41641. cameraToneMappingEnabled: boolean;
  41642. /**
  41643. * The camera exposure used on this material.
  41644. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41645. * This corresponds to a photographic exposure.
  41646. */
  41647. /**
  41648. * The camera exposure used on this material.
  41649. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41650. * This corresponds to a photographic exposure.
  41651. */
  41652. cameraExposure: float;
  41653. /**
  41654. * Gets The camera contrast used on this material.
  41655. */
  41656. /**
  41657. * Sets The camera contrast used on this material.
  41658. */
  41659. cameraContrast: float;
  41660. /**
  41661. * Gets the Color Grading 2D Lookup Texture.
  41662. */
  41663. /**
  41664. * Sets the Color Grading 2D Lookup Texture.
  41665. */
  41666. cameraColorGradingTexture: Nullable<BaseTexture>;
  41667. /**
  41668. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41669. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41670. * 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;
  41671. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41672. */
  41673. /**
  41674. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41675. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41676. * 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;
  41677. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41678. */
  41679. cameraColorCurves: Nullable<ColorCurves>;
  41680. /**
  41681. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  41682. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  41683. */
  41684. switchToBGR: boolean;
  41685. private _renderTargets;
  41686. private _reflectionControls;
  41687. private _white;
  41688. private _primaryShadowColor;
  41689. private _primaryHighlightColor;
  41690. /**
  41691. * Instantiates a Background Material in the given scene
  41692. * @param name The friendly name of the material
  41693. * @param scene The scene to add the material to
  41694. */
  41695. constructor(name: string, scene: Scene);
  41696. /**
  41697. * Gets a boolean indicating that current material needs to register RTT
  41698. */
  41699. readonly hasRenderTargetTextures: boolean;
  41700. /**
  41701. * The entire material has been created in order to prevent overdraw.
  41702. * @returns false
  41703. */
  41704. needAlphaTesting(): boolean;
  41705. /**
  41706. * The entire material has been created in order to prevent overdraw.
  41707. * @returns true if blending is enable
  41708. */
  41709. needAlphaBlending(): boolean;
  41710. /**
  41711. * Checks wether the material is ready to be rendered for a given mesh.
  41712. * @param mesh The mesh to render
  41713. * @param subMesh The submesh to check against
  41714. * @param useInstances Specify wether or not the material is used with instances
  41715. * @returns true if all the dependencies are ready (Textures, Effects...)
  41716. */
  41717. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41718. /**
  41719. * Compute the primary color according to the chosen perceptual color.
  41720. */
  41721. private _computePrimaryColorFromPerceptualColor;
  41722. /**
  41723. * Compute the highlights and shadow colors according to their chosen levels.
  41724. */
  41725. private _computePrimaryColors;
  41726. /**
  41727. * Build the uniform buffer used in the material.
  41728. */
  41729. buildUniformLayout(): void;
  41730. /**
  41731. * Unbind the material.
  41732. */
  41733. unbind(): void;
  41734. /**
  41735. * Bind only the world matrix to the material.
  41736. * @param world The world matrix to bind.
  41737. */
  41738. bindOnlyWorldMatrix(world: Matrix): void;
  41739. /**
  41740. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  41741. * @param world The world matrix to bind.
  41742. * @param subMesh The submesh to bind for.
  41743. */
  41744. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41745. /**
  41746. * Dispose the material.
  41747. * @param forceDisposeEffect Force disposal of the associated effect.
  41748. * @param forceDisposeTextures Force disposal of the associated textures.
  41749. */
  41750. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41751. /**
  41752. * Clones the material.
  41753. * @param name The cloned name.
  41754. * @returns The cloned material.
  41755. */
  41756. clone(name: string): BackgroundMaterial;
  41757. /**
  41758. * Serializes the current material to its JSON representation.
  41759. * @returns The JSON representation.
  41760. */
  41761. serialize(): any;
  41762. /**
  41763. * Gets the class name of the material
  41764. * @returns "BackgroundMaterial"
  41765. */
  41766. getClassName(): string;
  41767. /**
  41768. * Parse a JSON input to create back a background material.
  41769. * @param source The JSON data to parse
  41770. * @param scene The scene to create the parsed material in
  41771. * @param rootUrl The root url of the assets the material depends upon
  41772. * @returns the instantiated BackgroundMaterial.
  41773. */
  41774. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  41775. }
  41776. }
  41777. declare module BABYLON {
  41778. /**
  41779. * Represents the different options available during the creation of
  41780. * a Environment helper.
  41781. *
  41782. * This can control the default ground, skybox and image processing setup of your scene.
  41783. */
  41784. export interface IEnvironmentHelperOptions {
  41785. /**
  41786. * Specifies wether or not to create a ground.
  41787. * True by default.
  41788. */
  41789. createGround: boolean;
  41790. /**
  41791. * Specifies the ground size.
  41792. * 15 by default.
  41793. */
  41794. groundSize: number;
  41795. /**
  41796. * The texture used on the ground for the main color.
  41797. * Comes from the BabylonJS CDN by default.
  41798. *
  41799. * Remarks: Can be either a texture or a url.
  41800. */
  41801. groundTexture: string | BaseTexture;
  41802. /**
  41803. * The color mixed in the ground texture by default.
  41804. * BabylonJS clearColor by default.
  41805. */
  41806. groundColor: Color3;
  41807. /**
  41808. * Specifies the ground opacity.
  41809. * 1 by default.
  41810. */
  41811. groundOpacity: number;
  41812. /**
  41813. * Enables the ground to receive shadows.
  41814. * True by default.
  41815. */
  41816. enableGroundShadow: boolean;
  41817. /**
  41818. * Helps preventing the shadow to be fully black on the ground.
  41819. * 0.5 by default.
  41820. */
  41821. groundShadowLevel: number;
  41822. /**
  41823. * Creates a mirror texture attach to the ground.
  41824. * false by default.
  41825. */
  41826. enableGroundMirror: boolean;
  41827. /**
  41828. * Specifies the ground mirror size ratio.
  41829. * 0.3 by default as the default kernel is 64.
  41830. */
  41831. groundMirrorSizeRatio: number;
  41832. /**
  41833. * Specifies the ground mirror blur kernel size.
  41834. * 64 by default.
  41835. */
  41836. groundMirrorBlurKernel: number;
  41837. /**
  41838. * Specifies the ground mirror visibility amount.
  41839. * 1 by default
  41840. */
  41841. groundMirrorAmount: number;
  41842. /**
  41843. * Specifies the ground mirror reflectance weight.
  41844. * This uses the standard weight of the background material to setup the fresnel effect
  41845. * of the mirror.
  41846. * 1 by default.
  41847. */
  41848. groundMirrorFresnelWeight: number;
  41849. /**
  41850. * Specifies the ground mirror Falloff distance.
  41851. * This can helps reducing the size of the reflection.
  41852. * 0 by Default.
  41853. */
  41854. groundMirrorFallOffDistance: number;
  41855. /**
  41856. * Specifies the ground mirror texture type.
  41857. * Unsigned Int by Default.
  41858. */
  41859. groundMirrorTextureType: number;
  41860. /**
  41861. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  41862. * the shown objects.
  41863. */
  41864. groundYBias: number;
  41865. /**
  41866. * Specifies wether or not to create a skybox.
  41867. * True by default.
  41868. */
  41869. createSkybox: boolean;
  41870. /**
  41871. * Specifies the skybox size.
  41872. * 20 by default.
  41873. */
  41874. skyboxSize: number;
  41875. /**
  41876. * The texture used on the skybox for the main color.
  41877. * Comes from the BabylonJS CDN by default.
  41878. *
  41879. * Remarks: Can be either a texture or a url.
  41880. */
  41881. skyboxTexture: string | BaseTexture;
  41882. /**
  41883. * The color mixed in the skybox texture by default.
  41884. * BabylonJS clearColor by default.
  41885. */
  41886. skyboxColor: Color3;
  41887. /**
  41888. * The background rotation around the Y axis of the scene.
  41889. * This helps aligning the key lights of your scene with the background.
  41890. * 0 by default.
  41891. */
  41892. backgroundYRotation: number;
  41893. /**
  41894. * Compute automatically the size of the elements to best fit with the scene.
  41895. */
  41896. sizeAuto: boolean;
  41897. /**
  41898. * Default position of the rootMesh if autoSize is not true.
  41899. */
  41900. rootPosition: Vector3;
  41901. /**
  41902. * Sets up the image processing in the scene.
  41903. * true by default.
  41904. */
  41905. setupImageProcessing: boolean;
  41906. /**
  41907. * The texture used as your environment texture in the scene.
  41908. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  41909. *
  41910. * Remarks: Can be either a texture or a url.
  41911. */
  41912. environmentTexture: string | BaseTexture;
  41913. /**
  41914. * The value of the exposure to apply to the scene.
  41915. * 0.6 by default if setupImageProcessing is true.
  41916. */
  41917. cameraExposure: number;
  41918. /**
  41919. * The value of the contrast to apply to the scene.
  41920. * 1.6 by default if setupImageProcessing is true.
  41921. */
  41922. cameraContrast: number;
  41923. /**
  41924. * Specifies wether or not tonemapping should be enabled in the scene.
  41925. * true by default if setupImageProcessing is true.
  41926. */
  41927. toneMappingEnabled: boolean;
  41928. }
  41929. /**
  41930. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  41931. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  41932. * It also helps with the default setup of your imageProcessing configuration.
  41933. */
  41934. export class EnvironmentHelper {
  41935. /**
  41936. * Default ground texture URL.
  41937. */
  41938. private static _groundTextureCDNUrl;
  41939. /**
  41940. * Default skybox texture URL.
  41941. */
  41942. private static _skyboxTextureCDNUrl;
  41943. /**
  41944. * Default environment texture URL.
  41945. */
  41946. private static _environmentTextureCDNUrl;
  41947. /**
  41948. * Creates the default options for the helper.
  41949. */
  41950. private static _getDefaultOptions;
  41951. private _rootMesh;
  41952. /**
  41953. * Gets the root mesh created by the helper.
  41954. */
  41955. readonly rootMesh: Mesh;
  41956. private _skybox;
  41957. /**
  41958. * Gets the skybox created by the helper.
  41959. */
  41960. readonly skybox: Nullable<Mesh>;
  41961. private _skyboxTexture;
  41962. /**
  41963. * Gets the skybox texture created by the helper.
  41964. */
  41965. readonly skyboxTexture: Nullable<BaseTexture>;
  41966. private _skyboxMaterial;
  41967. /**
  41968. * Gets the skybox material created by the helper.
  41969. */
  41970. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  41971. private _ground;
  41972. /**
  41973. * Gets the ground mesh created by the helper.
  41974. */
  41975. readonly ground: Nullable<Mesh>;
  41976. private _groundTexture;
  41977. /**
  41978. * Gets the ground texture created by the helper.
  41979. */
  41980. readonly groundTexture: Nullable<BaseTexture>;
  41981. private _groundMirror;
  41982. /**
  41983. * Gets the ground mirror created by the helper.
  41984. */
  41985. readonly groundMirror: Nullable<MirrorTexture>;
  41986. /**
  41987. * Gets the ground mirror render list to helps pushing the meshes
  41988. * you wish in the ground reflection.
  41989. */
  41990. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  41991. private _groundMaterial;
  41992. /**
  41993. * Gets the ground material created by the helper.
  41994. */
  41995. readonly groundMaterial: Nullable<BackgroundMaterial>;
  41996. /**
  41997. * Stores the creation options.
  41998. */
  41999. private readonly _scene;
  42000. private _options;
  42001. /**
  42002. * This observable will be notified with any error during the creation of the environment,
  42003. * mainly texture creation errors.
  42004. */
  42005. onErrorObservable: Observable<{
  42006. message?: string;
  42007. exception?: any;
  42008. }>;
  42009. /**
  42010. * constructor
  42011. * @param options Defines the options we want to customize the helper
  42012. * @param scene The scene to add the material to
  42013. */
  42014. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  42015. /**
  42016. * Updates the background according to the new options
  42017. * @param options
  42018. */
  42019. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  42020. /**
  42021. * Sets the primary color of all the available elements.
  42022. * @param color the main color to affect to the ground and the background
  42023. */
  42024. setMainColor(color: Color3): void;
  42025. /**
  42026. * Setup the image processing according to the specified options.
  42027. */
  42028. private _setupImageProcessing;
  42029. /**
  42030. * Setup the environment texture according to the specified options.
  42031. */
  42032. private _setupEnvironmentTexture;
  42033. /**
  42034. * Setup the background according to the specified options.
  42035. */
  42036. private _setupBackground;
  42037. /**
  42038. * Get the scene sizes according to the setup.
  42039. */
  42040. private _getSceneSize;
  42041. /**
  42042. * Setup the ground according to the specified options.
  42043. */
  42044. private _setupGround;
  42045. /**
  42046. * Setup the ground material according to the specified options.
  42047. */
  42048. private _setupGroundMaterial;
  42049. /**
  42050. * Setup the ground diffuse texture according to the specified options.
  42051. */
  42052. private _setupGroundDiffuseTexture;
  42053. /**
  42054. * Setup the ground mirror texture according to the specified options.
  42055. */
  42056. private _setupGroundMirrorTexture;
  42057. /**
  42058. * Setup the ground to receive the mirror texture.
  42059. */
  42060. private _setupMirrorInGroundMaterial;
  42061. /**
  42062. * Setup the skybox according to the specified options.
  42063. */
  42064. private _setupSkybox;
  42065. /**
  42066. * Setup the skybox material according to the specified options.
  42067. */
  42068. private _setupSkyboxMaterial;
  42069. /**
  42070. * Setup the skybox reflection texture according to the specified options.
  42071. */
  42072. private _setupSkyboxReflectionTexture;
  42073. private _errorHandler;
  42074. /**
  42075. * Dispose all the elements created by the Helper.
  42076. */
  42077. dispose(): void;
  42078. }
  42079. }
  42080. declare module BABYLON {
  42081. /**
  42082. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  42083. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  42084. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  42085. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  42086. */
  42087. export class PhotoDome extends TransformNode {
  42088. private _useDirectMapping;
  42089. /**
  42090. * The texture being displayed on the sphere
  42091. */
  42092. protected _photoTexture: Texture;
  42093. /**
  42094. * Gets or sets the texture being displayed on the sphere
  42095. */
  42096. photoTexture: Texture;
  42097. /**
  42098. * Observable raised when an error occured while loading the 360 image
  42099. */
  42100. onLoadErrorObservable: Observable<string>;
  42101. /**
  42102. * The skybox material
  42103. */
  42104. protected _material: BackgroundMaterial;
  42105. /**
  42106. * The surface used for the skybox
  42107. */
  42108. protected _mesh: Mesh;
  42109. /**
  42110. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42111. * Also see the options.resolution property.
  42112. */
  42113. fovMultiplier: number;
  42114. /**
  42115. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  42116. * @param name Element's name, child elements will append suffixes for their own names.
  42117. * @param urlsOfPhoto defines the url of the photo to display
  42118. * @param options defines an object containing optional or exposed sub element properties
  42119. * @param onError defines a callback called when an error occured while loading the texture
  42120. */
  42121. constructor(name: string, urlOfPhoto: string, options: {
  42122. resolution?: number;
  42123. size?: number;
  42124. useDirectMapping?: boolean;
  42125. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  42126. /**
  42127. * Releases resources associated with this node.
  42128. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  42129. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  42130. */
  42131. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  42132. }
  42133. }
  42134. declare module BABYLON {
  42135. /**
  42136. * Class used to host texture specific utilities
  42137. */
  42138. export class TextureTools {
  42139. /**
  42140. * Uses the GPU to create a copy texture rescaled at a given size
  42141. * @param texture Texture to copy from
  42142. * @param width defines the desired width
  42143. * @param height defines the desired height
  42144. * @param useBilinearMode defines if bilinear mode has to be used
  42145. * @return the generated texture
  42146. */
  42147. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  42148. /**
  42149. * Gets an environment BRDF texture for a given scene
  42150. * @param scene defines the hosting scene
  42151. * @returns the environment BRDF texture
  42152. */
  42153. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  42154. private static _environmentBRDFBase64Texture;
  42155. }
  42156. }
  42157. declare module BABYLON {
  42158. /** @hidden */
  42159. export var pbrFragmentDeclaration: {
  42160. name: string;
  42161. shader: string;
  42162. };
  42163. }
  42164. declare module BABYLON {
  42165. /** @hidden */
  42166. export var pbrUboDeclaration: {
  42167. name: string;
  42168. shader: string;
  42169. };
  42170. }
  42171. declare module BABYLON {
  42172. /** @hidden */
  42173. export var pbrFunctions: {
  42174. name: string;
  42175. shader: string;
  42176. };
  42177. }
  42178. declare module BABYLON {
  42179. /** @hidden */
  42180. export var harmonicsFunctions: {
  42181. name: string;
  42182. shader: string;
  42183. };
  42184. }
  42185. declare module BABYLON {
  42186. /** @hidden */
  42187. export var pbrLightFunctions: {
  42188. name: string;
  42189. shader: string;
  42190. };
  42191. }
  42192. declare module BABYLON {
  42193. /** @hidden */
  42194. export var pbrPixelShader: {
  42195. name: string;
  42196. shader: string;
  42197. };
  42198. }
  42199. declare module BABYLON {
  42200. /** @hidden */
  42201. export var pbrVertexDeclaration: {
  42202. name: string;
  42203. shader: string;
  42204. };
  42205. }
  42206. declare module BABYLON {
  42207. /** @hidden */
  42208. export var pbrVertexShader: {
  42209. name: string;
  42210. shader: string;
  42211. };
  42212. }
  42213. declare module BABYLON {
  42214. /**
  42215. * The Physically based material base class of BJS.
  42216. *
  42217. * This offers the main features of a standard PBR material.
  42218. * For more information, please refer to the documentation :
  42219. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  42220. */
  42221. export abstract class PBRBaseMaterial extends PushMaterial {
  42222. /**
  42223. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  42224. */
  42225. static readonly PBRMATERIAL_OPAQUE: number;
  42226. /**
  42227. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  42228. */
  42229. static readonly PBRMATERIAL_ALPHATEST: number;
  42230. /**
  42231. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42232. */
  42233. static readonly PBRMATERIAL_ALPHABLEND: number;
  42234. /**
  42235. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42236. * They are also discarded below the alpha cutoff threshold to improve performances.
  42237. */
  42238. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  42239. /**
  42240. * Defines the default value of how much AO map is occluding the analytical lights
  42241. * (point spot...).
  42242. */
  42243. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  42244. /**
  42245. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  42246. */
  42247. static readonly LIGHTFALLOFF_PHYSICAL: number;
  42248. /**
  42249. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  42250. * to enhance interoperability with other engines.
  42251. */
  42252. static readonly LIGHTFALLOFF_GLTF: number;
  42253. /**
  42254. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  42255. * to enhance interoperability with other materials.
  42256. */
  42257. static readonly LIGHTFALLOFF_STANDARD: number;
  42258. /**
  42259. * Intensity of the direct lights e.g. the four lights available in your scene.
  42260. * This impacts both the direct diffuse and specular highlights.
  42261. */
  42262. protected _directIntensity: number;
  42263. /**
  42264. * Intensity of the emissive part of the material.
  42265. * This helps controlling the emissive effect without modifying the emissive color.
  42266. */
  42267. protected _emissiveIntensity: number;
  42268. /**
  42269. * Intensity of the environment e.g. how much the environment will light the object
  42270. * either through harmonics for rough material or through the refelction for shiny ones.
  42271. */
  42272. protected _environmentIntensity: number;
  42273. /**
  42274. * This is a special control allowing the reduction of the specular highlights coming from the
  42275. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  42276. */
  42277. protected _specularIntensity: number;
  42278. /**
  42279. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  42280. */
  42281. private _lightingInfos;
  42282. /**
  42283. * Debug Control allowing disabling the bump map on this material.
  42284. */
  42285. protected _disableBumpMap: boolean;
  42286. /**
  42287. * AKA Diffuse Texture in standard nomenclature.
  42288. */
  42289. protected _albedoTexture: BaseTexture;
  42290. /**
  42291. * AKA Occlusion Texture in other nomenclature.
  42292. */
  42293. protected _ambientTexture: BaseTexture;
  42294. /**
  42295. * AKA Occlusion Texture Intensity in other nomenclature.
  42296. */
  42297. protected _ambientTextureStrength: number;
  42298. /**
  42299. * Defines how much the AO map is occluding the analytical lights (point spot...).
  42300. * 1 means it completely occludes it
  42301. * 0 mean it has no impact
  42302. */
  42303. protected _ambientTextureImpactOnAnalyticalLights: number;
  42304. /**
  42305. * Stores the alpha values in a texture.
  42306. */
  42307. protected _opacityTexture: BaseTexture;
  42308. /**
  42309. * Stores the reflection values in a texture.
  42310. */
  42311. protected _reflectionTexture: BaseTexture;
  42312. /**
  42313. * Stores the refraction values in a texture.
  42314. */
  42315. protected _refractionTexture: BaseTexture;
  42316. /**
  42317. * Stores the emissive values in a texture.
  42318. */
  42319. protected _emissiveTexture: BaseTexture;
  42320. /**
  42321. * AKA Specular texture in other nomenclature.
  42322. */
  42323. protected _reflectivityTexture: BaseTexture;
  42324. /**
  42325. * Used to switch from specular/glossiness to metallic/roughness workflow.
  42326. */
  42327. protected _metallicTexture: BaseTexture;
  42328. /**
  42329. * Specifies the metallic scalar of the metallic/roughness workflow.
  42330. * Can also be used to scale the metalness values of the metallic texture.
  42331. */
  42332. protected _metallic: Nullable<number>;
  42333. /**
  42334. * Specifies the roughness scalar of the metallic/roughness workflow.
  42335. * Can also be used to scale the roughness values of the metallic texture.
  42336. */
  42337. protected _roughness: Nullable<number>;
  42338. /**
  42339. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  42340. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  42341. */
  42342. protected _microSurfaceTexture: BaseTexture;
  42343. /**
  42344. * Stores surface normal data used to displace a mesh in a texture.
  42345. */
  42346. protected _bumpTexture: BaseTexture;
  42347. /**
  42348. * Stores the pre-calculated light information of a mesh in a texture.
  42349. */
  42350. protected _lightmapTexture: BaseTexture;
  42351. /**
  42352. * The color of a material in ambient lighting.
  42353. */
  42354. protected _ambientColor: Color3;
  42355. /**
  42356. * AKA Diffuse Color in other nomenclature.
  42357. */
  42358. protected _albedoColor: Color3;
  42359. /**
  42360. * AKA Specular Color in other nomenclature.
  42361. */
  42362. protected _reflectivityColor: Color3;
  42363. /**
  42364. * The color applied when light is reflected from a material.
  42365. */
  42366. protected _reflectionColor: Color3;
  42367. /**
  42368. * The color applied when light is emitted from a material.
  42369. */
  42370. protected _emissiveColor: Color3;
  42371. /**
  42372. * AKA Glossiness in other nomenclature.
  42373. */
  42374. protected _microSurface: number;
  42375. /**
  42376. * source material index of refraction (IOR)' / 'destination material IOR.
  42377. */
  42378. protected _indexOfRefraction: number;
  42379. /**
  42380. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  42381. */
  42382. protected _invertRefractionY: boolean;
  42383. /**
  42384. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  42385. * Materials half opaque for instance using refraction could benefit from this control.
  42386. */
  42387. protected _linkRefractionWithTransparency: boolean;
  42388. /**
  42389. * Specifies that the material will use the light map as a show map.
  42390. */
  42391. protected _useLightmapAsShadowmap: boolean;
  42392. /**
  42393. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  42394. * makes the reflect vector face the model (under horizon).
  42395. */
  42396. protected _useHorizonOcclusion: boolean;
  42397. /**
  42398. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  42399. * too much the area relying on ambient texture to define their ambient occlusion.
  42400. */
  42401. protected _useRadianceOcclusion: boolean;
  42402. /**
  42403. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  42404. */
  42405. protected _useAlphaFromAlbedoTexture: boolean;
  42406. /**
  42407. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  42408. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  42409. */
  42410. protected _useSpecularOverAlpha: boolean;
  42411. /**
  42412. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  42413. */
  42414. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  42415. /**
  42416. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  42417. */
  42418. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  42419. /**
  42420. * Specifies if the metallic texture contains the roughness information in its green channel.
  42421. */
  42422. protected _useRoughnessFromMetallicTextureGreen: boolean;
  42423. /**
  42424. * Specifies if the metallic texture contains the metallness information in its blue channel.
  42425. */
  42426. protected _useMetallnessFromMetallicTextureBlue: boolean;
  42427. /**
  42428. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  42429. */
  42430. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  42431. /**
  42432. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  42433. */
  42434. protected _useAmbientInGrayScale: boolean;
  42435. /**
  42436. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  42437. * The material will try to infer what glossiness each pixel should be.
  42438. */
  42439. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  42440. /**
  42441. * Defines the falloff type used in this material.
  42442. * It by default is Physical.
  42443. */
  42444. protected _lightFalloff: number;
  42445. /**
  42446. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  42447. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  42448. */
  42449. protected _useRadianceOverAlpha: boolean;
  42450. /**
  42451. * Allows using an object space normal map (instead of tangent space).
  42452. */
  42453. protected _useObjectSpaceNormalMap: boolean;
  42454. /**
  42455. * Allows using the bump map in parallax mode.
  42456. */
  42457. protected _useParallax: boolean;
  42458. /**
  42459. * Allows using the bump map in parallax occlusion mode.
  42460. */
  42461. protected _useParallaxOcclusion: boolean;
  42462. /**
  42463. * Controls the scale bias of the parallax mode.
  42464. */
  42465. protected _parallaxScaleBias: number;
  42466. /**
  42467. * If sets to true, disables all the lights affecting the material.
  42468. */
  42469. protected _disableLighting: boolean;
  42470. /**
  42471. * Number of Simultaneous lights allowed on the material.
  42472. */
  42473. protected _maxSimultaneousLights: number;
  42474. /**
  42475. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  42476. */
  42477. protected _invertNormalMapX: boolean;
  42478. /**
  42479. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  42480. */
  42481. protected _invertNormalMapY: boolean;
  42482. /**
  42483. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42484. */
  42485. protected _twoSidedLighting: boolean;
  42486. /**
  42487. * Defines the alpha limits in alpha test mode.
  42488. */
  42489. protected _alphaCutOff: number;
  42490. /**
  42491. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  42492. */
  42493. protected _forceAlphaTest: boolean;
  42494. /**
  42495. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42496. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  42497. */
  42498. protected _useAlphaFresnel: boolean;
  42499. /**
  42500. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42501. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  42502. */
  42503. protected _useLinearAlphaFresnel: boolean;
  42504. /**
  42505. * The transparency mode of the material.
  42506. */
  42507. protected _transparencyMode: Nullable<number>;
  42508. /**
  42509. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  42510. * from cos thetav and roughness:
  42511. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  42512. */
  42513. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  42514. /**
  42515. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  42516. */
  42517. protected _forceIrradianceInFragment: boolean;
  42518. /**
  42519. * Force normal to face away from face.
  42520. */
  42521. protected _forceNormalForward: boolean;
  42522. /**
  42523. * Enables specular anti aliasing in the PBR shader.
  42524. * It will both interacts on the Geometry for analytical and IBL lighting.
  42525. * It also prefilter the roughness map based on the bump values.
  42526. */
  42527. protected _enableSpecularAntiAliasing: boolean;
  42528. /**
  42529. * Default configuration related to image processing available in the PBR Material.
  42530. */
  42531. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42532. /**
  42533. * Keep track of the image processing observer to allow dispose and replace.
  42534. */
  42535. private _imageProcessingObserver;
  42536. /**
  42537. * Attaches a new image processing configuration to the PBR Material.
  42538. * @param configuration
  42539. */
  42540. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42541. /**
  42542. * Stores the available render targets.
  42543. */
  42544. private _renderTargets;
  42545. /**
  42546. * Sets the global ambient color for the material used in lighting calculations.
  42547. */
  42548. private _globalAmbientColor;
  42549. /**
  42550. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  42551. */
  42552. private _useLogarithmicDepth;
  42553. /**
  42554. * If set to true, no lighting calculations will be applied.
  42555. */
  42556. private _unlit;
  42557. /**
  42558. * Instantiates a new PBRMaterial instance.
  42559. *
  42560. * @param name The material name
  42561. * @param scene The scene the material will be use in.
  42562. */
  42563. constructor(name: string, scene: Scene);
  42564. /**
  42565. * Gets a boolean indicating that current material needs to register RTT
  42566. */
  42567. readonly hasRenderTargetTextures: boolean;
  42568. /**
  42569. * Gets the name of the material class.
  42570. */
  42571. getClassName(): string;
  42572. /**
  42573. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  42574. */
  42575. /**
  42576. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  42577. */
  42578. useLogarithmicDepth: boolean;
  42579. /**
  42580. * Gets the current transparency mode.
  42581. */
  42582. /**
  42583. * Sets the transparency mode of the material.
  42584. *
  42585. * | Value | Type | Description |
  42586. * | ----- | ----------------------------------- | ----------- |
  42587. * | 0 | OPAQUE | |
  42588. * | 1 | ALPHATEST | |
  42589. * | 2 | ALPHABLEND | |
  42590. * | 3 | ALPHATESTANDBLEND | |
  42591. *
  42592. */
  42593. transparencyMode: Nullable<number>;
  42594. /**
  42595. * Returns true if alpha blending should be disabled.
  42596. */
  42597. private readonly _disableAlphaBlending;
  42598. /**
  42599. * Specifies whether or not this material should be rendered in alpha blend mode.
  42600. */
  42601. needAlphaBlending(): boolean;
  42602. /**
  42603. * Specifies if the mesh will require alpha blending.
  42604. * @param mesh - BJS mesh.
  42605. */
  42606. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  42607. /**
  42608. * Specifies whether or not this material should be rendered in alpha test mode.
  42609. */
  42610. needAlphaTesting(): boolean;
  42611. /**
  42612. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  42613. */
  42614. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  42615. /**
  42616. * Gets the texture used for the alpha test.
  42617. */
  42618. getAlphaTestTexture(): BaseTexture;
  42619. /**
  42620. * Specifies that the submesh is ready to be used.
  42621. * @param mesh - BJS mesh.
  42622. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  42623. * @param useInstances - Specifies that instances should be used.
  42624. * @returns - boolean indicating that the submesh is ready or not.
  42625. */
  42626. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42627. /**
  42628. * Specifies if the material uses metallic roughness workflow.
  42629. * @returns boolean specifiying if the material uses metallic roughness workflow.
  42630. */
  42631. isMetallicWorkflow(): boolean;
  42632. private _prepareEffect;
  42633. private _prepareDefines;
  42634. /**
  42635. * Force shader compilation
  42636. */
  42637. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  42638. clipPlane: boolean;
  42639. }>): void;
  42640. /**
  42641. * Initializes the uniform buffer layout for the shader.
  42642. */
  42643. buildUniformLayout(): void;
  42644. /**
  42645. * Unbinds the textures.
  42646. */
  42647. unbind(): void;
  42648. /**
  42649. * Binds the submesh data.
  42650. * @param world - The world matrix.
  42651. * @param mesh - The BJS mesh.
  42652. * @param subMesh - A submesh of the BJS mesh.
  42653. */
  42654. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42655. /**
  42656. * Returns the animatable textures.
  42657. * @returns - Array of animatable textures.
  42658. */
  42659. getAnimatables(): IAnimatable[];
  42660. /**
  42661. * Returns the texture used for reflections.
  42662. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  42663. */
  42664. private _getReflectionTexture;
  42665. /**
  42666. * Returns the texture used for refraction or null if none is used.
  42667. * @returns - Refection texture if present. If no refraction texture and refraction
  42668. * is linked with transparency, returns environment texture. Otherwise, returns null.
  42669. */
  42670. private _getRefractionTexture;
  42671. /**
  42672. * Disposes the resources of the material.
  42673. * @param forceDisposeEffect - Forces the disposal of effects.
  42674. * @param forceDisposeTextures - Forces the disposal of all textures.
  42675. */
  42676. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42677. }
  42678. }
  42679. declare module BABYLON {
  42680. /**
  42681. * The Physically based material of BJS.
  42682. *
  42683. * This offers the main features of a standard PBR material.
  42684. * For more information, please refer to the documentation :
  42685. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  42686. */
  42687. export class PBRMaterial extends PBRBaseMaterial {
  42688. /**
  42689. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  42690. */
  42691. static readonly PBRMATERIAL_OPAQUE: number;
  42692. /**
  42693. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  42694. */
  42695. static readonly PBRMATERIAL_ALPHATEST: number;
  42696. /**
  42697. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42698. */
  42699. static readonly PBRMATERIAL_ALPHABLEND: number;
  42700. /**
  42701. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42702. * They are also discarded below the alpha cutoff threshold to improve performances.
  42703. */
  42704. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  42705. /**
  42706. * Defines the default value of how much AO map is occluding the analytical lights
  42707. * (point spot...).
  42708. */
  42709. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  42710. /**
  42711. * Intensity of the direct lights e.g. the four lights available in your scene.
  42712. * This impacts both the direct diffuse and specular highlights.
  42713. */
  42714. directIntensity: number;
  42715. /**
  42716. * Intensity of the emissive part of the material.
  42717. * This helps controlling the emissive effect without modifying the emissive color.
  42718. */
  42719. emissiveIntensity: number;
  42720. /**
  42721. * Intensity of the environment e.g. how much the environment will light the object
  42722. * either through harmonics for rough material or through the refelction for shiny ones.
  42723. */
  42724. environmentIntensity: number;
  42725. /**
  42726. * This is a special control allowing the reduction of the specular highlights coming from the
  42727. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  42728. */
  42729. specularIntensity: number;
  42730. /**
  42731. * Debug Control allowing disabling the bump map on this material.
  42732. */
  42733. disableBumpMap: boolean;
  42734. /**
  42735. * AKA Diffuse Texture in standard nomenclature.
  42736. */
  42737. albedoTexture: BaseTexture;
  42738. /**
  42739. * AKA Occlusion Texture in other nomenclature.
  42740. */
  42741. ambientTexture: BaseTexture;
  42742. /**
  42743. * AKA Occlusion Texture Intensity in other nomenclature.
  42744. */
  42745. ambientTextureStrength: number;
  42746. /**
  42747. * Defines how much the AO map is occluding the analytical lights (point spot...).
  42748. * 1 means it completely occludes it
  42749. * 0 mean it has no impact
  42750. */
  42751. ambientTextureImpactOnAnalyticalLights: number;
  42752. /**
  42753. * Stores the alpha values in a texture.
  42754. */
  42755. opacityTexture: BaseTexture;
  42756. /**
  42757. * Stores the reflection values in a texture.
  42758. */
  42759. reflectionTexture: Nullable<BaseTexture>;
  42760. /**
  42761. * Stores the emissive values in a texture.
  42762. */
  42763. emissiveTexture: BaseTexture;
  42764. /**
  42765. * AKA Specular texture in other nomenclature.
  42766. */
  42767. reflectivityTexture: BaseTexture;
  42768. /**
  42769. * Used to switch from specular/glossiness to metallic/roughness workflow.
  42770. */
  42771. metallicTexture: BaseTexture;
  42772. /**
  42773. * Specifies the metallic scalar of the metallic/roughness workflow.
  42774. * Can also be used to scale the metalness values of the metallic texture.
  42775. */
  42776. metallic: Nullable<number>;
  42777. /**
  42778. * Specifies the roughness scalar of the metallic/roughness workflow.
  42779. * Can also be used to scale the roughness values of the metallic texture.
  42780. */
  42781. roughness: Nullable<number>;
  42782. /**
  42783. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  42784. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  42785. */
  42786. microSurfaceTexture: BaseTexture;
  42787. /**
  42788. * Stores surface normal data used to displace a mesh in a texture.
  42789. */
  42790. bumpTexture: BaseTexture;
  42791. /**
  42792. * Stores the pre-calculated light information of a mesh in a texture.
  42793. */
  42794. lightmapTexture: BaseTexture;
  42795. /**
  42796. * Stores the refracted light information in a texture.
  42797. */
  42798. refractionTexture: BaseTexture;
  42799. /**
  42800. * The color of a material in ambient lighting.
  42801. */
  42802. ambientColor: Color3;
  42803. /**
  42804. * AKA Diffuse Color in other nomenclature.
  42805. */
  42806. albedoColor: Color3;
  42807. /**
  42808. * AKA Specular Color in other nomenclature.
  42809. */
  42810. reflectivityColor: Color3;
  42811. /**
  42812. * The color reflected from the material.
  42813. */
  42814. reflectionColor: Color3;
  42815. /**
  42816. * The color emitted from the material.
  42817. */
  42818. emissiveColor: Color3;
  42819. /**
  42820. * AKA Glossiness in other nomenclature.
  42821. */
  42822. microSurface: number;
  42823. /**
  42824. * source material index of refraction (IOR)' / 'destination material IOR.
  42825. */
  42826. indexOfRefraction: number;
  42827. /**
  42828. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  42829. */
  42830. invertRefractionY: boolean;
  42831. /**
  42832. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  42833. * Materials half opaque for instance using refraction could benefit from this control.
  42834. */
  42835. linkRefractionWithTransparency: boolean;
  42836. /**
  42837. * If true, the light map contains occlusion information instead of lighting info.
  42838. */
  42839. useLightmapAsShadowmap: boolean;
  42840. /**
  42841. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  42842. */
  42843. useAlphaFromAlbedoTexture: boolean;
  42844. /**
  42845. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  42846. */
  42847. forceAlphaTest: boolean;
  42848. /**
  42849. * Defines the alpha limits in alpha test mode.
  42850. */
  42851. alphaCutOff: number;
  42852. /**
  42853. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  42854. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  42855. */
  42856. useSpecularOverAlpha: boolean;
  42857. /**
  42858. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  42859. */
  42860. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  42861. /**
  42862. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  42863. */
  42864. useRoughnessFromMetallicTextureAlpha: boolean;
  42865. /**
  42866. * Specifies if the metallic texture contains the roughness information in its green channel.
  42867. */
  42868. useRoughnessFromMetallicTextureGreen: boolean;
  42869. /**
  42870. * Specifies if the metallic texture contains the metallness information in its blue channel.
  42871. */
  42872. useMetallnessFromMetallicTextureBlue: boolean;
  42873. /**
  42874. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  42875. */
  42876. useAmbientOcclusionFromMetallicTextureRed: boolean;
  42877. /**
  42878. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  42879. */
  42880. useAmbientInGrayScale: boolean;
  42881. /**
  42882. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  42883. * The material will try to infer what glossiness each pixel should be.
  42884. */
  42885. useAutoMicroSurfaceFromReflectivityMap: boolean;
  42886. /**
  42887. * BJS is using an harcoded light falloff based on a manually sets up range.
  42888. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  42889. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  42890. */
  42891. /**
  42892. * BJS is using an harcoded light falloff based on a manually sets up range.
  42893. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  42894. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  42895. */
  42896. usePhysicalLightFalloff: boolean;
  42897. /**
  42898. * In order to support the falloff compatibility with gltf, a special mode has been added
  42899. * to reproduce the gltf light falloff.
  42900. */
  42901. /**
  42902. * In order to support the falloff compatibility with gltf, a special mode has been added
  42903. * to reproduce the gltf light falloff.
  42904. */
  42905. useGLTFLightFalloff: boolean;
  42906. /**
  42907. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  42908. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  42909. */
  42910. useRadianceOverAlpha: boolean;
  42911. /**
  42912. * Allows using an object space normal map (instead of tangent space).
  42913. */
  42914. useObjectSpaceNormalMap: boolean;
  42915. /**
  42916. * Allows using the bump map in parallax mode.
  42917. */
  42918. useParallax: boolean;
  42919. /**
  42920. * Allows using the bump map in parallax occlusion mode.
  42921. */
  42922. useParallaxOcclusion: boolean;
  42923. /**
  42924. * Controls the scale bias of the parallax mode.
  42925. */
  42926. parallaxScaleBias: number;
  42927. /**
  42928. * If sets to true, disables all the lights affecting the material.
  42929. */
  42930. disableLighting: boolean;
  42931. /**
  42932. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  42933. */
  42934. forceIrradianceInFragment: boolean;
  42935. /**
  42936. * Number of Simultaneous lights allowed on the material.
  42937. */
  42938. maxSimultaneousLights: number;
  42939. /**
  42940. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  42941. */
  42942. invertNormalMapX: boolean;
  42943. /**
  42944. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  42945. */
  42946. invertNormalMapY: boolean;
  42947. /**
  42948. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42949. */
  42950. twoSidedLighting: boolean;
  42951. /**
  42952. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42953. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  42954. */
  42955. useAlphaFresnel: boolean;
  42956. /**
  42957. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42958. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  42959. */
  42960. useLinearAlphaFresnel: boolean;
  42961. /**
  42962. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42963. * And/Or occlude the blended part.
  42964. */
  42965. environmentBRDFTexture: Nullable<BaseTexture>;
  42966. /**
  42967. * Force normal to face away from face.
  42968. */
  42969. forceNormalForward: boolean;
  42970. /**
  42971. * Enables specular anti aliasing in the PBR shader.
  42972. * It will both interacts on the Geometry for analytical and IBL lighting.
  42973. * It also prefilter the roughness map based on the bump values.
  42974. */
  42975. enableSpecularAntiAliasing: boolean;
  42976. /**
  42977. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  42978. * makes the reflect vector face the model (under horizon).
  42979. */
  42980. useHorizonOcclusion: boolean;
  42981. /**
  42982. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  42983. * too much the area relying on ambient texture to define their ambient occlusion.
  42984. */
  42985. useRadianceOcclusion: boolean;
  42986. /**
  42987. * If set to true, no lighting calculations will be applied.
  42988. */
  42989. unlit: boolean;
  42990. /**
  42991. * Gets the image processing configuration used either in this material.
  42992. */
  42993. /**
  42994. * Sets the Default image processing configuration used either in the this material.
  42995. *
  42996. * If sets to null, the scene one is in use.
  42997. */
  42998. imageProcessingConfiguration: ImageProcessingConfiguration;
  42999. /**
  43000. * Gets wether the color curves effect is enabled.
  43001. */
  43002. /**
  43003. * Sets wether the color curves effect is enabled.
  43004. */
  43005. cameraColorCurvesEnabled: boolean;
  43006. /**
  43007. * Gets wether the color grading effect is enabled.
  43008. */
  43009. /**
  43010. * Gets wether the color grading effect is enabled.
  43011. */
  43012. cameraColorGradingEnabled: boolean;
  43013. /**
  43014. * Gets wether tonemapping is enabled or not.
  43015. */
  43016. /**
  43017. * Sets wether tonemapping is enabled or not
  43018. */
  43019. cameraToneMappingEnabled: boolean;
  43020. /**
  43021. * The camera exposure used on this material.
  43022. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43023. * This corresponds to a photographic exposure.
  43024. */
  43025. /**
  43026. * The camera exposure used on this material.
  43027. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43028. * This corresponds to a photographic exposure.
  43029. */
  43030. cameraExposure: number;
  43031. /**
  43032. * Gets The camera contrast used on this material.
  43033. */
  43034. /**
  43035. * Sets The camera contrast used on this material.
  43036. */
  43037. cameraContrast: number;
  43038. /**
  43039. * Gets the Color Grading 2D Lookup Texture.
  43040. */
  43041. /**
  43042. * Sets the Color Grading 2D Lookup Texture.
  43043. */
  43044. cameraColorGradingTexture: Nullable<BaseTexture>;
  43045. /**
  43046. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43047. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43048. * 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;
  43049. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43050. */
  43051. /**
  43052. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43053. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43054. * 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;
  43055. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43056. */
  43057. cameraColorCurves: Nullable<ColorCurves>;
  43058. /**
  43059. * Instantiates a new PBRMaterial instance.
  43060. *
  43061. * @param name The material name
  43062. * @param scene The scene the material will be use in.
  43063. */
  43064. constructor(name: string, scene: Scene);
  43065. /**
  43066. * Returns the name of this material class.
  43067. */
  43068. getClassName(): string;
  43069. /**
  43070. * Returns an array of the actively used textures.
  43071. * @returns - Array of BaseTextures
  43072. */
  43073. getActiveTextures(): BaseTexture[];
  43074. /**
  43075. * Checks to see if a texture is used in the material.
  43076. * @param texture - Base texture to use.
  43077. * @returns - Boolean specifying if a texture is used in the material.
  43078. */
  43079. hasTexture(texture: BaseTexture): boolean;
  43080. /**
  43081. * Makes a duplicate of the current material.
  43082. * @param name - name to use for the new material.
  43083. */
  43084. clone(name: string): PBRMaterial;
  43085. /**
  43086. * Serializes this PBR Material.
  43087. * @returns - An object with the serialized material.
  43088. */
  43089. serialize(): any;
  43090. /**
  43091. * Parses a PBR Material from a serialized object.
  43092. * @param source - Serialized object.
  43093. * @param scene - BJS scene instance.
  43094. * @param rootUrl - url for the scene object
  43095. * @returns - PBRMaterial
  43096. */
  43097. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  43098. }
  43099. }
  43100. declare module BABYLON {
  43101. /** @hidden */
  43102. export var _forceSceneHelpersToBundle: boolean;
  43103. interface Scene {
  43104. /**
  43105. * Creates a default light for the scene.
  43106. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  43107. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  43108. */
  43109. createDefaultLight(replace?: boolean): void;
  43110. /**
  43111. * Creates a default camera for the scene.
  43112. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  43113. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  43114. * @param replace has default false, when true replaces the active camera in the scene
  43115. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  43116. */
  43117. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  43118. /**
  43119. * Creates a default camera and a default light.
  43120. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  43121. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  43122. * @param replace has the default false, when true replaces the active camera/light in the scene
  43123. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  43124. */
  43125. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  43126. /**
  43127. * Creates a new sky box
  43128. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  43129. * @param environmentTexture defines the texture to use as environment texture
  43130. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  43131. * @param scale defines the overall scale of the skybox
  43132. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  43133. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  43134. * @returns a new mesh holding the sky box
  43135. */
  43136. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  43137. /**
  43138. * Creates a new environment
  43139. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  43140. * @param options defines the options you can use to configure the environment
  43141. * @returns the new EnvironmentHelper
  43142. */
  43143. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  43144. /**
  43145. * Creates a new VREXperienceHelper
  43146. * @see http://doc.babylonjs.com/how_to/webvr_helper
  43147. * @param webVROptions defines the options used to create the new VREXperienceHelper
  43148. * @returns a new VREXperienceHelper
  43149. */
  43150. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  43151. /**
  43152. * Creates a new XREXperienceHelper
  43153. * @see http://doc.babylonjs.com/how_to/webxr
  43154. * @returns a promise for a new XREXperienceHelper
  43155. */
  43156. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  43157. }
  43158. }
  43159. declare module BABYLON {
  43160. /**
  43161. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  43162. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  43163. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  43164. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43165. */
  43166. export class VideoDome extends TransformNode {
  43167. private _useDirectMapping;
  43168. /**
  43169. * The video texture being displayed on the sphere
  43170. */
  43171. protected _videoTexture: VideoTexture;
  43172. /**
  43173. * Gets the video texture being displayed on the sphere
  43174. */
  43175. readonly videoTexture: VideoTexture;
  43176. /**
  43177. * The skybox material
  43178. */
  43179. protected _material: BackgroundMaterial;
  43180. /**
  43181. * The surface used for the skybox
  43182. */
  43183. protected _mesh: Mesh;
  43184. /**
  43185. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43186. * Also see the options.resolution property.
  43187. */
  43188. fovMultiplier: number;
  43189. /**
  43190. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  43191. * @param name Element's name, child elements will append suffixes for their own names.
  43192. * @param urlsOrVideo defines the url(s) or the video element to use
  43193. * @param options An object containing optional or exposed sub element properties
  43194. */
  43195. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  43196. resolution?: number;
  43197. clickToPlay?: boolean;
  43198. autoPlay?: boolean;
  43199. loop?: boolean;
  43200. size?: number;
  43201. poster?: string;
  43202. useDirectMapping?: boolean;
  43203. }, scene: Scene);
  43204. /**
  43205. * Releases resources associated with this node.
  43206. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43207. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43208. */
  43209. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43210. }
  43211. }
  43212. declare module BABYLON {
  43213. /**
  43214. * This class can be used to get instrumentation data from a Babylon engine
  43215. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  43216. */
  43217. export class EngineInstrumentation implements IDisposable {
  43218. /**
  43219. * Define the instrumented engine.
  43220. */
  43221. engine: Engine;
  43222. private _captureGPUFrameTime;
  43223. private _gpuFrameTimeToken;
  43224. private _gpuFrameTime;
  43225. private _captureShaderCompilationTime;
  43226. private _shaderCompilationTime;
  43227. private _onBeginFrameObserver;
  43228. private _onEndFrameObserver;
  43229. private _onBeforeShaderCompilationObserver;
  43230. private _onAfterShaderCompilationObserver;
  43231. /**
  43232. * Gets the perf counter used for GPU frame time
  43233. */
  43234. readonly gpuFrameTimeCounter: PerfCounter;
  43235. /**
  43236. * Gets the GPU frame time capture status
  43237. */
  43238. /**
  43239. * Enable or disable the GPU frame time capture
  43240. */
  43241. captureGPUFrameTime: boolean;
  43242. /**
  43243. * Gets the perf counter used for shader compilation time
  43244. */
  43245. readonly shaderCompilationTimeCounter: PerfCounter;
  43246. /**
  43247. * Gets the shader compilation time capture status
  43248. */
  43249. /**
  43250. * Enable or disable the shader compilation time capture
  43251. */
  43252. captureShaderCompilationTime: boolean;
  43253. /**
  43254. * Instantiates a new engine instrumentation.
  43255. * This class can be used to get instrumentation data from a Babylon engine
  43256. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  43257. * @param engine Defines the engine to instrument
  43258. */
  43259. constructor(
  43260. /**
  43261. * Define the instrumented engine.
  43262. */
  43263. engine: Engine);
  43264. /**
  43265. * Dispose and release associated resources.
  43266. */
  43267. dispose(): void;
  43268. }
  43269. }
  43270. declare module BABYLON {
  43271. /**
  43272. * This class can be used to get instrumentation data from a Babylon engine
  43273. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  43274. */
  43275. export class SceneInstrumentation implements IDisposable {
  43276. /**
  43277. * Defines the scene to instrument
  43278. */
  43279. scene: Scene;
  43280. private _captureActiveMeshesEvaluationTime;
  43281. private _activeMeshesEvaluationTime;
  43282. private _captureRenderTargetsRenderTime;
  43283. private _renderTargetsRenderTime;
  43284. private _captureFrameTime;
  43285. private _frameTime;
  43286. private _captureRenderTime;
  43287. private _renderTime;
  43288. private _captureInterFrameTime;
  43289. private _interFrameTime;
  43290. private _captureParticlesRenderTime;
  43291. private _particlesRenderTime;
  43292. private _captureSpritesRenderTime;
  43293. private _spritesRenderTime;
  43294. private _capturePhysicsTime;
  43295. private _physicsTime;
  43296. private _captureAnimationsTime;
  43297. private _animationsTime;
  43298. private _captureCameraRenderTime;
  43299. private _cameraRenderTime;
  43300. private _onBeforeActiveMeshesEvaluationObserver;
  43301. private _onAfterActiveMeshesEvaluationObserver;
  43302. private _onBeforeRenderTargetsRenderObserver;
  43303. private _onAfterRenderTargetsRenderObserver;
  43304. private _onAfterRenderObserver;
  43305. private _onBeforeDrawPhaseObserver;
  43306. private _onAfterDrawPhaseObserver;
  43307. private _onBeforeAnimationsObserver;
  43308. private _onBeforeParticlesRenderingObserver;
  43309. private _onAfterParticlesRenderingObserver;
  43310. private _onBeforeSpritesRenderingObserver;
  43311. private _onAfterSpritesRenderingObserver;
  43312. private _onBeforePhysicsObserver;
  43313. private _onAfterPhysicsObserver;
  43314. private _onAfterAnimationsObserver;
  43315. private _onBeforeCameraRenderObserver;
  43316. private _onAfterCameraRenderObserver;
  43317. /**
  43318. * Gets the perf counter used for active meshes evaluation time
  43319. */
  43320. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  43321. /**
  43322. * Gets the active meshes evaluation time capture status
  43323. */
  43324. /**
  43325. * Enable or disable the active meshes evaluation time capture
  43326. */
  43327. captureActiveMeshesEvaluationTime: boolean;
  43328. /**
  43329. * Gets the perf counter used for render targets render time
  43330. */
  43331. readonly renderTargetsRenderTimeCounter: PerfCounter;
  43332. /**
  43333. * Gets the render targets render time capture status
  43334. */
  43335. /**
  43336. * Enable or disable the render targets render time capture
  43337. */
  43338. captureRenderTargetsRenderTime: boolean;
  43339. /**
  43340. * Gets the perf counter used for particles render time
  43341. */
  43342. readonly particlesRenderTimeCounter: PerfCounter;
  43343. /**
  43344. * Gets the particles render time capture status
  43345. */
  43346. /**
  43347. * Enable or disable the particles render time capture
  43348. */
  43349. captureParticlesRenderTime: boolean;
  43350. /**
  43351. * Gets the perf counter used for sprites render time
  43352. */
  43353. readonly spritesRenderTimeCounter: PerfCounter;
  43354. /**
  43355. * Gets the sprites render time capture status
  43356. */
  43357. /**
  43358. * Enable or disable the sprites render time capture
  43359. */
  43360. captureSpritesRenderTime: boolean;
  43361. /**
  43362. * Gets the perf counter used for physics time
  43363. */
  43364. readonly physicsTimeCounter: PerfCounter;
  43365. /**
  43366. * Gets the physics time capture status
  43367. */
  43368. /**
  43369. * Enable or disable the physics time capture
  43370. */
  43371. capturePhysicsTime: boolean;
  43372. /**
  43373. * Gets the perf counter used for animations time
  43374. */
  43375. readonly animationsTimeCounter: PerfCounter;
  43376. /**
  43377. * Gets the animations time capture status
  43378. */
  43379. /**
  43380. * Enable or disable the animations time capture
  43381. */
  43382. captureAnimationsTime: boolean;
  43383. /**
  43384. * Gets the perf counter used for frame time capture
  43385. */
  43386. readonly frameTimeCounter: PerfCounter;
  43387. /**
  43388. * Gets the frame time capture status
  43389. */
  43390. /**
  43391. * Enable or disable the frame time capture
  43392. */
  43393. captureFrameTime: boolean;
  43394. /**
  43395. * Gets the perf counter used for inter-frames time capture
  43396. */
  43397. readonly interFrameTimeCounter: PerfCounter;
  43398. /**
  43399. * Gets the inter-frames time capture status
  43400. */
  43401. /**
  43402. * Enable or disable the inter-frames time capture
  43403. */
  43404. captureInterFrameTime: boolean;
  43405. /**
  43406. * Gets the perf counter used for render time capture
  43407. */
  43408. readonly renderTimeCounter: PerfCounter;
  43409. /**
  43410. * Gets the render time capture status
  43411. */
  43412. /**
  43413. * Enable or disable the render time capture
  43414. */
  43415. captureRenderTime: boolean;
  43416. /**
  43417. * Gets the perf counter used for camera render time capture
  43418. */
  43419. readonly cameraRenderTimeCounter: PerfCounter;
  43420. /**
  43421. * Gets the camera render time capture status
  43422. */
  43423. /**
  43424. * Enable or disable the camera render time capture
  43425. */
  43426. captureCameraRenderTime: boolean;
  43427. /**
  43428. * Gets the perf counter used for draw calls
  43429. */
  43430. readonly drawCallsCounter: PerfCounter;
  43431. /**
  43432. * Gets the perf counter used for texture collisions
  43433. */
  43434. readonly textureCollisionsCounter: PerfCounter;
  43435. /**
  43436. * Instantiates a new scene instrumentation.
  43437. * This class can be used to get instrumentation data from a Babylon engine
  43438. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  43439. * @param scene Defines the scene to instrument
  43440. */
  43441. constructor(
  43442. /**
  43443. * Defines the scene to instrument
  43444. */
  43445. scene: Scene);
  43446. /**
  43447. * Dispose and release associated resources.
  43448. */
  43449. dispose(): void;
  43450. }
  43451. }
  43452. declare module BABYLON {
  43453. /** @hidden */
  43454. export var glowMapGenerationPixelShader: {
  43455. name: string;
  43456. shader: string;
  43457. };
  43458. }
  43459. declare module BABYLON {
  43460. /** @hidden */
  43461. export var glowMapGenerationVertexShader: {
  43462. name: string;
  43463. shader: string;
  43464. };
  43465. }
  43466. declare module BABYLON {
  43467. /**
  43468. * Effect layer options. This helps customizing the behaviour
  43469. * of the effect layer.
  43470. */
  43471. export interface IEffectLayerOptions {
  43472. /**
  43473. * Multiplication factor apply to the canvas size to compute the render target size
  43474. * used to generated the objects (the smaller the faster).
  43475. */
  43476. mainTextureRatio: number;
  43477. /**
  43478. * Enforces a fixed size texture to ensure effect stability across devices.
  43479. */
  43480. mainTextureFixedSize?: number;
  43481. /**
  43482. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  43483. */
  43484. alphaBlendingMode: number;
  43485. /**
  43486. * The camera attached to the layer.
  43487. */
  43488. camera: Nullable<Camera>;
  43489. /**
  43490. * The rendering group to draw the layer in.
  43491. */
  43492. renderingGroupId: number;
  43493. }
  43494. /**
  43495. * The effect layer Helps adding post process effect blended with the main pass.
  43496. *
  43497. * This can be for instance use to generate glow or higlight effects on the scene.
  43498. *
  43499. * The effect layer class can not be used directly and is intented to inherited from to be
  43500. * customized per effects.
  43501. */
  43502. export abstract class EffectLayer {
  43503. private _vertexBuffers;
  43504. private _indexBuffer;
  43505. private _cachedDefines;
  43506. private _effectLayerMapGenerationEffect;
  43507. private _effectLayerOptions;
  43508. private _mergeEffect;
  43509. protected _scene: Scene;
  43510. protected _engine: Engine;
  43511. protected _maxSize: number;
  43512. protected _mainTextureDesiredSize: ISize;
  43513. protected _mainTexture: RenderTargetTexture;
  43514. protected _shouldRender: boolean;
  43515. protected _postProcesses: PostProcess[];
  43516. protected _textures: BaseTexture[];
  43517. protected _emissiveTextureAndColor: {
  43518. texture: Nullable<BaseTexture>;
  43519. color: Color4;
  43520. };
  43521. /**
  43522. * The name of the layer
  43523. */
  43524. name: string;
  43525. /**
  43526. * The clear color of the texture used to generate the glow map.
  43527. */
  43528. neutralColor: Color4;
  43529. /**
  43530. * Specifies wether the highlight layer is enabled or not.
  43531. */
  43532. isEnabled: boolean;
  43533. /**
  43534. * Gets the camera attached to the layer.
  43535. */
  43536. readonly camera: Nullable<Camera>;
  43537. /**
  43538. * Gets the rendering group id the layer should render in.
  43539. */
  43540. readonly renderingGroupId: number;
  43541. /**
  43542. * An event triggered when the effect layer has been disposed.
  43543. */
  43544. onDisposeObservable: Observable<EffectLayer>;
  43545. /**
  43546. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  43547. */
  43548. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  43549. /**
  43550. * An event triggered when the generated texture is being merged in the scene.
  43551. */
  43552. onBeforeComposeObservable: Observable<EffectLayer>;
  43553. /**
  43554. * An event triggered when the generated texture has been merged in the scene.
  43555. */
  43556. onAfterComposeObservable: Observable<EffectLayer>;
  43557. /**
  43558. * An event triggered when the efffect layer changes its size.
  43559. */
  43560. onSizeChangedObservable: Observable<EffectLayer>;
  43561. /** @hidden */
  43562. static _SceneComponentInitialization: (scene: Scene) => void;
  43563. /**
  43564. * Instantiates a new effect Layer and references it in the scene.
  43565. * @param name The name of the layer
  43566. * @param scene The scene to use the layer in
  43567. */
  43568. constructor(
  43569. /** The Friendly of the effect in the scene */
  43570. name: string, scene: Scene);
  43571. /**
  43572. * Get the effect name of the layer.
  43573. * @return The effect name
  43574. */
  43575. abstract getEffectName(): string;
  43576. /**
  43577. * Checks for the readiness of the element composing the layer.
  43578. * @param subMesh the mesh to check for
  43579. * @param useInstances specify wether or not to use instances to render the mesh
  43580. * @return true if ready otherwise, false
  43581. */
  43582. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43583. /**
  43584. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  43585. * @returns true if the effect requires stencil during the main canvas render pass.
  43586. */
  43587. abstract needStencil(): boolean;
  43588. /**
  43589. * Create the merge effect. This is the shader use to blit the information back
  43590. * to the main canvas at the end of the scene rendering.
  43591. * @returns The effect containing the shader used to merge the effect on the main canvas
  43592. */
  43593. protected abstract _createMergeEffect(): Effect;
  43594. /**
  43595. * Creates the render target textures and post processes used in the effect layer.
  43596. */
  43597. protected abstract _createTextureAndPostProcesses(): void;
  43598. /**
  43599. * Implementation specific of rendering the generating effect on the main canvas.
  43600. * @param effect The effect used to render through
  43601. */
  43602. protected abstract _internalRender(effect: Effect): void;
  43603. /**
  43604. * Sets the required values for both the emissive texture and and the main color.
  43605. */
  43606. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  43607. /**
  43608. * Free any resources and references associated to a mesh.
  43609. * Internal use
  43610. * @param mesh The mesh to free.
  43611. */
  43612. abstract _disposeMesh(mesh: Mesh): void;
  43613. /**
  43614. * Serializes this layer (Glow or Highlight for example)
  43615. * @returns a serialized layer object
  43616. */
  43617. abstract serialize?(): any;
  43618. /**
  43619. * Initializes the effect layer with the required options.
  43620. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  43621. */
  43622. protected _init(options: Partial<IEffectLayerOptions>): void;
  43623. /**
  43624. * Generates the index buffer of the full screen quad blending to the main canvas.
  43625. */
  43626. private _generateIndexBuffer;
  43627. /**
  43628. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  43629. */
  43630. private _genrateVertexBuffer;
  43631. /**
  43632. * Sets the main texture desired size which is the closest power of two
  43633. * of the engine canvas size.
  43634. */
  43635. private _setMainTextureSize;
  43636. /**
  43637. * Creates the main texture for the effect layer.
  43638. */
  43639. protected _createMainTexture(): void;
  43640. /**
  43641. * Adds specific effects defines.
  43642. * @param defines The defines to add specifics to.
  43643. */
  43644. protected _addCustomEffectDefines(defines: string[]): void;
  43645. /**
  43646. * Checks for the readiness of the element composing the layer.
  43647. * @param subMesh the mesh to check for
  43648. * @param useInstances specify wether or not to use instances to render the mesh
  43649. * @param emissiveTexture the associated emissive texture used to generate the glow
  43650. * @return true if ready otherwise, false
  43651. */
  43652. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  43653. /**
  43654. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  43655. */
  43656. render(): void;
  43657. /**
  43658. * Determine if a given mesh will be used in the current effect.
  43659. * @param mesh mesh to test
  43660. * @returns true if the mesh will be used
  43661. */
  43662. hasMesh(mesh: AbstractMesh): boolean;
  43663. /**
  43664. * Returns true if the layer contains information to display, otherwise false.
  43665. * @returns true if the glow layer should be rendered
  43666. */
  43667. shouldRender(): boolean;
  43668. /**
  43669. * Returns true if the mesh should render, otherwise false.
  43670. * @param mesh The mesh to render
  43671. * @returns true if it should render otherwise false
  43672. */
  43673. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  43674. /**
  43675. * Returns true if the mesh can be rendered, otherwise false.
  43676. * @param mesh The mesh to render
  43677. * @param material The material used on the mesh
  43678. * @returns true if it can be rendered otherwise false
  43679. */
  43680. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  43681. /**
  43682. * Returns true if the mesh should render, otherwise false.
  43683. * @param mesh The mesh to render
  43684. * @returns true if it should render otherwise false
  43685. */
  43686. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  43687. /**
  43688. * Renders the submesh passed in parameter to the generation map.
  43689. */
  43690. protected _renderSubMesh(subMesh: SubMesh): void;
  43691. /**
  43692. * Rebuild the required buffers.
  43693. * @hidden Internal use only.
  43694. */
  43695. _rebuild(): void;
  43696. /**
  43697. * Dispose only the render target textures and post process.
  43698. */
  43699. private _disposeTextureAndPostProcesses;
  43700. /**
  43701. * Dispose the highlight layer and free resources.
  43702. */
  43703. dispose(): void;
  43704. /**
  43705. * Gets the class name of the effect layer
  43706. * @returns the string with the class name of the effect layer
  43707. */
  43708. getClassName(): string;
  43709. /**
  43710. * Creates an effect layer from parsed effect layer data
  43711. * @param parsedEffectLayer defines effect layer data
  43712. * @param scene defines the current scene
  43713. * @param rootUrl defines the root URL containing the effect layer information
  43714. * @returns a parsed effect Layer
  43715. */
  43716. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  43717. }
  43718. }
  43719. declare module BABYLON {
  43720. interface AbstractScene {
  43721. /**
  43722. * The list of effect layers (highlights/glow) added to the scene
  43723. * @see http://doc.babylonjs.com/how_to/highlight_layer
  43724. * @see http://doc.babylonjs.com/how_to/glow_layer
  43725. */
  43726. effectLayers: Array<EffectLayer>;
  43727. /**
  43728. * Removes the given effect layer from this scene.
  43729. * @param toRemove defines the effect layer to remove
  43730. * @returns the index of the removed effect layer
  43731. */
  43732. removeEffectLayer(toRemove: EffectLayer): number;
  43733. /**
  43734. * Adds the given effect layer to this scene
  43735. * @param newEffectLayer defines the effect layer to add
  43736. */
  43737. addEffectLayer(newEffectLayer: EffectLayer): void;
  43738. }
  43739. /**
  43740. * Defines the layer scene component responsible to manage any effect layers
  43741. * in a given scene.
  43742. */
  43743. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  43744. /**
  43745. * The component name helpfull to identify the component in the list of scene components.
  43746. */
  43747. readonly name: string;
  43748. /**
  43749. * The scene the component belongs to.
  43750. */
  43751. scene: Scene;
  43752. private _engine;
  43753. private _renderEffects;
  43754. private _needStencil;
  43755. private _previousStencilState;
  43756. /**
  43757. * Creates a new instance of the component for the given scene
  43758. * @param scene Defines the scene to register the component in
  43759. */
  43760. constructor(scene: Scene);
  43761. /**
  43762. * Registers the component in a given scene
  43763. */
  43764. register(): void;
  43765. /**
  43766. * Rebuilds the elements related to this component in case of
  43767. * context lost for instance.
  43768. */
  43769. rebuild(): void;
  43770. /**
  43771. * Serializes the component data to the specified json object
  43772. * @param serializationObject The object to serialize to
  43773. */
  43774. serialize(serializationObject: any): void;
  43775. /**
  43776. * Adds all the element from the container to the scene
  43777. * @param container the container holding the elements
  43778. */
  43779. addFromContainer(container: AbstractScene): void;
  43780. /**
  43781. * Removes all the elements in the container from the scene
  43782. * @param container contains the elements to remove
  43783. */
  43784. removeFromContainer(container: AbstractScene): void;
  43785. /**
  43786. * Disposes the component and the associated ressources.
  43787. */
  43788. dispose(): void;
  43789. private _isReadyForMesh;
  43790. private _renderMainTexture;
  43791. private _setStencil;
  43792. private _setStencilBack;
  43793. private _draw;
  43794. private _drawCamera;
  43795. private _drawRenderingGroup;
  43796. }
  43797. }
  43798. declare module BABYLON {
  43799. /** @hidden */
  43800. export var glowMapMergePixelShader: {
  43801. name: string;
  43802. shader: string;
  43803. };
  43804. }
  43805. declare module BABYLON {
  43806. /** @hidden */
  43807. export var glowMapMergeVertexShader: {
  43808. name: string;
  43809. shader: string;
  43810. };
  43811. }
  43812. declare module BABYLON {
  43813. interface AbstractScene {
  43814. /**
  43815. * Return a the first highlight layer of the scene with a given name.
  43816. * @param name The name of the highlight layer to look for.
  43817. * @return The highlight layer if found otherwise null.
  43818. */
  43819. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  43820. }
  43821. /**
  43822. * Glow layer options. This helps customizing the behaviour
  43823. * of the glow layer.
  43824. */
  43825. export interface IGlowLayerOptions {
  43826. /**
  43827. * Multiplication factor apply to the canvas size to compute the render target size
  43828. * used to generated the glowing objects (the smaller the faster).
  43829. */
  43830. mainTextureRatio: number;
  43831. /**
  43832. * Enforces a fixed size texture to ensure resize independant blur.
  43833. */
  43834. mainTextureFixedSize?: number;
  43835. /**
  43836. * How big is the kernel of the blur texture.
  43837. */
  43838. blurKernelSize: number;
  43839. /**
  43840. * The camera attached to the layer.
  43841. */
  43842. camera: Nullable<Camera>;
  43843. /**
  43844. * Enable MSAA by chosing the number of samples.
  43845. */
  43846. mainTextureSamples?: number;
  43847. /**
  43848. * The rendering group to draw the layer in.
  43849. */
  43850. renderingGroupId: number;
  43851. }
  43852. /**
  43853. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  43854. *
  43855. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  43856. * glowy meshes to your scene.
  43857. *
  43858. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  43859. */
  43860. export class GlowLayer extends EffectLayer {
  43861. /**
  43862. * Effect Name of the layer.
  43863. */
  43864. static readonly EffectName: string;
  43865. /**
  43866. * The default blur kernel size used for the glow.
  43867. */
  43868. static DefaultBlurKernelSize: number;
  43869. /**
  43870. * The default texture size ratio used for the glow.
  43871. */
  43872. static DefaultTextureRatio: number;
  43873. /**
  43874. * Sets the kernel size of the blur.
  43875. */
  43876. /**
  43877. * Gets the kernel size of the blur.
  43878. */
  43879. blurKernelSize: number;
  43880. /**
  43881. * Sets the glow intensity.
  43882. */
  43883. /**
  43884. * Gets the glow intensity.
  43885. */
  43886. intensity: number;
  43887. private _options;
  43888. private _intensity;
  43889. private _horizontalBlurPostprocess1;
  43890. private _verticalBlurPostprocess1;
  43891. private _horizontalBlurPostprocess2;
  43892. private _verticalBlurPostprocess2;
  43893. private _blurTexture1;
  43894. private _blurTexture2;
  43895. private _postProcesses1;
  43896. private _postProcesses2;
  43897. private _includedOnlyMeshes;
  43898. private _excludedMeshes;
  43899. /**
  43900. * Callback used to let the user override the color selection on a per mesh basis
  43901. */
  43902. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  43903. /**
  43904. * Callback used to let the user override the texture selection on a per mesh basis
  43905. */
  43906. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  43907. /**
  43908. * Instantiates a new glow Layer and references it to the scene.
  43909. * @param name The name of the layer
  43910. * @param scene The scene to use the layer in
  43911. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  43912. */
  43913. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  43914. /**
  43915. * Get the effect name of the layer.
  43916. * @return The effect name
  43917. */
  43918. getEffectName(): string;
  43919. /**
  43920. * Create the merge effect. This is the shader use to blit the information back
  43921. * to the main canvas at the end of the scene rendering.
  43922. */
  43923. protected _createMergeEffect(): Effect;
  43924. /**
  43925. * Creates the render target textures and post processes used in the glow layer.
  43926. */
  43927. protected _createTextureAndPostProcesses(): void;
  43928. /**
  43929. * Checks for the readiness of the element composing the layer.
  43930. * @param subMesh the mesh to check for
  43931. * @param useInstances specify wether or not to use instances to render the mesh
  43932. * @param emissiveTexture the associated emissive texture used to generate the glow
  43933. * @return true if ready otherwise, false
  43934. */
  43935. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43936. /**
  43937. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  43938. */
  43939. needStencil(): boolean;
  43940. /**
  43941. * Returns true if the mesh can be rendered, otherwise false.
  43942. * @param mesh The mesh to render
  43943. * @param material The material used on the mesh
  43944. * @returns true if it can be rendered otherwise false
  43945. */
  43946. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  43947. /**
  43948. * Implementation specific of rendering the generating effect on the main canvas.
  43949. * @param effect The effect used to render through
  43950. */
  43951. protected _internalRender(effect: Effect): void;
  43952. /**
  43953. * Sets the required values for both the emissive texture and and the main color.
  43954. */
  43955. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  43956. /**
  43957. * Returns true if the mesh should render, otherwise false.
  43958. * @param mesh The mesh to render
  43959. * @returns true if it should render otherwise false
  43960. */
  43961. protected _shouldRenderMesh(mesh: Mesh): boolean;
  43962. /**
  43963. * Adds specific effects defines.
  43964. * @param defines The defines to add specifics to.
  43965. */
  43966. protected _addCustomEffectDefines(defines: string[]): void;
  43967. /**
  43968. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  43969. * @param mesh The mesh to exclude from the glow layer
  43970. */
  43971. addExcludedMesh(mesh: Mesh): void;
  43972. /**
  43973. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  43974. * @param mesh The mesh to remove
  43975. */
  43976. removeExcludedMesh(mesh: Mesh): void;
  43977. /**
  43978. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  43979. * @param mesh The mesh to include in the glow layer
  43980. */
  43981. addIncludedOnlyMesh(mesh: Mesh): void;
  43982. /**
  43983. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  43984. * @param mesh The mesh to remove
  43985. */
  43986. removeIncludedOnlyMesh(mesh: Mesh): void;
  43987. /**
  43988. * Determine if a given mesh will be used in the glow layer
  43989. * @param mesh The mesh to test
  43990. * @returns true if the mesh will be highlighted by the current glow layer
  43991. */
  43992. hasMesh(mesh: AbstractMesh): boolean;
  43993. /**
  43994. * Free any resources and references associated to a mesh.
  43995. * Internal use
  43996. * @param mesh The mesh to free.
  43997. * @hidden
  43998. */
  43999. _disposeMesh(mesh: Mesh): void;
  44000. /**
  44001. * Gets the class name of the effect layer
  44002. * @returns the string with the class name of the effect layer
  44003. */
  44004. getClassName(): string;
  44005. /**
  44006. * Serializes this glow layer
  44007. * @returns a serialized glow layer object
  44008. */
  44009. serialize(): any;
  44010. /**
  44011. * Creates a Glow Layer from parsed glow layer data
  44012. * @param parsedGlowLayer defines glow layer data
  44013. * @param scene defines the current scene
  44014. * @param rootUrl defines the root URL containing the glow layer information
  44015. * @returns a parsed Glow Layer
  44016. */
  44017. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  44018. }
  44019. }
  44020. declare module BABYLON {
  44021. /** @hidden */
  44022. export var glowBlurPostProcessPixelShader: {
  44023. name: string;
  44024. shader: string;
  44025. };
  44026. }
  44027. declare module BABYLON {
  44028. interface AbstractScene {
  44029. /**
  44030. * Return a the first highlight layer of the scene with a given name.
  44031. * @param name The name of the highlight layer to look for.
  44032. * @return The highlight layer if found otherwise null.
  44033. */
  44034. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  44035. }
  44036. /**
  44037. * Highlight layer options. This helps customizing the behaviour
  44038. * of the highlight layer.
  44039. */
  44040. export interface IHighlightLayerOptions {
  44041. /**
  44042. * Multiplication factor apply to the canvas size to compute the render target size
  44043. * used to generated the glowing objects (the smaller the faster).
  44044. */
  44045. mainTextureRatio: number;
  44046. /**
  44047. * Enforces a fixed size texture to ensure resize independant blur.
  44048. */
  44049. mainTextureFixedSize?: number;
  44050. /**
  44051. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  44052. * of the picture to blur (the smaller the faster).
  44053. */
  44054. blurTextureSizeRatio: number;
  44055. /**
  44056. * How big in texel of the blur texture is the vertical blur.
  44057. */
  44058. blurVerticalSize: number;
  44059. /**
  44060. * How big in texel of the blur texture is the horizontal blur.
  44061. */
  44062. blurHorizontalSize: number;
  44063. /**
  44064. * Alpha blending mode used to apply the blur. Default is combine.
  44065. */
  44066. alphaBlendingMode: number;
  44067. /**
  44068. * The camera attached to the layer.
  44069. */
  44070. camera: Nullable<Camera>;
  44071. /**
  44072. * Should we display highlight as a solid stroke?
  44073. */
  44074. isStroke?: boolean;
  44075. /**
  44076. * The rendering group to draw the layer in.
  44077. */
  44078. renderingGroupId: number;
  44079. }
  44080. /**
  44081. * The highlight layer Helps adding a glow effect around a mesh.
  44082. *
  44083. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  44084. * glowy meshes to your scene.
  44085. *
  44086. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  44087. */
  44088. export class HighlightLayer extends EffectLayer {
  44089. name: string;
  44090. /**
  44091. * Effect Name of the highlight layer.
  44092. */
  44093. static readonly EffectName: string;
  44094. /**
  44095. * The neutral color used during the preparation of the glow effect.
  44096. * This is black by default as the blend operation is a blend operation.
  44097. */
  44098. static NeutralColor: Color4;
  44099. /**
  44100. * Stencil value used for glowing meshes.
  44101. */
  44102. static GlowingMeshStencilReference: number;
  44103. /**
  44104. * Stencil value used for the other meshes in the scene.
  44105. */
  44106. static NormalMeshStencilReference: number;
  44107. /**
  44108. * Specifies whether or not the inner glow is ACTIVE in the layer.
  44109. */
  44110. innerGlow: boolean;
  44111. /**
  44112. * Specifies whether or not the outer glow is ACTIVE in the layer.
  44113. */
  44114. outerGlow: boolean;
  44115. /**
  44116. * Specifies the horizontal size of the blur.
  44117. */
  44118. /**
  44119. * Gets the horizontal size of the blur.
  44120. */
  44121. blurHorizontalSize: number;
  44122. /**
  44123. * Specifies the vertical size of the blur.
  44124. */
  44125. /**
  44126. * Gets the vertical size of the blur.
  44127. */
  44128. blurVerticalSize: number;
  44129. /**
  44130. * An event triggered when the highlight layer is being blurred.
  44131. */
  44132. onBeforeBlurObservable: Observable<HighlightLayer>;
  44133. /**
  44134. * An event triggered when the highlight layer has been blurred.
  44135. */
  44136. onAfterBlurObservable: Observable<HighlightLayer>;
  44137. private _instanceGlowingMeshStencilReference;
  44138. private _options;
  44139. private _downSamplePostprocess;
  44140. private _horizontalBlurPostprocess;
  44141. private _verticalBlurPostprocess;
  44142. private _blurTexture;
  44143. private _meshes;
  44144. private _excludedMeshes;
  44145. /**
  44146. * Instantiates a new highlight Layer and references it to the scene..
  44147. * @param name The name of the layer
  44148. * @param scene The scene to use the layer in
  44149. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  44150. */
  44151. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  44152. /**
  44153. * Get the effect name of the layer.
  44154. * @return The effect name
  44155. */
  44156. getEffectName(): string;
  44157. /**
  44158. * Create the merge effect. This is the shader use to blit the information back
  44159. * to the main canvas at the end of the scene rendering.
  44160. */
  44161. protected _createMergeEffect(): Effect;
  44162. /**
  44163. * Creates the render target textures and post processes used in the highlight layer.
  44164. */
  44165. protected _createTextureAndPostProcesses(): void;
  44166. /**
  44167. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  44168. */
  44169. needStencil(): boolean;
  44170. /**
  44171. * Checks for the readiness of the element composing the layer.
  44172. * @param subMesh the mesh to check for
  44173. * @param useInstances specify wether or not to use instances to render the mesh
  44174. * @param emissiveTexture the associated emissive texture used to generate the glow
  44175. * @return true if ready otherwise, false
  44176. */
  44177. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44178. /**
  44179. * Implementation specific of rendering the generating effect on the main canvas.
  44180. * @param effect The effect used to render through
  44181. */
  44182. protected _internalRender(effect: Effect): void;
  44183. /**
  44184. * Returns true if the layer contains information to display, otherwise false.
  44185. */
  44186. shouldRender(): boolean;
  44187. /**
  44188. * Returns true if the mesh should render, otherwise false.
  44189. * @param mesh The mesh to render
  44190. * @returns true if it should render otherwise false
  44191. */
  44192. protected _shouldRenderMesh(mesh: Mesh): boolean;
  44193. /**
  44194. * Sets the required values for both the emissive texture and and the main color.
  44195. */
  44196. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  44197. /**
  44198. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  44199. * @param mesh The mesh to exclude from the highlight layer
  44200. */
  44201. addExcludedMesh(mesh: Mesh): void;
  44202. /**
  44203. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  44204. * @param mesh The mesh to highlight
  44205. */
  44206. removeExcludedMesh(mesh: Mesh): void;
  44207. /**
  44208. * Determine if a given mesh will be highlighted by the current HighlightLayer
  44209. * @param mesh mesh to test
  44210. * @returns true if the mesh will be highlighted by the current HighlightLayer
  44211. */
  44212. hasMesh(mesh: AbstractMesh): boolean;
  44213. /**
  44214. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  44215. * @param mesh The mesh to highlight
  44216. * @param color The color of the highlight
  44217. * @param glowEmissiveOnly Extract the glow from the emissive texture
  44218. */
  44219. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  44220. /**
  44221. * Remove a mesh from the highlight layer in order to make it stop glowing.
  44222. * @param mesh The mesh to highlight
  44223. */
  44224. removeMesh(mesh: Mesh): void;
  44225. /**
  44226. * Force the stencil to the normal expected value for none glowing parts
  44227. */
  44228. private _defaultStencilReference;
  44229. /**
  44230. * Free any resources and references associated to a mesh.
  44231. * Internal use
  44232. * @param mesh The mesh to free.
  44233. * @hidden
  44234. */
  44235. _disposeMesh(mesh: Mesh): void;
  44236. /**
  44237. * Dispose the highlight layer and free resources.
  44238. */
  44239. dispose(): void;
  44240. /**
  44241. * Gets the class name of the effect layer
  44242. * @returns the string with the class name of the effect layer
  44243. */
  44244. getClassName(): string;
  44245. /**
  44246. * Serializes this Highlight layer
  44247. * @returns a serialized Highlight layer object
  44248. */
  44249. serialize(): any;
  44250. /**
  44251. * Creates a Highlight layer from parsed Highlight layer data
  44252. * @param parsedHightlightLayer defines the Highlight layer data
  44253. * @param scene defines the current scene
  44254. * @param rootUrl defines the root URL containing the Highlight layer information
  44255. * @returns a parsed Highlight layer
  44256. */
  44257. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  44258. }
  44259. }
  44260. declare module BABYLON {
  44261. /** @hidden */
  44262. export var lensFlarePixelShader: {
  44263. name: string;
  44264. shader: string;
  44265. };
  44266. }
  44267. declare module BABYLON {
  44268. /** @hidden */
  44269. export var lensFlareVertexShader: {
  44270. name: string;
  44271. shader: string;
  44272. };
  44273. }
  44274. declare module BABYLON {
  44275. /**
  44276. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44277. * It is usually composed of several `lensFlare`.
  44278. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44279. */
  44280. export class LensFlareSystem {
  44281. /**
  44282. * Define the name of the lens flare system
  44283. */
  44284. name: string;
  44285. /**
  44286. * List of lens flares used in this system.
  44287. */
  44288. lensFlares: LensFlare[];
  44289. /**
  44290. * Define a limit from the border the lens flare can be visible.
  44291. */
  44292. borderLimit: number;
  44293. /**
  44294. * Define a viewport border we do not want to see the lens flare in.
  44295. */
  44296. viewportBorder: number;
  44297. /**
  44298. * Define a predicate which could limit the list of meshes able to occlude the effect.
  44299. */
  44300. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  44301. /**
  44302. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  44303. */
  44304. layerMask: number;
  44305. /**
  44306. * Define the id of the lens flare system in the scene.
  44307. * (equal to name by default)
  44308. */
  44309. id: string;
  44310. private _scene;
  44311. private _emitter;
  44312. private _vertexBuffers;
  44313. private _indexBuffer;
  44314. private _effect;
  44315. private _positionX;
  44316. private _positionY;
  44317. private _isEnabled;
  44318. /** @hidden */
  44319. static _SceneComponentInitialization: (scene: Scene) => void;
  44320. /**
  44321. * Instantiates a lens flare system.
  44322. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44323. * It is usually composed of several `lensFlare`.
  44324. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44325. * @param name Define the name of the lens flare system in the scene
  44326. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  44327. * @param scene Define the scene the lens flare system belongs to
  44328. */
  44329. constructor(
  44330. /**
  44331. * Define the name of the lens flare system
  44332. */
  44333. name: string, emitter: any, scene: Scene);
  44334. /**
  44335. * Define if the lens flare system is enabled.
  44336. */
  44337. isEnabled: boolean;
  44338. /**
  44339. * Get the scene the effects belongs to.
  44340. * @returns the scene holding the lens flare system
  44341. */
  44342. getScene(): Scene;
  44343. /**
  44344. * Get the emitter of the lens flare system.
  44345. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  44346. * @returns the emitter of the lens flare system
  44347. */
  44348. getEmitter(): any;
  44349. /**
  44350. * Set the emitter of the lens flare system.
  44351. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  44352. * @param newEmitter Define the new emitter of the system
  44353. */
  44354. setEmitter(newEmitter: any): void;
  44355. /**
  44356. * Get the lens flare system emitter position.
  44357. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  44358. * @returns the position
  44359. */
  44360. getEmitterPosition(): Vector3;
  44361. /**
  44362. * @hidden
  44363. */
  44364. computeEffectivePosition(globalViewport: Viewport): boolean;
  44365. /** @hidden */
  44366. _isVisible(): boolean;
  44367. /**
  44368. * @hidden
  44369. */
  44370. render(): boolean;
  44371. /**
  44372. * Dispose and release the lens flare with its associated resources.
  44373. */
  44374. dispose(): void;
  44375. /**
  44376. * Parse a lens flare system from a JSON repressentation
  44377. * @param parsedLensFlareSystem Define the JSON to parse
  44378. * @param scene Define the scene the parsed system should be instantiated in
  44379. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  44380. * @returns the parsed system
  44381. */
  44382. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  44383. /**
  44384. * Serialize the current Lens Flare System into a JSON representation.
  44385. * @returns the serialized JSON
  44386. */
  44387. serialize(): any;
  44388. }
  44389. }
  44390. declare module BABYLON {
  44391. /**
  44392. * This represents one of the lens effect in a `lensFlareSystem`.
  44393. * It controls one of the indiviual texture used in the effect.
  44394. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44395. */
  44396. export class LensFlare {
  44397. /**
  44398. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  44399. */
  44400. size: number;
  44401. /**
  44402. * 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.
  44403. */
  44404. position: number;
  44405. /**
  44406. * Define the lens color.
  44407. */
  44408. color: Color3;
  44409. /**
  44410. * Define the lens texture.
  44411. */
  44412. texture: Nullable<Texture>;
  44413. /**
  44414. * Define the alpha mode to render this particular lens.
  44415. */
  44416. alphaMode: number;
  44417. private _system;
  44418. /**
  44419. * Creates a new Lens Flare.
  44420. * This represents one of the lens effect in a `lensFlareSystem`.
  44421. * It controls one of the indiviual texture used in the effect.
  44422. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44423. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  44424. * @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.
  44425. * @param color Define the lens color
  44426. * @param imgUrl Define the lens texture url
  44427. * @param system Define the `lensFlareSystem` this flare is part of
  44428. * @returns The newly created Lens Flare
  44429. */
  44430. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  44431. /**
  44432. * Instantiates a new Lens Flare.
  44433. * This represents one of the lens effect in a `lensFlareSystem`.
  44434. * It controls one of the indiviual texture used in the effect.
  44435. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44436. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  44437. * @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.
  44438. * @param color Define the lens color
  44439. * @param imgUrl Define the lens texture url
  44440. * @param system Define the `lensFlareSystem` this flare is part of
  44441. */
  44442. constructor(
  44443. /**
  44444. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  44445. */
  44446. size: number,
  44447. /**
  44448. * 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.
  44449. */
  44450. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  44451. /**
  44452. * Dispose and release the lens flare with its associated resources.
  44453. */
  44454. dispose(): void;
  44455. }
  44456. }
  44457. declare module BABYLON {
  44458. interface AbstractScene {
  44459. /**
  44460. * The list of lens flare system added to the scene
  44461. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44462. */
  44463. lensFlareSystems: Array<LensFlareSystem>;
  44464. /**
  44465. * Removes the given lens flare system from this scene.
  44466. * @param toRemove The lens flare system to remove
  44467. * @returns The index of the removed lens flare system
  44468. */
  44469. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  44470. /**
  44471. * Adds the given lens flare system to this scene
  44472. * @param newLensFlareSystem The lens flare system to add
  44473. */
  44474. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  44475. /**
  44476. * Gets a lens flare system using its name
  44477. * @param name defines the name to look for
  44478. * @returns the lens flare system or null if not found
  44479. */
  44480. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  44481. /**
  44482. * Gets a lens flare system using its id
  44483. * @param id defines the id to look for
  44484. * @returns the lens flare system or null if not found
  44485. */
  44486. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  44487. }
  44488. /**
  44489. * Defines the lens flare scene component responsible to manage any lens flares
  44490. * in a given scene.
  44491. */
  44492. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  44493. /**
  44494. * The component name helpfull to identify the component in the list of scene components.
  44495. */
  44496. readonly name: string;
  44497. /**
  44498. * The scene the component belongs to.
  44499. */
  44500. scene: Scene;
  44501. /**
  44502. * Creates a new instance of the component for the given scene
  44503. * @param scene Defines the scene to register the component in
  44504. */
  44505. constructor(scene: Scene);
  44506. /**
  44507. * Registers the component in a given scene
  44508. */
  44509. register(): void;
  44510. /**
  44511. * Rebuilds the elements related to this component in case of
  44512. * context lost for instance.
  44513. */
  44514. rebuild(): void;
  44515. /**
  44516. * Adds all the element from the container to the scene
  44517. * @param container the container holding the elements
  44518. */
  44519. addFromContainer(container: AbstractScene): void;
  44520. /**
  44521. * Removes all the elements in the container from the scene
  44522. * @param container contains the elements to remove
  44523. */
  44524. removeFromContainer(container: AbstractScene): void;
  44525. /**
  44526. * Serializes the component data to the specified json object
  44527. * @param serializationObject The object to serialize to
  44528. */
  44529. serialize(serializationObject: any): void;
  44530. /**
  44531. * Disposes the component and the associated ressources.
  44532. */
  44533. dispose(): void;
  44534. private _draw;
  44535. }
  44536. }
  44537. declare module BABYLON {
  44538. /**
  44539. * Defines the shadow generator component responsible to manage any shadow generators
  44540. * in a given scene.
  44541. */
  44542. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  44543. /**
  44544. * The component name helpfull to identify the component in the list of scene components.
  44545. */
  44546. readonly name: string;
  44547. /**
  44548. * The scene the component belongs to.
  44549. */
  44550. scene: Scene;
  44551. /**
  44552. * Creates a new instance of the component for the given scene
  44553. * @param scene Defines the scene to register the component in
  44554. */
  44555. constructor(scene: Scene);
  44556. /**
  44557. * Registers the component in a given scene
  44558. */
  44559. register(): void;
  44560. /**
  44561. * Rebuilds the elements related to this component in case of
  44562. * context lost for instance.
  44563. */
  44564. rebuild(): void;
  44565. /**
  44566. * Serializes the component data to the specified json object
  44567. * @param serializationObject The object to serialize to
  44568. */
  44569. serialize(serializationObject: any): void;
  44570. /**
  44571. * Adds all the element from the container to the scene
  44572. * @param container the container holding the elements
  44573. */
  44574. addFromContainer(container: AbstractScene): void;
  44575. /**
  44576. * Removes all the elements in the container from the scene
  44577. * @param container contains the elements to remove
  44578. */
  44579. removeFromContainer(container: AbstractScene): void;
  44580. /**
  44581. * Rebuilds the elements related to this component in case of
  44582. * context lost for instance.
  44583. */
  44584. dispose(): void;
  44585. private _gatherRenderTargets;
  44586. }
  44587. }
  44588. declare module BABYLON {
  44589. /**
  44590. * A directional light is defined by a direction (what a surprise!).
  44591. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44592. * 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.
  44593. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44594. */
  44595. export class DirectionalLight extends ShadowLight {
  44596. private _shadowFrustumSize;
  44597. /**
  44598. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44599. */
  44600. /**
  44601. * Specifies a fix frustum size for the shadow generation.
  44602. */
  44603. shadowFrustumSize: number;
  44604. private _shadowOrthoScale;
  44605. /**
  44606. * Gets the shadow projection scale against the optimal computed one.
  44607. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44608. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44609. */
  44610. /**
  44611. * Sets the shadow projection scale against the optimal computed one.
  44612. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44613. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44614. */
  44615. shadowOrthoScale: number;
  44616. /**
  44617. * Automatically compute the projection matrix to best fit (including all the casters)
  44618. * on each frame.
  44619. */
  44620. autoUpdateExtends: boolean;
  44621. private _orthoLeft;
  44622. private _orthoRight;
  44623. private _orthoTop;
  44624. private _orthoBottom;
  44625. /**
  44626. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44627. * The directional light is emitted from everywhere in the given direction.
  44628. * It can cast shadows.
  44629. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44630. * @param name The friendly name of the light
  44631. * @param direction The direction of the light
  44632. * @param scene The scene the light belongs to
  44633. */
  44634. constructor(name: string, direction: Vector3, scene: Scene);
  44635. /**
  44636. * Returns the string "DirectionalLight".
  44637. * @return The class name
  44638. */
  44639. getClassName(): string;
  44640. /**
  44641. * Returns the integer 1.
  44642. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44643. */
  44644. getTypeID(): number;
  44645. /**
  44646. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44647. * Returns the DirectionalLight Shadow projection matrix.
  44648. */
  44649. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44650. /**
  44651. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44652. * Returns the DirectionalLight Shadow projection matrix.
  44653. */
  44654. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44655. /**
  44656. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44657. * Returns the DirectionalLight Shadow projection matrix.
  44658. */
  44659. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44660. protected _buildUniformLayout(): void;
  44661. /**
  44662. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44663. * @param effect The effect to update
  44664. * @param lightIndex The index of the light in the effect to update
  44665. * @returns The directional light
  44666. */
  44667. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44668. /**
  44669. * Gets the minZ used for shadow according to both the scene and the light.
  44670. *
  44671. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44672. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44673. * @param activeCamera The camera we are returning the min for
  44674. * @returns the depth min z
  44675. */
  44676. getDepthMinZ(activeCamera: Camera): number;
  44677. /**
  44678. * Gets the maxZ used for shadow according to both the scene and the light.
  44679. *
  44680. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44681. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44682. * @param activeCamera The camera we are returning the max for
  44683. * @returns the depth max z
  44684. */
  44685. getDepthMaxZ(activeCamera: Camera): number;
  44686. /**
  44687. * Prepares the list of defines specific to the light type.
  44688. * @param defines the list of defines
  44689. * @param lightIndex defines the index of the light for the effect
  44690. */
  44691. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44692. }
  44693. }
  44694. declare module BABYLON {
  44695. /**
  44696. * A point light is a light defined by an unique point in world space.
  44697. * The light is emitted in every direction from this point.
  44698. * A good example of a point light is a standard light bulb.
  44699. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44700. */
  44701. export class PointLight extends ShadowLight {
  44702. private _shadowAngle;
  44703. /**
  44704. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  44705. * This specifies what angle the shadow will use to be created.
  44706. *
  44707. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  44708. */
  44709. /**
  44710. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  44711. * This specifies what angle the shadow will use to be created.
  44712. *
  44713. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  44714. */
  44715. shadowAngle: number;
  44716. /**
  44717. * Gets the direction if it has been set.
  44718. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  44719. */
  44720. /**
  44721. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  44722. */
  44723. direction: Vector3;
  44724. /**
  44725. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  44726. * A PointLight emits the light in every direction.
  44727. * It can cast shadows.
  44728. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  44729. * ```javascript
  44730. * var pointLight = new PointLight("pl", camera.position, scene);
  44731. * ```
  44732. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44733. * @param name The light friendly name
  44734. * @param position The position of the point light in the scene
  44735. * @param scene The scene the lights belongs to
  44736. */
  44737. constructor(name: string, position: Vector3, scene: Scene);
  44738. /**
  44739. * Returns the string "PointLight"
  44740. * @returns the class name
  44741. */
  44742. getClassName(): string;
  44743. /**
  44744. * Returns the integer 0.
  44745. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44746. */
  44747. getTypeID(): number;
  44748. /**
  44749. * Specifies wether or not the shadowmap should be a cube texture.
  44750. * @returns true if the shadowmap needs to be a cube texture.
  44751. */
  44752. needCube(): boolean;
  44753. /**
  44754. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  44755. * @param faceIndex The index of the face we are computed the direction to generate shadow
  44756. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  44757. */
  44758. getShadowDirection(faceIndex?: number): Vector3;
  44759. /**
  44760. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  44761. * - fov = PI / 2
  44762. * - aspect ratio : 1.0
  44763. * - z-near and far equal to the active camera minZ and maxZ.
  44764. * Returns the PointLight.
  44765. */
  44766. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44767. protected _buildUniformLayout(): void;
  44768. /**
  44769. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  44770. * @param effect The effect to update
  44771. * @param lightIndex The index of the light in the effect to update
  44772. * @returns The point light
  44773. */
  44774. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  44775. /**
  44776. * Prepares the list of defines specific to the light type.
  44777. * @param defines the list of defines
  44778. * @param lightIndex defines the index of the light for the effect
  44779. */
  44780. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44781. }
  44782. }
  44783. declare module BABYLON {
  44784. /**
  44785. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44786. * These values define a cone of light starting from the position, emitting toward the direction.
  44787. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44788. * and the exponent defines the speed of the decay of the light with distance (reach).
  44789. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44790. */
  44791. export class SpotLight extends ShadowLight {
  44792. private _angle;
  44793. private _innerAngle;
  44794. private _cosHalfAngle;
  44795. private _lightAngleScale;
  44796. private _lightAngleOffset;
  44797. /**
  44798. * Gets the cone angle of the spot light in Radians.
  44799. */
  44800. /**
  44801. * Sets the cone angle of the spot light in Radians.
  44802. */
  44803. angle: number;
  44804. /**
  44805. * Only used in gltf falloff mode, this defines the angle where
  44806. * the directional falloff will start before cutting at angle which could be seen
  44807. * as outer angle.
  44808. */
  44809. /**
  44810. * Only used in gltf falloff mode, this defines the angle where
  44811. * the directional falloff will start before cutting at angle which could be seen
  44812. * as outer angle.
  44813. */
  44814. innerAngle: number;
  44815. private _shadowAngleScale;
  44816. /**
  44817. * Allows scaling the angle of the light for shadow generation only.
  44818. */
  44819. /**
  44820. * Allows scaling the angle of the light for shadow generation only.
  44821. */
  44822. shadowAngleScale: number;
  44823. /**
  44824. * The light decay speed with the distance from the emission spot.
  44825. */
  44826. exponent: number;
  44827. private _projectionTextureMatrix;
  44828. /**
  44829. * Allows reading the projecton texture
  44830. */
  44831. readonly projectionTextureMatrix: Matrix;
  44832. protected _projectionTextureLightNear: number;
  44833. /**
  44834. * Gets the near clip of the Spotlight for texture projection.
  44835. */
  44836. /**
  44837. * Sets the near clip of the Spotlight for texture projection.
  44838. */
  44839. projectionTextureLightNear: number;
  44840. protected _projectionTextureLightFar: number;
  44841. /**
  44842. * Gets the far clip of the Spotlight for texture projection.
  44843. */
  44844. /**
  44845. * Sets the far clip of the Spotlight for texture projection.
  44846. */
  44847. projectionTextureLightFar: number;
  44848. protected _projectionTextureUpDirection: Vector3;
  44849. /**
  44850. * Gets the Up vector of the Spotlight for texture projection.
  44851. */
  44852. /**
  44853. * Sets the Up vector of the Spotlight for texture projection.
  44854. */
  44855. projectionTextureUpDirection: Vector3;
  44856. private _projectionTexture;
  44857. /**
  44858. * Gets the projection texture of the light.
  44859. */
  44860. /**
  44861. * Sets the projection texture of the light.
  44862. */
  44863. projectionTexture: Nullable<BaseTexture>;
  44864. private _projectionTextureViewLightDirty;
  44865. private _projectionTextureProjectionLightDirty;
  44866. private _projectionTextureDirty;
  44867. private _projectionTextureViewTargetVector;
  44868. private _projectionTextureViewLightMatrix;
  44869. private _projectionTextureProjectionLightMatrix;
  44870. private _projectionTextureScalingMatrix;
  44871. /**
  44872. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44873. * It can cast shadows.
  44874. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44875. * @param name The light friendly name
  44876. * @param position The position of the spot light in the scene
  44877. * @param direction The direction of the light in the scene
  44878. * @param angle The cone angle of the light in Radians
  44879. * @param exponent The light decay speed with the distance from the emission spot
  44880. * @param scene The scene the lights belongs to
  44881. */
  44882. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44883. /**
  44884. * Returns the string "SpotLight".
  44885. * @returns the class name
  44886. */
  44887. getClassName(): string;
  44888. /**
  44889. * Returns the integer 2.
  44890. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44891. */
  44892. getTypeID(): number;
  44893. /**
  44894. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44895. */
  44896. protected _setDirection(value: Vector3): void;
  44897. /**
  44898. * Overrides the position setter to recompute the projection texture view light Matrix.
  44899. */
  44900. protected _setPosition(value: Vector3): void;
  44901. /**
  44902. * 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.
  44903. * Returns the SpotLight.
  44904. */
  44905. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44906. protected _computeProjectionTextureViewLightMatrix(): void;
  44907. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44908. /**
  44909. * Main function for light texture projection matrix computing.
  44910. */
  44911. protected _computeProjectionTextureMatrix(): void;
  44912. protected _buildUniformLayout(): void;
  44913. private _computeAngleValues;
  44914. /**
  44915. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44916. * @param effect The effect to update
  44917. * @param lightIndex The index of the light in the effect to update
  44918. * @returns The spot light
  44919. */
  44920. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44921. /**
  44922. * Disposes the light and the associated resources.
  44923. */
  44924. dispose(): void;
  44925. /**
  44926. * Prepares the list of defines specific to the light type.
  44927. * @param defines the list of defines
  44928. * @param lightIndex defines the index of the light for the effect
  44929. */
  44930. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44931. }
  44932. }
  44933. declare module BABYLON {
  44934. /**
  44935. * Header information of HDR texture files.
  44936. */
  44937. export interface HDRInfo {
  44938. /**
  44939. * The height of the texture in pixels.
  44940. */
  44941. height: number;
  44942. /**
  44943. * The width of the texture in pixels.
  44944. */
  44945. width: number;
  44946. /**
  44947. * The index of the beginning of the data in the binary file.
  44948. */
  44949. dataPosition: number;
  44950. }
  44951. /**
  44952. * This groups tools to convert HDR texture to native colors array.
  44953. */
  44954. export class HDRTools {
  44955. private static Ldexp;
  44956. private static Rgbe2float;
  44957. private static readStringLine;
  44958. /**
  44959. * Reads header information from an RGBE texture stored in a native array.
  44960. * More information on this format are available here:
  44961. * https://en.wikipedia.org/wiki/RGBE_image_format
  44962. *
  44963. * @param uint8array The binary file stored in native array.
  44964. * @return The header information.
  44965. */
  44966. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  44967. /**
  44968. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  44969. * This RGBE texture needs to store the information as a panorama.
  44970. *
  44971. * More information on this format are available here:
  44972. * https://en.wikipedia.org/wiki/RGBE_image_format
  44973. *
  44974. * @param buffer The binary file stored in an array buffer.
  44975. * @param size The expected size of the extracted cubemap.
  44976. * @return The Cube Map information.
  44977. */
  44978. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  44979. /**
  44980. * Returns the pixels data extracted from an RGBE texture.
  44981. * This pixels will be stored left to right up to down in the R G B order in one array.
  44982. *
  44983. * More information on this format are available here:
  44984. * https://en.wikipedia.org/wiki/RGBE_image_format
  44985. *
  44986. * @param uint8array The binary file stored in an array buffer.
  44987. * @param hdrInfo The header information of the file.
  44988. * @return The pixels data in RGB right to left up to down order.
  44989. */
  44990. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  44991. private static RGBE_ReadPixels_RLE;
  44992. }
  44993. }
  44994. declare module BABYLON {
  44995. /**
  44996. * This represents a texture coming from an HDR input.
  44997. *
  44998. * The only supported format is currently panorama picture stored in RGBE format.
  44999. * Example of such files can be found on HDRLib: http://hdrlib.com/
  45000. */
  45001. export class HDRCubeTexture extends BaseTexture {
  45002. private static _facesMapping;
  45003. private _generateHarmonics;
  45004. private _noMipmap;
  45005. private _textureMatrix;
  45006. private _size;
  45007. private _onLoad;
  45008. private _onError;
  45009. /**
  45010. * The texture URL.
  45011. */
  45012. url: string;
  45013. /**
  45014. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  45015. */
  45016. coordinatesMode: number;
  45017. protected _isBlocking: boolean;
  45018. /**
  45019. * Sets wether or not the texture is blocking during loading.
  45020. */
  45021. /**
  45022. * Gets wether or not the texture is blocking during loading.
  45023. */
  45024. isBlocking: boolean;
  45025. protected _rotationY: number;
  45026. /**
  45027. * Sets texture matrix rotation angle around Y axis in radians.
  45028. */
  45029. /**
  45030. * Gets texture matrix rotation angle around Y axis radians.
  45031. */
  45032. rotationY: number;
  45033. /**
  45034. * Gets or sets the center of the bounding box associated with the cube texture
  45035. * It must define where the camera used to render the texture was set
  45036. */
  45037. boundingBoxPosition: Vector3;
  45038. private _boundingBoxSize;
  45039. /**
  45040. * Gets or sets the size of the bounding box associated with the cube texture
  45041. * When defined, the cubemap will switch to local mode
  45042. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  45043. * @example https://www.babylonjs-playground.com/#RNASML
  45044. */
  45045. boundingBoxSize: Vector3;
  45046. /**
  45047. * Instantiates an HDRTexture from the following parameters.
  45048. *
  45049. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  45050. * @param scene The scene the texture will be used in
  45051. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  45052. * @param noMipmap Forces to not generate the mipmap if true
  45053. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  45054. * @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)
  45055. * @param reserved Reserved flag for internal use.
  45056. */
  45057. 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>);
  45058. /**
  45059. * Get the current class name of the texture useful for serialization or dynamic coding.
  45060. * @returns "HDRCubeTexture"
  45061. */
  45062. getClassName(): string;
  45063. /**
  45064. * Occurs when the file is raw .hdr file.
  45065. */
  45066. private loadTexture;
  45067. clone(): HDRCubeTexture;
  45068. delayLoad(): void;
  45069. /**
  45070. * Get the texture reflection matrix used to rotate/transform the reflection.
  45071. * @returns the reflection matrix
  45072. */
  45073. getReflectionTextureMatrix(): Matrix;
  45074. /**
  45075. * Set the texture reflection matrix used to rotate/transform the reflection.
  45076. * @param value Define the reflection matrix to set
  45077. */
  45078. setReflectionTextureMatrix(value: Matrix): void;
  45079. /**
  45080. * Parses a JSON representation of an HDR Texture in order to create the texture
  45081. * @param parsedTexture Define the JSON representation
  45082. * @param scene Define the scene the texture should be created in
  45083. * @param rootUrl Define the root url in case we need to load relative dependencies
  45084. * @returns the newly created texture after parsing
  45085. */
  45086. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  45087. serialize(): any;
  45088. }
  45089. }
  45090. declare module BABYLON {
  45091. /**
  45092. * Class used to control physics engine
  45093. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  45094. */
  45095. export class PhysicsEngine implements IPhysicsEngine {
  45096. private _physicsPlugin;
  45097. /**
  45098. * Global value used to control the smallest number supported by the simulation
  45099. */
  45100. static Epsilon: number;
  45101. private _impostors;
  45102. private _joints;
  45103. /**
  45104. * Gets the gravity vector used by the simulation
  45105. */
  45106. gravity: Vector3;
  45107. /**
  45108. * Factory used to create the default physics plugin.
  45109. * @returns The default physics plugin
  45110. */
  45111. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  45112. /**
  45113. * Creates a new Physics Engine
  45114. * @param gravity defines the gravity vector used by the simulation
  45115. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  45116. */
  45117. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  45118. /**
  45119. * Sets the gravity vector used by the simulation
  45120. * @param gravity defines the gravity vector to use
  45121. */
  45122. setGravity(gravity: Vector3): void;
  45123. /**
  45124. * Set the time step of the physics engine.
  45125. * Default is 1/60.
  45126. * To slow it down, enter 1/600 for example.
  45127. * To speed it up, 1/30
  45128. * @param newTimeStep defines the new timestep to apply to this world.
  45129. */
  45130. setTimeStep(newTimeStep?: number): void;
  45131. /**
  45132. * Get the time step of the physics engine.
  45133. * @returns the current time step
  45134. */
  45135. getTimeStep(): number;
  45136. /**
  45137. * Release all resources
  45138. */
  45139. dispose(): void;
  45140. /**
  45141. * Gets the name of the current physics plugin
  45142. * @returns the name of the plugin
  45143. */
  45144. getPhysicsPluginName(): string;
  45145. /**
  45146. * Adding a new impostor for the impostor tracking.
  45147. * This will be done by the impostor itself.
  45148. * @param impostor the impostor to add
  45149. */
  45150. addImpostor(impostor: PhysicsImpostor): void;
  45151. /**
  45152. * Remove an impostor from the engine.
  45153. * This impostor and its mesh will not longer be updated by the physics engine.
  45154. * @param impostor the impostor to remove
  45155. */
  45156. removeImpostor(impostor: PhysicsImpostor): void;
  45157. /**
  45158. * Add a joint to the physics engine
  45159. * @param mainImpostor defines the main impostor to which the joint is added.
  45160. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  45161. * @param joint defines the joint that will connect both impostors.
  45162. */
  45163. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  45164. /**
  45165. * Removes a joint from the simulation
  45166. * @param mainImpostor defines the impostor used with the joint
  45167. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  45168. * @param joint defines the joint to remove
  45169. */
  45170. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  45171. /**
  45172. * Called by the scene. No need to call it.
  45173. * @param delta defines the timespam between frames
  45174. */
  45175. _step(delta: number): void;
  45176. /**
  45177. * Gets the current plugin used to run the simulation
  45178. * @returns current plugin
  45179. */
  45180. getPhysicsPlugin(): IPhysicsEnginePlugin;
  45181. /**
  45182. * Gets the list of physic impostors
  45183. * @returns an array of PhysicsImpostor
  45184. */
  45185. getImpostors(): Array<PhysicsImpostor>;
  45186. /**
  45187. * Gets the impostor for a physics enabled object
  45188. * @param object defines the object impersonated by the impostor
  45189. * @returns the PhysicsImpostor or null if not found
  45190. */
  45191. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  45192. /**
  45193. * Gets the impostor for a physics body object
  45194. * @param body defines physics body used by the impostor
  45195. * @returns the PhysicsImpostor or null if not found
  45196. */
  45197. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  45198. }
  45199. }
  45200. declare module BABYLON {
  45201. /** @hidden */
  45202. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  45203. private _useDeltaForWorldStep;
  45204. world: any;
  45205. name: string;
  45206. private _physicsMaterials;
  45207. private _fixedTimeStep;
  45208. BJSCANNON: any;
  45209. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  45210. setGravity(gravity: Vector3): void;
  45211. setTimeStep(timeStep: number): void;
  45212. getTimeStep(): number;
  45213. executeStep(delta: number): void;
  45214. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  45215. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  45216. generatePhysicsBody(impostor: PhysicsImpostor): void;
  45217. private _processChildMeshes;
  45218. removePhysicsBody(impostor: PhysicsImpostor): void;
  45219. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  45220. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  45221. private _addMaterial;
  45222. private _checkWithEpsilon;
  45223. private _createShape;
  45224. private _createHeightmap;
  45225. private _minus90X;
  45226. private _plus90X;
  45227. private _tmpPosition;
  45228. private _tmpDeltaPosition;
  45229. private _tmpUnityRotation;
  45230. private _updatePhysicsBodyTransformation;
  45231. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  45232. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  45233. isSupported(): boolean;
  45234. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  45235. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  45236. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  45237. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  45238. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  45239. getBodyMass(impostor: PhysicsImpostor): number;
  45240. getBodyFriction(impostor: PhysicsImpostor): number;
  45241. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  45242. getBodyRestitution(impostor: PhysicsImpostor): number;
  45243. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  45244. sleepBody(impostor: PhysicsImpostor): void;
  45245. wakeUpBody(impostor: PhysicsImpostor): void;
  45246. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  45247. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  45248. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  45249. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  45250. getRadius(impostor: PhysicsImpostor): number;
  45251. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  45252. dispose(): void;
  45253. private _extendNamespace;
  45254. }
  45255. }
  45256. declare module BABYLON {
  45257. /** @hidden */
  45258. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  45259. world: any;
  45260. name: string;
  45261. BJSOIMO: any;
  45262. constructor(iterations?: number, oimoInjection?: any);
  45263. setGravity(gravity: Vector3): void;
  45264. setTimeStep(timeStep: number): void;
  45265. getTimeStep(): number;
  45266. private _tmpImpostorsArray;
  45267. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  45268. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  45269. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  45270. generatePhysicsBody(impostor: PhysicsImpostor): void;
  45271. private _tmpPositionVector;
  45272. removePhysicsBody(impostor: PhysicsImpostor): void;
  45273. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  45274. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  45275. isSupported(): boolean;
  45276. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  45277. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  45278. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  45279. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  45280. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  45281. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  45282. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  45283. getBodyMass(impostor: PhysicsImpostor): number;
  45284. getBodyFriction(impostor: PhysicsImpostor): number;
  45285. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  45286. getBodyRestitution(impostor: PhysicsImpostor): number;
  45287. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  45288. sleepBody(impostor: PhysicsImpostor): void;
  45289. wakeUpBody(impostor: PhysicsImpostor): void;
  45290. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  45291. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  45292. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  45293. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  45294. getRadius(impostor: PhysicsImpostor): number;
  45295. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  45296. dispose(): void;
  45297. }
  45298. }
  45299. declare module BABYLON {
  45300. interface AbstractScene {
  45301. /**
  45302. * The list of reflection probes added to the scene
  45303. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  45304. */
  45305. reflectionProbes: Array<ReflectionProbe>;
  45306. /**
  45307. * Removes the given reflection probe from this scene.
  45308. * @param toRemove The reflection probe to remove
  45309. * @returns The index of the removed reflection probe
  45310. */
  45311. removeReflectionProbe(toRemove: ReflectionProbe): number;
  45312. /**
  45313. * Adds the given reflection probe to this scene.
  45314. * @param newReflectionProbe The reflection probe to add
  45315. */
  45316. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  45317. }
  45318. /**
  45319. * Class used to generate realtime reflection / refraction cube textures
  45320. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  45321. */
  45322. export class ReflectionProbe {
  45323. /** defines the name of the probe */
  45324. name: string;
  45325. private _scene;
  45326. private _renderTargetTexture;
  45327. private _projectionMatrix;
  45328. private _viewMatrix;
  45329. private _target;
  45330. private _add;
  45331. private _attachedMesh;
  45332. private _invertYAxis;
  45333. /** Gets or sets probe position (center of the cube map) */
  45334. position: Vector3;
  45335. /**
  45336. * Creates a new reflection probe
  45337. * @param name defines the name of the probe
  45338. * @param size defines the texture resolution (for each face)
  45339. * @param scene defines the hosting scene
  45340. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  45341. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  45342. */
  45343. constructor(
  45344. /** defines the name of the probe */
  45345. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  45346. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  45347. samples: number;
  45348. /** Gets or sets the refresh rate to use (on every frame by default) */
  45349. refreshRate: number;
  45350. /**
  45351. * Gets the hosting scene
  45352. * @returns a Scene
  45353. */
  45354. getScene(): Scene;
  45355. /** Gets the internal CubeTexture used to render to */
  45356. readonly cubeTexture: RenderTargetTexture;
  45357. /** Gets the list of meshes to render */
  45358. readonly renderList: Nullable<AbstractMesh[]>;
  45359. /**
  45360. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  45361. * @param mesh defines the mesh to attach to
  45362. */
  45363. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45364. /**
  45365. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  45366. * @param renderingGroupId The rendering group id corresponding to its index
  45367. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  45368. */
  45369. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  45370. /**
  45371. * Clean all associated resources
  45372. */
  45373. dispose(): void;
  45374. /**
  45375. * Converts the reflection probe information to a readable string for debug purpose.
  45376. * @param fullDetails Supports for multiple levels of logging within scene loading
  45377. * @returns the human readable reflection probe info
  45378. */
  45379. toString(fullDetails?: boolean): string;
  45380. /**
  45381. * Get the class name of the relfection probe.
  45382. * @returns "ReflectionProbe"
  45383. */
  45384. getClassName(): string;
  45385. /**
  45386. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  45387. * @returns The JSON representation of the texture
  45388. */
  45389. serialize(): any;
  45390. /**
  45391. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  45392. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  45393. * @param scene Define the scene the parsed reflection probe should be instantiated in
  45394. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  45395. * @returns The parsed reflection probe if successful
  45396. */
  45397. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  45398. }
  45399. }
  45400. declare module BABYLON {
  45401. /** @hidden */
  45402. export var _BabylonLoaderRegistered: boolean;
  45403. }
  45404. declare module BABYLON {
  45405. /**
  45406. * The Physically based simple base material of BJS.
  45407. *
  45408. * This enables better naming and convention enforcements on top of the pbrMaterial.
  45409. * It is used as the base class for both the specGloss and metalRough conventions.
  45410. */
  45411. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  45412. /**
  45413. * Number of Simultaneous lights allowed on the material.
  45414. */
  45415. maxSimultaneousLights: number;
  45416. /**
  45417. * If sets to true, disables all the lights affecting the material.
  45418. */
  45419. disableLighting: boolean;
  45420. /**
  45421. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  45422. */
  45423. environmentTexture: BaseTexture;
  45424. /**
  45425. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45426. */
  45427. invertNormalMapX: boolean;
  45428. /**
  45429. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45430. */
  45431. invertNormalMapY: boolean;
  45432. /**
  45433. * Normal map used in the model.
  45434. */
  45435. normalTexture: BaseTexture;
  45436. /**
  45437. * Emissivie color used to self-illuminate the model.
  45438. */
  45439. emissiveColor: Color3;
  45440. /**
  45441. * Emissivie texture used to self-illuminate the model.
  45442. */
  45443. emissiveTexture: BaseTexture;
  45444. /**
  45445. * Occlusion Channel Strenght.
  45446. */
  45447. occlusionStrength: number;
  45448. /**
  45449. * Occlusion Texture of the material (adding extra occlusion effects).
  45450. */
  45451. occlusionTexture: BaseTexture;
  45452. /**
  45453. * Defines the alpha limits in alpha test mode.
  45454. */
  45455. alphaCutOff: number;
  45456. /**
  45457. * Gets the current double sided mode.
  45458. */
  45459. /**
  45460. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45461. */
  45462. doubleSided: boolean;
  45463. /**
  45464. * Stores the pre-calculated light information of a mesh in a texture.
  45465. */
  45466. lightmapTexture: BaseTexture;
  45467. /**
  45468. * If true, the light map contains occlusion information instead of lighting info.
  45469. */
  45470. useLightmapAsShadowmap: boolean;
  45471. /**
  45472. * Return the active textures of the material.
  45473. */
  45474. getActiveTextures(): BaseTexture[];
  45475. hasTexture(texture: BaseTexture): boolean;
  45476. /**
  45477. * Instantiates a new PBRMaterial instance.
  45478. *
  45479. * @param name The material name
  45480. * @param scene The scene the material will be use in.
  45481. */
  45482. constructor(name: string, scene: Scene);
  45483. getClassName(): string;
  45484. }
  45485. }
  45486. declare module BABYLON {
  45487. /**
  45488. * The PBR material of BJS following the metal roughness convention.
  45489. *
  45490. * This fits to the PBR convention in the GLTF definition:
  45491. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  45492. */
  45493. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  45494. /**
  45495. * The base color has two different interpretations depending on the value of metalness.
  45496. * When the material is a metal, the base color is the specific measured reflectance value
  45497. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  45498. * of the material.
  45499. */
  45500. baseColor: Color3;
  45501. /**
  45502. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  45503. * well as opacity information in the alpha channel.
  45504. */
  45505. baseTexture: BaseTexture;
  45506. /**
  45507. * Specifies the metallic scalar value of the material.
  45508. * Can also be used to scale the metalness values of the metallic texture.
  45509. */
  45510. metallic: number;
  45511. /**
  45512. * Specifies the roughness scalar value of the material.
  45513. * Can also be used to scale the roughness values of the metallic texture.
  45514. */
  45515. roughness: number;
  45516. /**
  45517. * Texture containing both the metallic value in the B channel and the
  45518. * roughness value in the G channel to keep better precision.
  45519. */
  45520. metallicRoughnessTexture: BaseTexture;
  45521. /**
  45522. * Instantiates a new PBRMetalRoughnessMaterial instance.
  45523. *
  45524. * @param name The material name
  45525. * @param scene The scene the material will be use in.
  45526. */
  45527. constructor(name: string, scene: Scene);
  45528. /**
  45529. * Return the currrent class name of the material.
  45530. */
  45531. getClassName(): string;
  45532. /**
  45533. * Return the active textures of the material.
  45534. */
  45535. getActiveTextures(): BaseTexture[];
  45536. /**
  45537. * Checks to see if a texture is used in the material.
  45538. * @param texture - Base texture to use.
  45539. * @returns - Boolean specifying if a texture is used in the material.
  45540. */
  45541. hasTexture(texture: BaseTexture): boolean;
  45542. /**
  45543. * Makes a duplicate of the current material.
  45544. * @param name - name to use for the new material.
  45545. */
  45546. clone(name: string): PBRMetallicRoughnessMaterial;
  45547. /**
  45548. * Serialize the material to a parsable JSON object.
  45549. */
  45550. serialize(): any;
  45551. /**
  45552. * Parses a JSON object correponding to the serialize function.
  45553. */
  45554. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  45555. }
  45556. }
  45557. declare module BABYLON {
  45558. /**
  45559. * The PBR material of BJS following the specular glossiness convention.
  45560. *
  45561. * This fits to the PBR convention in the GLTF definition:
  45562. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  45563. */
  45564. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  45565. /**
  45566. * Specifies the diffuse color of the material.
  45567. */
  45568. diffuseColor: Color3;
  45569. /**
  45570. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  45571. * channel.
  45572. */
  45573. diffuseTexture: BaseTexture;
  45574. /**
  45575. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  45576. */
  45577. specularColor: Color3;
  45578. /**
  45579. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  45580. */
  45581. glossiness: number;
  45582. /**
  45583. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  45584. */
  45585. specularGlossinessTexture: BaseTexture;
  45586. /**
  45587. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  45588. *
  45589. * @param name The material name
  45590. * @param scene The scene the material will be use in.
  45591. */
  45592. constructor(name: string, scene: Scene);
  45593. /**
  45594. * Return the currrent class name of the material.
  45595. */
  45596. getClassName(): string;
  45597. /**
  45598. * Return the active textures of the material.
  45599. */
  45600. getActiveTextures(): BaseTexture[];
  45601. /**
  45602. * Checks to see if a texture is used in the material.
  45603. * @param texture - Base texture to use.
  45604. * @returns - Boolean specifying if a texture is used in the material.
  45605. */
  45606. hasTexture(texture: BaseTexture): boolean;
  45607. /**
  45608. * Makes a duplicate of the current material.
  45609. * @param name - name to use for the new material.
  45610. */
  45611. clone(name: string): PBRSpecularGlossinessMaterial;
  45612. /**
  45613. * Serialize the material to a parsable JSON object.
  45614. */
  45615. serialize(): any;
  45616. /**
  45617. * Parses a JSON object correponding to the serialize function.
  45618. */
  45619. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  45620. }
  45621. }
  45622. declare module BABYLON {
  45623. /**
  45624. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  45625. * It can help converting any input color in a desired output one. This can then be used to create effects
  45626. * from sepia, black and white to sixties or futuristic rendering...
  45627. *
  45628. * The only supported format is currently 3dl.
  45629. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  45630. */
  45631. export class ColorGradingTexture extends BaseTexture {
  45632. /**
  45633. * The current texture matrix. (will always be identity in color grading texture)
  45634. */
  45635. private _textureMatrix;
  45636. /**
  45637. * The texture URL.
  45638. */
  45639. url: string;
  45640. /**
  45641. * Empty line regex stored for GC.
  45642. */
  45643. private static _noneEmptyLineRegex;
  45644. private _engine;
  45645. /**
  45646. * Instantiates a ColorGradingTexture from the following parameters.
  45647. *
  45648. * @param url The location of the color gradind data (currently only supporting 3dl)
  45649. * @param scene The scene the texture will be used in
  45650. */
  45651. constructor(url: string, scene: Scene);
  45652. /**
  45653. * Returns the texture matrix used in most of the material.
  45654. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  45655. */
  45656. getTextureMatrix(): Matrix;
  45657. /**
  45658. * Occurs when the file being loaded is a .3dl LUT file.
  45659. */
  45660. private load3dlTexture;
  45661. /**
  45662. * Starts the loading process of the texture.
  45663. */
  45664. private loadTexture;
  45665. /**
  45666. * Clones the color gradind texture.
  45667. */
  45668. clone(): ColorGradingTexture;
  45669. /**
  45670. * Called during delayed load for textures.
  45671. */
  45672. delayLoad(): void;
  45673. /**
  45674. * Parses a color grading texture serialized by Babylon.
  45675. * @param parsedTexture The texture information being parsedTexture
  45676. * @param scene The scene to load the texture in
  45677. * @param rootUrl The root url of the data assets to load
  45678. * @return A color gradind texture
  45679. */
  45680. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  45681. /**
  45682. * Serializes the LUT texture to json format.
  45683. */
  45684. serialize(): any;
  45685. }
  45686. }
  45687. declare module BABYLON {
  45688. /**
  45689. * Direct draw surface info
  45690. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45691. */
  45692. export interface DDSInfo {
  45693. /**
  45694. * Width of the texture
  45695. */
  45696. width: number;
  45697. /**
  45698. * Width of the texture
  45699. */
  45700. height: number;
  45701. /**
  45702. * Number of Mipmaps for the texture
  45703. * @see https://en.wikipedia.org/wiki/Mipmap
  45704. */
  45705. mipmapCount: number;
  45706. /**
  45707. * If the textures format is a known fourCC format
  45708. * @see https://www.fourcc.org/
  45709. */
  45710. isFourCC: boolean;
  45711. /**
  45712. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45713. */
  45714. isRGB: boolean;
  45715. /**
  45716. * If the texture is a lumincance format
  45717. */
  45718. isLuminance: boolean;
  45719. /**
  45720. * If this is a cube texture
  45721. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45722. */
  45723. isCube: boolean;
  45724. /**
  45725. * If the texture is a compressed format eg. FOURCC_DXT1
  45726. */
  45727. isCompressed: boolean;
  45728. /**
  45729. * The dxgiFormat of the texture
  45730. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45731. */
  45732. dxgiFormat: number;
  45733. /**
  45734. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45735. */
  45736. textureType: number;
  45737. /**
  45738. * Sphericle polynomial created for the dds texture
  45739. */
  45740. sphericalPolynomial?: SphericalPolynomial;
  45741. }
  45742. /**
  45743. * Class used to provide DDS decompression tools
  45744. */
  45745. export class DDSTools {
  45746. /**
  45747. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45748. */
  45749. static StoreLODInAlphaChannel: boolean;
  45750. /**
  45751. * Gets DDS information from an array buffer
  45752. * @param arrayBuffer defines the array buffer to read data from
  45753. * @returns the DDS information
  45754. */
  45755. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45756. private static _FloatView;
  45757. private static _Int32View;
  45758. private static _ToHalfFloat;
  45759. private static _FromHalfFloat;
  45760. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45761. private static _GetHalfFloatRGBAArrayBuffer;
  45762. private static _GetFloatRGBAArrayBuffer;
  45763. private static _GetFloatAsUIntRGBAArrayBuffer;
  45764. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45765. private static _GetRGBAArrayBuffer;
  45766. private static _ExtractLongWordOrder;
  45767. private static _GetRGBArrayBuffer;
  45768. private static _GetLuminanceArrayBuffer;
  45769. /**
  45770. * Uploads DDS Levels to a Babylon Texture
  45771. * @hidden
  45772. */
  45773. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45774. }
  45775. interface Engine {
  45776. /**
  45777. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45778. * @param rootUrl defines the url where the file to load is located
  45779. * @param scene defines the current scene
  45780. * @param lodScale defines scale to apply to the mip map selection
  45781. * @param lodOffset defines offset to apply to the mip map selection
  45782. * @param onLoad defines an optional callback raised when the texture is loaded
  45783. * @param onError defines an optional callback raised if there is an issue to load the texture
  45784. * @param format defines the format of the data
  45785. * @param forcedExtension defines the extension to use to pick the right loader
  45786. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45787. * @returns the cube texture as an InternalTexture
  45788. */
  45789. 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;
  45790. }
  45791. }
  45792. declare module BABYLON {
  45793. /**
  45794. * Implementation of the DDS Texture Loader.
  45795. * @hidden
  45796. */
  45797. export class _DDSTextureLoader implements IInternalTextureLoader {
  45798. /**
  45799. * Defines wether the loader supports cascade loading the different faces.
  45800. */
  45801. readonly supportCascades: boolean;
  45802. /**
  45803. * This returns if the loader support the current file information.
  45804. * @param extension defines the file extension of the file being loaded
  45805. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45806. * @param fallback defines the fallback internal texture if any
  45807. * @param isBase64 defines whether the texture is encoded as a base64
  45808. * @param isBuffer defines whether the texture data are stored as a buffer
  45809. * @returns true if the loader can load the specified file
  45810. */
  45811. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45812. /**
  45813. * Transform the url before loading if required.
  45814. * @param rootUrl the url of the texture
  45815. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45816. * @returns the transformed texture
  45817. */
  45818. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45819. /**
  45820. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45821. * @param rootUrl the url of the texture
  45822. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45823. * @returns the fallback texture
  45824. */
  45825. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45826. /**
  45827. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45828. * @param data contains the texture data
  45829. * @param texture defines the BabylonJS internal texture
  45830. * @param createPolynomials will be true if polynomials have been requested
  45831. * @param onLoad defines the callback to trigger once the texture is ready
  45832. * @param onError defines the callback to trigger in case of error
  45833. */
  45834. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45835. /**
  45836. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45837. * @param data contains the texture data
  45838. * @param texture defines the BabylonJS internal texture
  45839. * @param callback defines the method to call once ready to upload
  45840. */
  45841. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45842. }
  45843. }
  45844. declare module BABYLON {
  45845. /** @hidden */
  45846. export var rgbdEncodePixelShader: {
  45847. name: string;
  45848. shader: string;
  45849. };
  45850. }
  45851. declare module BABYLON {
  45852. /** @hidden */
  45853. export var rgbdDecodePixelShader: {
  45854. name: string;
  45855. shader: string;
  45856. };
  45857. }
  45858. declare module BABYLON {
  45859. /**
  45860. * Raw texture data and descriptor sufficient for WebGL texture upload
  45861. */
  45862. export interface EnvironmentTextureInfo {
  45863. /**
  45864. * Version of the environment map
  45865. */
  45866. version: number;
  45867. /**
  45868. * Width of image
  45869. */
  45870. width: number;
  45871. /**
  45872. * Irradiance information stored in the file.
  45873. */
  45874. irradiance: any;
  45875. /**
  45876. * Specular information stored in the file.
  45877. */
  45878. specular: any;
  45879. }
  45880. /**
  45881. * Sets of helpers addressing the serialization and deserialization of environment texture
  45882. * stored in a BabylonJS env file.
  45883. * Those files are usually stored as .env files.
  45884. */
  45885. export class EnvironmentTextureTools {
  45886. /**
  45887. * Magic number identifying the env file.
  45888. */
  45889. private static _MagicBytes;
  45890. /**
  45891. * Gets the environment info from an env file.
  45892. * @param data The array buffer containing the .env bytes.
  45893. * @returns the environment file info (the json header) if successfully parsed.
  45894. */
  45895. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45896. /**
  45897. * Creates an environment texture from a loaded cube texture.
  45898. * @param texture defines the cube texture to convert in env file
  45899. * @return a promise containing the environment data if succesfull.
  45900. */
  45901. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45902. /**
  45903. * Creates a JSON representation of the spherical data.
  45904. * @param texture defines the texture containing the polynomials
  45905. * @return the JSON representation of the spherical info
  45906. */
  45907. private static _CreateEnvTextureIrradiance;
  45908. /**
  45909. * Uploads the texture info contained in the env file to the GPU.
  45910. * @param texture defines the internal texture to upload to
  45911. * @param arrayBuffer defines the buffer cotaining the data to load
  45912. * @param info defines the texture info retrieved through the GetEnvInfo method
  45913. * @returns a promise
  45914. */
  45915. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45916. /**
  45917. * Uploads the levels of image data to the GPU.
  45918. * @param texture defines the internal texture to upload to
  45919. * @param imageData defines the array buffer views of image data [mipmap][face]
  45920. * @returns a promise
  45921. */
  45922. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45923. /**
  45924. * Uploads spherical polynomials information to the texture.
  45925. * @param texture defines the texture we are trying to upload the information to
  45926. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45927. */
  45928. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45929. /** @hidden */
  45930. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45931. }
  45932. }
  45933. declare module BABYLON {
  45934. /**
  45935. * Implementation of the ENV Texture Loader.
  45936. * @hidden
  45937. */
  45938. export class _ENVTextureLoader implements IInternalTextureLoader {
  45939. /**
  45940. * Defines wether the loader supports cascade loading the different faces.
  45941. */
  45942. readonly supportCascades: boolean;
  45943. /**
  45944. * This returns if the loader support the current file information.
  45945. * @param extension defines the file extension of the file being loaded
  45946. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45947. * @param fallback defines the fallback internal texture if any
  45948. * @param isBase64 defines whether the texture is encoded as a base64
  45949. * @param isBuffer defines whether the texture data are stored as a buffer
  45950. * @returns true if the loader can load the specified file
  45951. */
  45952. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45953. /**
  45954. * Transform the url before loading if required.
  45955. * @param rootUrl the url of the texture
  45956. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45957. * @returns the transformed texture
  45958. */
  45959. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45960. /**
  45961. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45962. * @param rootUrl the url of the texture
  45963. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45964. * @returns the fallback texture
  45965. */
  45966. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45967. /**
  45968. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45969. * @param data contains the texture data
  45970. * @param texture defines the BabylonJS internal texture
  45971. * @param createPolynomials will be true if polynomials have been requested
  45972. * @param onLoad defines the callback to trigger once the texture is ready
  45973. * @param onError defines the callback to trigger in case of error
  45974. */
  45975. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45976. /**
  45977. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45978. * @param data contains the texture data
  45979. * @param texture defines the BabylonJS internal texture
  45980. * @param callback defines the method to call once ready to upload
  45981. */
  45982. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45983. }
  45984. }
  45985. declare module BABYLON {
  45986. /**
  45987. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  45988. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  45989. */
  45990. export class KhronosTextureContainer {
  45991. /** contents of the KTX container file */
  45992. arrayBuffer: any;
  45993. private static HEADER_LEN;
  45994. private static COMPRESSED_2D;
  45995. private static COMPRESSED_3D;
  45996. private static TEX_2D;
  45997. private static TEX_3D;
  45998. /**
  45999. * Gets the openGL type
  46000. */
  46001. glType: number;
  46002. /**
  46003. * Gets the openGL type size
  46004. */
  46005. glTypeSize: number;
  46006. /**
  46007. * Gets the openGL format
  46008. */
  46009. glFormat: number;
  46010. /**
  46011. * Gets the openGL internal format
  46012. */
  46013. glInternalFormat: number;
  46014. /**
  46015. * Gets the base internal format
  46016. */
  46017. glBaseInternalFormat: number;
  46018. /**
  46019. * Gets image width in pixel
  46020. */
  46021. pixelWidth: number;
  46022. /**
  46023. * Gets image height in pixel
  46024. */
  46025. pixelHeight: number;
  46026. /**
  46027. * Gets image depth in pixels
  46028. */
  46029. pixelDepth: number;
  46030. /**
  46031. * Gets the number of array elements
  46032. */
  46033. numberOfArrayElements: number;
  46034. /**
  46035. * Gets the number of faces
  46036. */
  46037. numberOfFaces: number;
  46038. /**
  46039. * Gets the number of mipmap levels
  46040. */
  46041. numberOfMipmapLevels: number;
  46042. /**
  46043. * Gets the bytes of key value data
  46044. */
  46045. bytesOfKeyValueData: number;
  46046. /**
  46047. * Gets the load type
  46048. */
  46049. loadType: number;
  46050. /**
  46051. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46052. */
  46053. isInvalid: boolean;
  46054. /**
  46055. * Creates a new KhronosTextureContainer
  46056. * @param arrayBuffer contents of the KTX container file
  46057. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46058. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46059. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46060. */
  46061. constructor(
  46062. /** contents of the KTX container file */
  46063. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46064. /**
  46065. * Uploads KTX content to a Babylon Texture.
  46066. * It is assumed that the texture has already been created & is currently bound
  46067. * @hidden
  46068. */
  46069. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46070. private _upload2DCompressedLevels;
  46071. }
  46072. }
  46073. declare module BABYLON {
  46074. /**
  46075. * Implementation of the KTX Texture Loader.
  46076. * @hidden
  46077. */
  46078. export class _KTXTextureLoader implements IInternalTextureLoader {
  46079. /**
  46080. * Defines wether the loader supports cascade loading the different faces.
  46081. */
  46082. readonly supportCascades: boolean;
  46083. /**
  46084. * This returns if the loader support the current file information.
  46085. * @param extension defines the file extension of the file being loaded
  46086. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46087. * @param fallback defines the fallback internal texture if any
  46088. * @param isBase64 defines whether the texture is encoded as a base64
  46089. * @param isBuffer defines whether the texture data are stored as a buffer
  46090. * @returns true if the loader can load the specified file
  46091. */
  46092. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46093. /**
  46094. * Transform the url before loading if required.
  46095. * @param rootUrl the url of the texture
  46096. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46097. * @returns the transformed texture
  46098. */
  46099. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46100. /**
  46101. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46102. * @param rootUrl the url of the texture
  46103. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46104. * @returns the fallback texture
  46105. */
  46106. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46107. /**
  46108. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46109. * @param data contains the texture data
  46110. * @param texture defines the BabylonJS internal texture
  46111. * @param createPolynomials will be true if polynomials have been requested
  46112. * @param onLoad defines the callback to trigger once the texture is ready
  46113. * @param onError defines the callback to trigger in case of error
  46114. */
  46115. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46116. /**
  46117. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46118. * @param data contains the texture data
  46119. * @param texture defines the BabylonJS internal texture
  46120. * @param callback defines the method to call once ready to upload
  46121. */
  46122. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46123. }
  46124. }
  46125. declare module BABYLON {
  46126. /**
  46127. * Based on jsTGALoader - Javascript loader for TGA file
  46128. * By Vincent Thibault
  46129. * @see http://blog.robrowser.com/javascript-tga-loader.html
  46130. */
  46131. export class TGATools {
  46132. private static _TYPE_INDEXED;
  46133. private static _TYPE_RGB;
  46134. private static _TYPE_GREY;
  46135. private static _TYPE_RLE_INDEXED;
  46136. private static _TYPE_RLE_RGB;
  46137. private static _TYPE_RLE_GREY;
  46138. private static _ORIGIN_MASK;
  46139. private static _ORIGIN_SHIFT;
  46140. private static _ORIGIN_BL;
  46141. private static _ORIGIN_BR;
  46142. private static _ORIGIN_UL;
  46143. private static _ORIGIN_UR;
  46144. /**
  46145. * Gets the header of a TGA file
  46146. * @param data defines the TGA data
  46147. * @returns the header
  46148. */
  46149. static GetTGAHeader(data: Uint8Array): any;
  46150. /**
  46151. * Uploads TGA content to a Babylon Texture
  46152. * @hidden
  46153. */
  46154. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  46155. /** @hidden */
  46156. 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;
  46157. /** @hidden */
  46158. 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;
  46159. /** @hidden */
  46160. 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;
  46161. /** @hidden */
  46162. 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;
  46163. /** @hidden */
  46164. 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;
  46165. /** @hidden */
  46166. 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;
  46167. }
  46168. }
  46169. declare module BABYLON {
  46170. /**
  46171. * Implementation of the TGA Texture Loader.
  46172. * @hidden
  46173. */
  46174. export class _TGATextureLoader implements IInternalTextureLoader {
  46175. /**
  46176. * Defines wether the loader supports cascade loading the different faces.
  46177. */
  46178. readonly supportCascades: boolean;
  46179. /**
  46180. * This returns if the loader support the current file information.
  46181. * @param extension defines the file extension of the file being loaded
  46182. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46183. * @param fallback defines the fallback internal texture if any
  46184. * @param isBase64 defines whether the texture is encoded as a base64
  46185. * @param isBuffer defines whether the texture data are stored as a buffer
  46186. * @returns true if the loader can load the specified file
  46187. */
  46188. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46189. /**
  46190. * Transform the url before loading if required.
  46191. * @param rootUrl the url of the texture
  46192. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46193. * @returns the transformed texture
  46194. */
  46195. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46196. /**
  46197. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46198. * @param rootUrl the url of the texture
  46199. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46200. * @returns the fallback texture
  46201. */
  46202. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46203. /**
  46204. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46205. * @param data contains the texture data
  46206. * @param texture defines the BabylonJS internal texture
  46207. * @param createPolynomials will be true if polynomials have been requested
  46208. * @param onLoad defines the callback to trigger once the texture is ready
  46209. * @param onError defines the callback to trigger in case of error
  46210. */
  46211. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46212. /**
  46213. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46214. * @param data contains the texture data
  46215. * @param texture defines the BabylonJS internal texture
  46216. * @param callback defines the method to call once ready to upload
  46217. */
  46218. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46219. }
  46220. }
  46221. declare module BABYLON {
  46222. /**
  46223. * 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.
  46224. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  46225. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  46226. */
  46227. export class CustomProceduralTexture extends ProceduralTexture {
  46228. private _animate;
  46229. private _time;
  46230. private _config;
  46231. private _texturePath;
  46232. /**
  46233. * Instantiates a new Custom Procedural Texture.
  46234. * 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.
  46235. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  46236. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  46237. * @param name Define the name of the texture
  46238. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  46239. * @param size Define the size of the texture to create
  46240. * @param scene Define the scene the texture belongs to
  46241. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  46242. * @param generateMipMaps Define if the texture should creates mip maps or not
  46243. */
  46244. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  46245. private _loadJson;
  46246. /**
  46247. * Is the texture ready to be used ? (rendered at least once)
  46248. * @returns true if ready, otherwise, false.
  46249. */
  46250. isReady(): boolean;
  46251. /**
  46252. * Render the texture to its associated render target.
  46253. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  46254. */
  46255. render(useCameraPostProcess?: boolean): void;
  46256. /**
  46257. * Update the list of dependant textures samplers in the shader.
  46258. */
  46259. updateTextures(): void;
  46260. /**
  46261. * Update the uniform values of the procedural texture in the shader.
  46262. */
  46263. updateShaderUniforms(): void;
  46264. /**
  46265. * Define if the texture animates or not.
  46266. */
  46267. animate: boolean;
  46268. }
  46269. }
  46270. declare module BABYLON {
  46271. /** @hidden */
  46272. export var noisePixelShader: {
  46273. name: string;
  46274. shader: string;
  46275. };
  46276. }
  46277. declare module BABYLON {
  46278. /**
  46279. * Class used to generate noise procedural textures
  46280. */
  46281. export class NoiseProceduralTexture extends ProceduralTexture {
  46282. private _time;
  46283. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  46284. brightness: number;
  46285. /** Defines the number of octaves to process */
  46286. octaves: number;
  46287. /** Defines the level of persistence (0.8 by default) */
  46288. persistence: number;
  46289. /** Gets or sets animation speed factor (default is 1) */
  46290. animationSpeedFactor: number;
  46291. /**
  46292. * Creates a new NoiseProceduralTexture
  46293. * @param name defines the name fo the texture
  46294. * @param size defines the size of the texture (default is 256)
  46295. * @param scene defines the hosting scene
  46296. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  46297. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  46298. */
  46299. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  46300. private _updateShaderUniforms;
  46301. protected _getDefines(): string;
  46302. /** Generate the current state of the procedural texture */
  46303. render(useCameraPostProcess?: boolean): void;
  46304. /**
  46305. * Serializes this noise procedural texture
  46306. * @returns a serialized noise procedural texture object
  46307. */
  46308. serialize(): any;
  46309. /**
  46310. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  46311. * @param parsedTexture defines parsed texture data
  46312. * @param scene defines the current scene
  46313. * @param rootUrl defines the root URL containing noise procedural texture information
  46314. * @returns a parsed NoiseProceduralTexture
  46315. */
  46316. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  46317. }
  46318. }
  46319. declare module BABYLON {
  46320. /**
  46321. * Raw cube texture where the raw buffers are passed in
  46322. */
  46323. export class RawCubeTexture extends CubeTexture {
  46324. /**
  46325. * Creates a cube texture where the raw buffers are passed in.
  46326. * @param scene defines the scene the texture is attached to
  46327. * @param data defines the array of data to use to create each face
  46328. * @param size defines the size of the textures
  46329. * @param format defines the format of the data
  46330. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  46331. * @param generateMipMaps defines if the engine should generate the mip levels
  46332. * @param invertY defines if data must be stored with Y axis inverted
  46333. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46334. * @param compression defines the compression used (null by default)
  46335. */
  46336. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  46337. /**
  46338. * Updates the raw cube texture.
  46339. * @param data defines the data to store
  46340. * @param format defines the data format
  46341. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46342. * @param invertY defines if data must be stored with Y axis inverted
  46343. * @param compression defines the compression used (null by default)
  46344. * @param level defines which level of the texture to update
  46345. */
  46346. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  46347. /**
  46348. * Updates a raw cube texture with RGBD encoded data.
  46349. * @param data defines the array of data [mipmap][face] to use to create each face
  46350. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  46351. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46352. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46353. * @returns a promsie that resolves when the operation is complete
  46354. */
  46355. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  46356. /**
  46357. * Clones the raw cube texture.
  46358. * @return a new cube texture
  46359. */
  46360. clone(): CubeTexture;
  46361. /** @hidden */
  46362. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46363. }
  46364. }
  46365. declare module BABYLON {
  46366. /**
  46367. * Class used to store 3D textures containing user data
  46368. */
  46369. export class RawTexture3D extends Texture {
  46370. /** Gets or sets the texture format to use */
  46371. format: number;
  46372. private _engine;
  46373. /**
  46374. * Create a new RawTexture3D
  46375. * @param data defines the data of the texture
  46376. * @param width defines the width of the texture
  46377. * @param height defines the height of the texture
  46378. * @param depth defines the depth of the texture
  46379. * @param format defines the texture format to use
  46380. * @param scene defines the hosting scene
  46381. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  46382. * @param invertY defines if texture must be stored with Y axis inverted
  46383. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  46384. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  46385. */
  46386. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  46387. /** Gets or sets the texture format to use */
  46388. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  46389. /**
  46390. * Update the texture with new data
  46391. * @param data defines the data to store in the texture
  46392. */
  46393. update(data: ArrayBufferView): void;
  46394. }
  46395. }
  46396. declare module BABYLON {
  46397. /**
  46398. * Creates a refraction texture used by refraction channel of the standard material.
  46399. * It is like a mirror but to see through a material.
  46400. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46401. */
  46402. export class RefractionTexture extends RenderTargetTexture {
  46403. /**
  46404. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  46405. * It is possible to directly set the refractionPlane by directly using a 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.
  46406. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46407. */
  46408. refractionPlane: Plane;
  46409. /**
  46410. * Define how deep under the surface we should see.
  46411. */
  46412. depth: number;
  46413. /**
  46414. * Creates a refraction texture used by refraction channel of the standard material.
  46415. * It is like a mirror but to see through a material.
  46416. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46417. * @param name Define the texture name
  46418. * @param size Define the size of the underlying texture
  46419. * @param scene Define the scene the refraction belongs to
  46420. * @param generateMipMaps Define if we need to generate mips level for the refraction
  46421. */
  46422. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  46423. /**
  46424. * Clone the refraction texture.
  46425. * @returns the cloned texture
  46426. */
  46427. clone(): RefractionTexture;
  46428. /**
  46429. * Serialize the texture to a JSON representation you could use in Parse later on
  46430. * @returns the serialized JSON representation
  46431. */
  46432. serialize(): any;
  46433. }
  46434. }
  46435. declare module BABYLON {
  46436. /**
  46437. * Configuration for Draco compression
  46438. */
  46439. export interface IDracoCompressionConfiguration {
  46440. /**
  46441. * Configuration for the decoder.
  46442. */
  46443. decoder?: {
  46444. /**
  46445. * The url to the WebAssembly module.
  46446. */
  46447. wasmUrl?: string;
  46448. /**
  46449. * The url to the WebAssembly binary.
  46450. */
  46451. wasmBinaryUrl?: string;
  46452. /**
  46453. * The url to the fallback JavaScript module.
  46454. */
  46455. fallbackUrl?: string;
  46456. };
  46457. }
  46458. /**
  46459. * Draco compression (https://google.github.io/draco/)
  46460. *
  46461. * This class wraps the Draco module.
  46462. *
  46463. * **Encoder**
  46464. *
  46465. * The encoder is not currently implemented.
  46466. *
  46467. * **Decoder**
  46468. *
  46469. * 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.
  46470. *
  46471. * To update the configuration, use the following code:
  46472. * ```javascript
  46473. * DracoCompression.Configuration = {
  46474. * decoder: {
  46475. * wasmUrl: "<url to the WebAssembly library>",
  46476. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  46477. * fallbackUrl: "<url to the fallback JavaScript library>",
  46478. * }
  46479. * };
  46480. * ```
  46481. *
  46482. * 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.
  46483. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  46484. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  46485. *
  46486. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  46487. * ```javascript
  46488. * var dracoCompression = new DracoCompression();
  46489. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  46490. * [VertexBuffer.PositionKind]: 0
  46491. * });
  46492. * ```
  46493. *
  46494. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  46495. */
  46496. export class DracoCompression implements IDisposable {
  46497. private static _DecoderModulePromise;
  46498. /**
  46499. * The configuration. Defaults to the following urls:
  46500. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  46501. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  46502. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  46503. */
  46504. static Configuration: IDracoCompressionConfiguration;
  46505. /**
  46506. * Returns true if the decoder is available.
  46507. */
  46508. static readonly DecoderAvailable: boolean;
  46509. /**
  46510. * Constructor
  46511. */
  46512. constructor();
  46513. /**
  46514. * Stop all async operations and release resources.
  46515. */
  46516. dispose(): void;
  46517. /**
  46518. * Decode Draco compressed mesh data to vertex data.
  46519. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  46520. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  46521. * @returns A promise that resolves with the decoded vertex data
  46522. */
  46523. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  46524. [kind: string]: number;
  46525. }): Promise<VertexData>;
  46526. private static _GetDecoderModule;
  46527. private static _LoadScriptAsync;
  46528. private static _LoadFileAsync;
  46529. }
  46530. }
  46531. declare module BABYLON {
  46532. /**
  46533. * Class for building Constructive Solid Geometry
  46534. */
  46535. export class CSG {
  46536. private polygons;
  46537. /**
  46538. * The world matrix
  46539. */
  46540. matrix: Matrix;
  46541. /**
  46542. * Stores the position
  46543. */
  46544. position: Vector3;
  46545. /**
  46546. * Stores the rotation
  46547. */
  46548. rotation: Vector3;
  46549. /**
  46550. * Stores the rotation quaternion
  46551. */
  46552. rotationQuaternion: Nullable<Quaternion>;
  46553. /**
  46554. * Stores the scaling vector
  46555. */
  46556. scaling: Vector3;
  46557. /**
  46558. * Convert the Mesh to CSG
  46559. * @param mesh The Mesh to convert to CSG
  46560. * @returns A new CSG from the Mesh
  46561. */
  46562. static FromMesh(mesh: Mesh): CSG;
  46563. /**
  46564. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  46565. * @param polygons Polygons used to construct a CSG solid
  46566. */
  46567. private static FromPolygons;
  46568. /**
  46569. * Clones, or makes a deep copy, of the CSG
  46570. * @returns A new CSG
  46571. */
  46572. clone(): CSG;
  46573. /**
  46574. * Unions this CSG with another CSG
  46575. * @param csg The CSG to union against this CSG
  46576. * @returns The unioned CSG
  46577. */
  46578. union(csg: CSG): CSG;
  46579. /**
  46580. * Unions this CSG with another CSG in place
  46581. * @param csg The CSG to union against this CSG
  46582. */
  46583. unionInPlace(csg: CSG): void;
  46584. /**
  46585. * Subtracts this CSG with another CSG
  46586. * @param csg The CSG to subtract against this CSG
  46587. * @returns A new CSG
  46588. */
  46589. subtract(csg: CSG): CSG;
  46590. /**
  46591. * Subtracts this CSG with another CSG in place
  46592. * @param csg The CSG to subtact against this CSG
  46593. */
  46594. subtractInPlace(csg: CSG): void;
  46595. /**
  46596. * Intersect this CSG with another CSG
  46597. * @param csg The CSG to intersect against this CSG
  46598. * @returns A new CSG
  46599. */
  46600. intersect(csg: CSG): CSG;
  46601. /**
  46602. * Intersects this CSG with another CSG in place
  46603. * @param csg The CSG to intersect against this CSG
  46604. */
  46605. intersectInPlace(csg: CSG): void;
  46606. /**
  46607. * Return a new CSG solid with solid and empty space switched. This solid is
  46608. * not modified.
  46609. * @returns A new CSG solid with solid and empty space switched
  46610. */
  46611. inverse(): CSG;
  46612. /**
  46613. * Inverses the CSG in place
  46614. */
  46615. inverseInPlace(): void;
  46616. /**
  46617. * This is used to keep meshes transformations so they can be restored
  46618. * when we build back a Babylon Mesh
  46619. * NB : All CSG operations are performed in world coordinates
  46620. * @param csg The CSG to copy the transform attributes from
  46621. * @returns This CSG
  46622. */
  46623. copyTransformAttributes(csg: CSG): CSG;
  46624. /**
  46625. * Build Raw mesh from CSG
  46626. * Coordinates here are in world space
  46627. * @param name The name of the mesh geometry
  46628. * @param scene The Scene
  46629. * @param keepSubMeshes Specifies if the submeshes should be kept
  46630. * @returns A new Mesh
  46631. */
  46632. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  46633. /**
  46634. * Build Mesh from CSG taking material and transforms into account
  46635. * @param name The name of the Mesh
  46636. * @param material The material of the Mesh
  46637. * @param scene The Scene
  46638. * @param keepSubMeshes Specifies if submeshes should be kept
  46639. * @returns The new Mesh
  46640. */
  46641. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  46642. }
  46643. }
  46644. declare module BABYLON {
  46645. /**
  46646. * Class containing static functions to help procedurally build meshes
  46647. */
  46648. export class RibbonBuilder {
  46649. /**
  46650. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  46651. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  46652. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  46653. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  46654. * * 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
  46655. * * 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
  46656. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  46657. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46658. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46659. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46660. * * 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
  46661. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  46662. * * 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
  46663. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  46664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46665. * @param name defines the name of the mesh
  46666. * @param options defines the options used to create the mesh
  46667. * @param scene defines the hosting scene
  46668. * @returns the ribbon mesh
  46669. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  46670. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46671. */
  46672. static CreateRibbon(name: string, options: {
  46673. pathArray: Vector3[][];
  46674. closeArray?: boolean;
  46675. closePath?: boolean;
  46676. offset?: number;
  46677. updatable?: boolean;
  46678. sideOrientation?: number;
  46679. frontUVs?: Vector4;
  46680. backUVs?: Vector4;
  46681. instance?: Mesh;
  46682. invertUV?: boolean;
  46683. uvs?: Vector2[];
  46684. colors?: Color4[];
  46685. }, scene?: Nullable<Scene>): Mesh;
  46686. }
  46687. }
  46688. declare module BABYLON {
  46689. /**
  46690. * Class containing static functions to help procedurally build meshes
  46691. */
  46692. export class TorusKnotBuilder {
  46693. /**
  46694. * Creates a torus knot mesh
  46695. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  46696. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  46697. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  46698. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  46699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46700. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46702. * @param name defines the name of the mesh
  46703. * @param options defines the options used to create the mesh
  46704. * @param scene defines the hosting scene
  46705. * @returns the torus knot mesh
  46706. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  46707. */
  46708. static CreateTorusKnot(name: string, options: {
  46709. radius?: number;
  46710. tube?: number;
  46711. radialSegments?: number;
  46712. tubularSegments?: number;
  46713. p?: number;
  46714. q?: number;
  46715. updatable?: boolean;
  46716. sideOrientation?: number;
  46717. frontUVs?: Vector4;
  46718. backUVs?: Vector4;
  46719. }, scene: any): Mesh;
  46720. }
  46721. }
  46722. declare module BABYLON {
  46723. /**
  46724. * Polygon
  46725. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  46726. */
  46727. export class Polygon {
  46728. /**
  46729. * Creates a rectangle
  46730. * @param xmin bottom X coord
  46731. * @param ymin bottom Y coord
  46732. * @param xmax top X coord
  46733. * @param ymax top Y coord
  46734. * @returns points that make the resulting rectation
  46735. */
  46736. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  46737. /**
  46738. * Creates a circle
  46739. * @param radius radius of circle
  46740. * @param cx scale in x
  46741. * @param cy scale in y
  46742. * @param numberOfSides number of sides that make up the circle
  46743. * @returns points that make the resulting circle
  46744. */
  46745. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  46746. /**
  46747. * Creates a polygon from input string
  46748. * @param input Input polygon data
  46749. * @returns the parsed points
  46750. */
  46751. static Parse(input: string): Vector2[];
  46752. /**
  46753. * Starts building a polygon from x and y coordinates
  46754. * @param x x coordinate
  46755. * @param y y coordinate
  46756. * @returns the started path2
  46757. */
  46758. static StartingAt(x: number, y: number): Path2;
  46759. }
  46760. /**
  46761. * Builds a polygon
  46762. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  46763. */
  46764. export class PolygonMeshBuilder {
  46765. private _points;
  46766. private _outlinepoints;
  46767. private _holes;
  46768. private _name;
  46769. private _scene;
  46770. private _epoints;
  46771. private _eholes;
  46772. private _addToepoint;
  46773. /**
  46774. * Babylon reference to the earcut plugin.
  46775. */
  46776. bjsEarcut: any;
  46777. /**
  46778. * Creates a PolygonMeshBuilder
  46779. * @param name name of the builder
  46780. * @param contours Path of the polygon
  46781. * @param scene scene to add to
  46782. * @param earcutInjection can be used to inject your own earcut reference
  46783. */
  46784. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  46785. /**
  46786. * Adds a whole within the polygon
  46787. * @param hole Array of points defining the hole
  46788. * @returns this
  46789. */
  46790. addHole(hole: Vector2[]): PolygonMeshBuilder;
  46791. /**
  46792. * Creates the polygon
  46793. * @param updatable If the mesh should be updatable
  46794. * @param depth The depth of the mesh created
  46795. * @returns the created mesh
  46796. */
  46797. build(updatable?: boolean, depth?: number): Mesh;
  46798. /**
  46799. * Adds a side to the polygon
  46800. * @param positions points that make the polygon
  46801. * @param normals normals of the polygon
  46802. * @param uvs uvs of the polygon
  46803. * @param indices indices of the polygon
  46804. * @param bounds bounds of the polygon
  46805. * @param points points of the polygon
  46806. * @param depth depth of the polygon
  46807. * @param flip flip of the polygon
  46808. */
  46809. private addSide;
  46810. }
  46811. }
  46812. declare module BABYLON {
  46813. /**
  46814. * Class containing static functions to help procedurally build meshes
  46815. */
  46816. export class PolygonBuilder {
  46817. /**
  46818. * Creates a polygon mesh
  46819. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  46820. * * 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
  46821. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  46822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46823. * * 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)
  46824. * * Remember you can only change the shape positions, not their number when updating a polygon
  46825. * @param name defines the name of the mesh
  46826. * @param options defines the options used to create the mesh
  46827. * @param scene defines the hosting scene
  46828. * @param earcutInjection can be used to inject your own earcut reference
  46829. * @returns the polygon mesh
  46830. */
  46831. static CreatePolygon(name: string, options: {
  46832. shape: Vector3[];
  46833. holes?: Vector3[][];
  46834. depth?: number;
  46835. faceUV?: Vector4[];
  46836. faceColors?: Color4[];
  46837. updatable?: boolean;
  46838. sideOrientation?: number;
  46839. frontUVs?: Vector4;
  46840. backUVs?: Vector4;
  46841. }, scene: Scene, earcutInjection?: any): Mesh;
  46842. /**
  46843. * Creates an extruded polygon mesh, with depth in the Y direction.
  46844. * * 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)
  46845. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46846. * @param name defines the name of the mesh
  46847. * @param options defines the options used to create the mesh
  46848. * @param scene defines the hosting scene
  46849. * @param earcutInjection can be used to inject your own earcut reference
  46850. * @returns the polygon mesh
  46851. */
  46852. static ExtrudePolygon(name: string, options: {
  46853. shape: Vector3[];
  46854. holes?: Vector3[][];
  46855. depth?: number;
  46856. faceUV?: Vector4[];
  46857. faceColors?: Color4[];
  46858. updatable?: boolean;
  46859. sideOrientation?: number;
  46860. frontUVs?: Vector4;
  46861. backUVs?: Vector4;
  46862. }, scene: Scene, earcutInjection?: any): Mesh;
  46863. }
  46864. }
  46865. declare module BABYLON {
  46866. /**
  46867. * Class containing static functions to help procedurally build meshes
  46868. */
  46869. export class ShapeBuilder {
  46870. /**
  46871. * 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.
  46872. * * 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.
  46873. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  46874. * * 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.
  46875. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  46876. * * 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
  46877. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  46878. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  46879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46880. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46881. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  46882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46883. * @param name defines the name of the mesh
  46884. * @param options defines the options used to create the mesh
  46885. * @param scene defines the hosting scene
  46886. * @returns the extruded shape mesh
  46887. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46888. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  46889. */
  46890. static ExtrudeShape(name: string, options: {
  46891. shape: Vector3[];
  46892. path: Vector3[];
  46893. scale?: number;
  46894. rotation?: number;
  46895. cap?: number;
  46896. updatable?: boolean;
  46897. sideOrientation?: number;
  46898. frontUVs?: Vector4;
  46899. backUVs?: Vector4;
  46900. instance?: Mesh;
  46901. invertUV?: boolean;
  46902. }, scene?: Nullable<Scene>): Mesh;
  46903. /**
  46904. * Creates an custom extruded shape mesh.
  46905. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  46906. * * 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.
  46907. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  46908. * * 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
  46909. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  46910. * * 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
  46911. * * It must returns a float value that will be the scale value applied to the shape on each path point
  46912. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  46913. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  46914. * * 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
  46915. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  46916. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  46917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46918. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46919. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46921. * @param name defines the name of the mesh
  46922. * @param options defines the options used to create the mesh
  46923. * @param scene defines the hosting scene
  46924. * @returns the custom extruded shape mesh
  46925. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  46926. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46927. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  46928. */
  46929. static ExtrudeShapeCustom(name: string, options: {
  46930. shape: Vector3[];
  46931. path: Vector3[];
  46932. scaleFunction?: any;
  46933. rotationFunction?: any;
  46934. ribbonCloseArray?: boolean;
  46935. ribbonClosePath?: boolean;
  46936. cap?: number;
  46937. updatable?: boolean;
  46938. sideOrientation?: number;
  46939. frontUVs?: Vector4;
  46940. backUVs?: Vector4;
  46941. instance?: Mesh;
  46942. invertUV?: boolean;
  46943. }, scene: Scene): Mesh;
  46944. private static _ExtrudeShapeGeneric;
  46945. }
  46946. }
  46947. declare module BABYLON {
  46948. /**
  46949. * Class containing static functions to help procedurally build meshes
  46950. */
  46951. export class LatheBuilder {
  46952. /**
  46953. * Creates lathe mesh.
  46954. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  46955. * * 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
  46956. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  46957. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  46958. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  46959. * * 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
  46960. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  46961. * * 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
  46962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46963. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46964. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46966. * @param name defines the name of the mesh
  46967. * @param options defines the options used to create the mesh
  46968. * @param scene defines the hosting scene
  46969. * @returns the lathe mesh
  46970. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  46971. */
  46972. static CreateLathe(name: string, options: {
  46973. shape: Vector3[];
  46974. radius?: number;
  46975. tessellation?: number;
  46976. clip?: number;
  46977. arc?: number;
  46978. closed?: boolean;
  46979. updatable?: boolean;
  46980. sideOrientation?: number;
  46981. frontUVs?: Vector4;
  46982. backUVs?: Vector4;
  46983. cap?: number;
  46984. invertUV?: boolean;
  46985. }, scene: Scene): Mesh;
  46986. }
  46987. }
  46988. declare module BABYLON {
  46989. /**
  46990. * Class containing static functions to help procedurally build meshes
  46991. */
  46992. export class TubeBuilder {
  46993. /**
  46994. * Creates a tube mesh.
  46995. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  46996. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  46997. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  46998. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  46999. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  47000. * * 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)
  47001. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  47002. * * 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
  47003. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  47004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47006. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47008. * @param name defines the name of the mesh
  47009. * @param options defines the options used to create the mesh
  47010. * @param scene defines the hosting scene
  47011. * @returns the tube mesh
  47012. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47013. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  47014. */
  47015. static CreateTube(name: string, options: {
  47016. path: Vector3[];
  47017. radius?: number;
  47018. tessellation?: number;
  47019. radiusFunction?: {
  47020. (i: number, distance: number): number;
  47021. };
  47022. cap?: number;
  47023. arc?: number;
  47024. updatable?: boolean;
  47025. sideOrientation?: number;
  47026. frontUVs?: Vector4;
  47027. backUVs?: Vector4;
  47028. instance?: Mesh;
  47029. invertUV?: boolean;
  47030. }, scene: Scene): Mesh;
  47031. }
  47032. }
  47033. declare module BABYLON {
  47034. /**
  47035. * Class containing static functions to help procedurally build meshes
  47036. */
  47037. export class IcoSphereBuilder {
  47038. /**
  47039. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  47040. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  47041. * * 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`)
  47042. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  47043. * * 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
  47044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47045. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47047. * @param name defines the name of the mesh
  47048. * @param options defines the options used to create the mesh
  47049. * @param scene defines the hosting scene
  47050. * @returns the icosahedron mesh
  47051. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  47052. */
  47053. static CreateIcoSphere(name: string, options: {
  47054. radius?: number;
  47055. radiusX?: number;
  47056. radiusY?: number;
  47057. radiusZ?: number;
  47058. flat?: boolean;
  47059. subdivisions?: number;
  47060. sideOrientation?: number;
  47061. frontUVs?: Vector4;
  47062. backUVs?: Vector4;
  47063. updatable?: boolean;
  47064. }, scene: Scene): Mesh;
  47065. }
  47066. }
  47067. declare module BABYLON {
  47068. /**
  47069. * Class containing static functions to help procedurally build meshes
  47070. */
  47071. export class DecalBuilder {
  47072. /**
  47073. * Creates a decal mesh.
  47074. * 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
  47075. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  47076. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  47077. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  47078. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  47079. * @param name defines the name of the mesh
  47080. * @param sourceMesh defines the mesh where the decal must be applied
  47081. * @param options defines the options used to create the mesh
  47082. * @param scene defines the hosting scene
  47083. * @returns the decal mesh
  47084. * @see https://doc.babylonjs.com/how_to/decals
  47085. */
  47086. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  47087. position?: Vector3;
  47088. normal?: Vector3;
  47089. size?: Vector3;
  47090. angle?: number;
  47091. }): Mesh;
  47092. }
  47093. }
  47094. declare module BABYLON {
  47095. /**
  47096. * Class containing static functions to help procedurally build meshes
  47097. */
  47098. export class MeshBuilder {
  47099. /**
  47100. * Creates a box mesh
  47101. * * The parameter `size` sets the size (float) of each box side (default 1)
  47102. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47103. * * 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)
  47104. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47106. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47108. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47109. * @param name defines the name of the mesh
  47110. * @param options defines the options used to create the mesh
  47111. * @param scene defines the hosting scene
  47112. * @returns the box mesh
  47113. */
  47114. static CreateBox(name: string, options: {
  47115. size?: number;
  47116. width?: number;
  47117. height?: number;
  47118. depth?: number;
  47119. faceUV?: Vector4[];
  47120. faceColors?: Color4[];
  47121. sideOrientation?: number;
  47122. frontUVs?: Vector4;
  47123. backUVs?: Vector4;
  47124. updatable?: boolean;
  47125. }, scene?: Nullable<Scene>): Mesh;
  47126. /**
  47127. * Creates a sphere mesh
  47128. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47129. * * 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`)
  47130. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47131. * * 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
  47132. * * 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)
  47133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47134. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47136. * @param name defines the name of the mesh
  47137. * @param options defines the options used to create the mesh
  47138. * @param scene defines the hosting scene
  47139. * @returns the sphere mesh
  47140. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47141. */
  47142. static CreateSphere(name: string, options: {
  47143. segments?: number;
  47144. diameter?: number;
  47145. diameterX?: number;
  47146. diameterY?: number;
  47147. diameterZ?: number;
  47148. arc?: number;
  47149. slice?: number;
  47150. sideOrientation?: number;
  47151. frontUVs?: Vector4;
  47152. backUVs?: Vector4;
  47153. updatable?: boolean;
  47154. }, scene: any): Mesh;
  47155. /**
  47156. * Creates a plane polygonal mesh. By default, this is a disc
  47157. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  47158. * * 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
  47159. * * 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
  47160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47161. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47163. * @param name defines the name of the mesh
  47164. * @param options defines the options used to create the mesh
  47165. * @param scene defines the hosting scene
  47166. * @returns the plane polygonal mesh
  47167. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  47168. */
  47169. static CreateDisc(name: string, options: {
  47170. radius?: number;
  47171. tessellation?: number;
  47172. arc?: number;
  47173. updatable?: boolean;
  47174. sideOrientation?: number;
  47175. frontUVs?: Vector4;
  47176. backUVs?: Vector4;
  47177. }, scene?: Nullable<Scene>): Mesh;
  47178. /**
  47179. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  47180. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  47181. * * 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`)
  47182. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  47183. * * 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
  47184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47185. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47187. * @param name defines the name of the mesh
  47188. * @param options defines the options used to create the mesh
  47189. * @param scene defines the hosting scene
  47190. * @returns the icosahedron mesh
  47191. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  47192. */
  47193. static CreateIcoSphere(name: string, options: {
  47194. radius?: number;
  47195. radiusX?: number;
  47196. radiusY?: number;
  47197. radiusZ?: number;
  47198. flat?: boolean;
  47199. subdivisions?: number;
  47200. sideOrientation?: number;
  47201. frontUVs?: Vector4;
  47202. backUVs?: Vector4;
  47203. updatable?: boolean;
  47204. }, scene: Scene): Mesh;
  47205. /**
  47206. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47207. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  47208. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  47209. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  47210. * * 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
  47211. * * 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
  47212. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  47213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47214. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47215. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47216. * * 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
  47217. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  47218. * * 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
  47219. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  47220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47221. * @param name defines the name of the mesh
  47222. * @param options defines the options used to create the mesh
  47223. * @param scene defines the hosting scene
  47224. * @returns the ribbon mesh
  47225. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  47226. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47227. */
  47228. static CreateRibbon(name: string, options: {
  47229. pathArray: Vector3[][];
  47230. closeArray?: boolean;
  47231. closePath?: boolean;
  47232. offset?: number;
  47233. updatable?: boolean;
  47234. sideOrientation?: number;
  47235. frontUVs?: Vector4;
  47236. backUVs?: Vector4;
  47237. instance?: Mesh;
  47238. invertUV?: boolean;
  47239. uvs?: Vector2[];
  47240. colors?: Color4[];
  47241. }, scene?: Nullable<Scene>): Mesh;
  47242. /**
  47243. * Creates a cylinder or a cone mesh
  47244. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  47245. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  47246. * * 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.
  47247. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  47248. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  47249. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  47250. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  47251. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  47252. * * 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).
  47253. * * 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
  47254. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  47255. * * 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
  47256. * * 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.
  47257. * * If `enclose` is false, a ring surface is one element.
  47258. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  47259. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  47260. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47261. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47263. * @param name defines the name of the mesh
  47264. * @param options defines the options used to create the mesh
  47265. * @param scene defines the hosting scene
  47266. * @returns the cylinder mesh
  47267. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  47268. */
  47269. static CreateCylinder(name: string, options: {
  47270. height?: number;
  47271. diameterTop?: number;
  47272. diameterBottom?: number;
  47273. diameter?: number;
  47274. tessellation?: number;
  47275. subdivisions?: number;
  47276. arc?: number;
  47277. faceColors?: Color4[];
  47278. faceUV?: Vector4[];
  47279. updatable?: boolean;
  47280. hasRings?: boolean;
  47281. enclose?: boolean;
  47282. sideOrientation?: number;
  47283. frontUVs?: Vector4;
  47284. backUVs?: Vector4;
  47285. }, scene: any): Mesh;
  47286. /**
  47287. * Creates a torus mesh
  47288. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  47289. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  47290. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  47291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47292. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47294. * @param name defines the name of the mesh
  47295. * @param options defines the options used to create the mesh
  47296. * @param scene defines the hosting scene
  47297. * @returns the torus mesh
  47298. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  47299. */
  47300. static CreateTorus(name: string, options: {
  47301. diameter?: number;
  47302. thickness?: number;
  47303. tessellation?: number;
  47304. updatable?: boolean;
  47305. sideOrientation?: number;
  47306. frontUVs?: Vector4;
  47307. backUVs?: Vector4;
  47308. }, scene: any): Mesh;
  47309. /**
  47310. * Creates a torus knot mesh
  47311. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  47312. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  47313. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  47314. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  47315. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47316. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47318. * @param name defines the name of the mesh
  47319. * @param options defines the options used to create the mesh
  47320. * @param scene defines the hosting scene
  47321. * @returns the torus knot mesh
  47322. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  47323. */
  47324. static CreateTorusKnot(name: string, options: {
  47325. radius?: number;
  47326. tube?: number;
  47327. radialSegments?: number;
  47328. tubularSegments?: number;
  47329. p?: number;
  47330. q?: number;
  47331. updatable?: boolean;
  47332. sideOrientation?: number;
  47333. frontUVs?: Vector4;
  47334. backUVs?: Vector4;
  47335. }, scene: any): Mesh;
  47336. /**
  47337. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47338. * * 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
  47339. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47340. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47341. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47342. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47343. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47344. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  47345. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47347. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47348. * @param name defines the name of the new line system
  47349. * @param options defines the options used to create the line system
  47350. * @param scene defines the hosting scene
  47351. * @returns a new line system mesh
  47352. */
  47353. static CreateLineSystem(name: string, options: {
  47354. lines: Vector3[][];
  47355. updatable?: boolean;
  47356. instance?: Nullable<LinesMesh>;
  47357. colors?: Nullable<Color4[][]>;
  47358. useVertexAlpha?: boolean;
  47359. }, scene: Nullable<Scene>): LinesMesh;
  47360. /**
  47361. * Creates a line mesh
  47362. * 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
  47363. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47364. * * The parameter `points` is an array successive Vector3
  47365. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  47366. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47367. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47368. * * When updating an instance, remember that only point positions can change, not the number of points
  47369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47370. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47371. * @param name defines the name of the new line system
  47372. * @param options defines the options used to create the line system
  47373. * @param scene defines the hosting scene
  47374. * @returns a new line mesh
  47375. */
  47376. static CreateLines(name: string, options: {
  47377. points: Vector3[];
  47378. updatable?: boolean;
  47379. instance?: Nullable<LinesMesh>;
  47380. colors?: Color4[];
  47381. useVertexAlpha?: boolean;
  47382. }, scene?: Nullable<Scene>): LinesMesh;
  47383. /**
  47384. * Creates a dashed line mesh
  47385. * * 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
  47386. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47387. * * The parameter `points` is an array successive Vector3
  47388. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47389. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47390. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47391. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  47392. * * When updating an instance, remember that only point positions can change, not the number of points
  47393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47394. * @param name defines the name of the mesh
  47395. * @param options defines the options used to create the mesh
  47396. * @param scene defines the hosting scene
  47397. * @returns the dashed line mesh
  47398. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47399. */
  47400. static CreateDashedLines(name: string, options: {
  47401. points: Vector3[];
  47402. dashSize?: number;
  47403. gapSize?: number;
  47404. dashNb?: number;
  47405. updatable?: boolean;
  47406. instance?: LinesMesh;
  47407. }, scene?: Nullable<Scene>): LinesMesh;
  47408. /**
  47409. * 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.
  47410. * * 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.
  47411. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47412. * * 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.
  47413. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  47414. * * 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
  47415. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  47416. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  47417. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47418. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47419. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  47420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47421. * @param name defines the name of the mesh
  47422. * @param options defines the options used to create the mesh
  47423. * @param scene defines the hosting scene
  47424. * @returns the extruded shape mesh
  47425. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47426. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47427. */
  47428. static ExtrudeShape(name: string, options: {
  47429. shape: Vector3[];
  47430. path: Vector3[];
  47431. scale?: number;
  47432. rotation?: number;
  47433. cap?: number;
  47434. updatable?: boolean;
  47435. sideOrientation?: number;
  47436. frontUVs?: Vector4;
  47437. backUVs?: Vector4;
  47438. instance?: Mesh;
  47439. invertUV?: boolean;
  47440. }, scene?: Nullable<Scene>): Mesh;
  47441. /**
  47442. * Creates an custom extruded shape mesh.
  47443. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  47444. * * 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.
  47445. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47446. * * 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
  47447. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  47448. * * 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
  47449. * * It must returns a float value that will be the scale value applied to the shape on each path point
  47450. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  47451. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  47452. * * 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
  47453. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  47454. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  47455. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47456. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47457. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47459. * @param name defines the name of the mesh
  47460. * @param options defines the options used to create the mesh
  47461. * @param scene defines the hosting scene
  47462. * @returns the custom extruded shape mesh
  47463. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  47464. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47465. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47466. */
  47467. static ExtrudeShapeCustom(name: string, options: {
  47468. shape: Vector3[];
  47469. path: Vector3[];
  47470. scaleFunction?: any;
  47471. rotationFunction?: any;
  47472. ribbonCloseArray?: boolean;
  47473. ribbonClosePath?: boolean;
  47474. cap?: number;
  47475. updatable?: boolean;
  47476. sideOrientation?: number;
  47477. frontUVs?: Vector4;
  47478. backUVs?: Vector4;
  47479. instance?: Mesh;
  47480. invertUV?: boolean;
  47481. }, scene: Scene): Mesh;
  47482. /**
  47483. * Creates lathe mesh.
  47484. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  47485. * * 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
  47486. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  47487. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  47488. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  47489. * * 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
  47490. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  47491. * * 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
  47492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47493. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47494. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47496. * @param name defines the name of the mesh
  47497. * @param options defines the options used to create the mesh
  47498. * @param scene defines the hosting scene
  47499. * @returns the lathe mesh
  47500. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  47501. */
  47502. static CreateLathe(name: string, options: {
  47503. shape: Vector3[];
  47504. radius?: number;
  47505. tessellation?: number;
  47506. clip?: number;
  47507. arc?: number;
  47508. closed?: boolean;
  47509. updatable?: boolean;
  47510. sideOrientation?: number;
  47511. frontUVs?: Vector4;
  47512. backUVs?: Vector4;
  47513. cap?: number;
  47514. invertUV?: boolean;
  47515. }, scene: Scene): Mesh;
  47516. /**
  47517. * Creates a plane mesh
  47518. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  47519. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  47520. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  47521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47522. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47524. * @param name defines the name of the mesh
  47525. * @param options defines the options used to create the mesh
  47526. * @param scene defines the hosting scene
  47527. * @returns the plane mesh
  47528. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  47529. */
  47530. static CreatePlane(name: string, options: {
  47531. size?: number;
  47532. width?: number;
  47533. height?: number;
  47534. sideOrientation?: number;
  47535. frontUVs?: Vector4;
  47536. backUVs?: Vector4;
  47537. updatable?: boolean;
  47538. sourcePlane?: Plane;
  47539. }, scene: Scene): Mesh;
  47540. /**
  47541. * Creates a ground mesh
  47542. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  47543. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  47544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47545. * @param name defines the name of the mesh
  47546. * @param options defines the options used to create the mesh
  47547. * @param scene defines the hosting scene
  47548. * @returns the ground mesh
  47549. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  47550. */
  47551. static CreateGround(name: string, options: {
  47552. width?: number;
  47553. height?: number;
  47554. subdivisions?: number;
  47555. subdivisionsX?: number;
  47556. subdivisionsY?: number;
  47557. updatable?: boolean;
  47558. }, scene: any): Mesh;
  47559. /**
  47560. * Creates a tiled ground mesh
  47561. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  47562. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  47563. * * 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
  47564. * * 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
  47565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47566. * @param name defines the name of the mesh
  47567. * @param options defines the options used to create the mesh
  47568. * @param scene defines the hosting scene
  47569. * @returns the tiled ground mesh
  47570. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  47571. */
  47572. static CreateTiledGround(name: string, options: {
  47573. xmin: number;
  47574. zmin: number;
  47575. xmax: number;
  47576. zmax: number;
  47577. subdivisions?: {
  47578. w: number;
  47579. h: number;
  47580. };
  47581. precision?: {
  47582. w: number;
  47583. h: number;
  47584. };
  47585. updatable?: boolean;
  47586. }, scene: Scene): Mesh;
  47587. /**
  47588. * Creates a ground mesh from a height map
  47589. * * The parameter `url` sets the URL of the height map image resource.
  47590. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  47591. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  47592. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  47593. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  47594. * * 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.
  47595. * * 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).
  47596. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  47597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47598. * @param name defines the name of the mesh
  47599. * @param url defines the url to the height map
  47600. * @param options defines the options used to create the mesh
  47601. * @param scene defines the hosting scene
  47602. * @returns the ground mesh
  47603. * @see https://doc.babylonjs.com/babylon101/height_map
  47604. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  47605. */
  47606. static CreateGroundFromHeightMap(name: string, url: string, options: {
  47607. width?: number;
  47608. height?: number;
  47609. subdivisions?: number;
  47610. minHeight?: number;
  47611. maxHeight?: number;
  47612. colorFilter?: Color3;
  47613. alphaFilter?: number;
  47614. updatable?: boolean;
  47615. onReady?: (mesh: GroundMesh) => void;
  47616. }, scene: Scene): GroundMesh;
  47617. /**
  47618. * Creates a polygon mesh
  47619. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  47620. * * 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
  47621. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  47622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47623. * * 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)
  47624. * * Remember you can only change the shape positions, not their number when updating a polygon
  47625. * @param name defines the name of the mesh
  47626. * @param options defines the options used to create the mesh
  47627. * @param scene defines the hosting scene
  47628. * @param earcutInjection can be used to inject your own earcut reference
  47629. * @returns the polygon mesh
  47630. */
  47631. static CreatePolygon(name: string, options: {
  47632. shape: Vector3[];
  47633. holes?: Vector3[][];
  47634. depth?: number;
  47635. faceUV?: Vector4[];
  47636. faceColors?: Color4[];
  47637. updatable?: boolean;
  47638. sideOrientation?: number;
  47639. frontUVs?: Vector4;
  47640. backUVs?: Vector4;
  47641. }, scene: Scene, earcutInjection?: any): Mesh;
  47642. /**
  47643. * Creates an extruded polygon mesh, with depth in the Y direction.
  47644. * * 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)
  47645. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47646. * @param name defines the name of the mesh
  47647. * @param options defines the options used to create the mesh
  47648. * @param scene defines the hosting scene
  47649. * @param earcutInjection can be used to inject your own earcut reference
  47650. * @returns the polygon mesh
  47651. */
  47652. static ExtrudePolygon(name: string, options: {
  47653. shape: Vector3[];
  47654. holes?: Vector3[][];
  47655. depth?: number;
  47656. faceUV?: Vector4[];
  47657. faceColors?: Color4[];
  47658. updatable?: boolean;
  47659. sideOrientation?: number;
  47660. frontUVs?: Vector4;
  47661. backUVs?: Vector4;
  47662. }, scene: Scene, earcutInjection?: any): Mesh;
  47663. /**
  47664. * Creates a tube mesh.
  47665. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47666. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  47667. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  47668. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  47669. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  47670. * * 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)
  47671. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  47672. * * 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
  47673. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  47674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47675. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47676. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47678. * @param name defines the name of the mesh
  47679. * @param options defines the options used to create the mesh
  47680. * @param scene defines the hosting scene
  47681. * @returns the tube mesh
  47682. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47683. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  47684. */
  47685. static CreateTube(name: string, options: {
  47686. path: Vector3[];
  47687. radius?: number;
  47688. tessellation?: number;
  47689. radiusFunction?: {
  47690. (i: number, distance: number): number;
  47691. };
  47692. cap?: number;
  47693. arc?: number;
  47694. updatable?: boolean;
  47695. sideOrientation?: number;
  47696. frontUVs?: Vector4;
  47697. backUVs?: Vector4;
  47698. instance?: Mesh;
  47699. invertUV?: boolean;
  47700. }, scene: Scene): Mesh;
  47701. /**
  47702. * Creates a polyhedron mesh
  47703. * * 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
  47704. * * The parameter `size` (positive float, default 1) sets the polygon size
  47705. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47706. * * 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`
  47707. * * 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
  47708. * * 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)`)
  47709. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47710. * * 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
  47711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47712. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47714. * @param name defines the name of the mesh
  47715. * @param options defines the options used to create the mesh
  47716. * @param scene defines the hosting scene
  47717. * @returns the polyhedron mesh
  47718. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47719. */
  47720. static CreatePolyhedron(name: string, options: {
  47721. type?: number;
  47722. size?: number;
  47723. sizeX?: number;
  47724. sizeY?: number;
  47725. sizeZ?: number;
  47726. custom?: any;
  47727. faceUV?: Vector4[];
  47728. faceColors?: Color4[];
  47729. flat?: boolean;
  47730. updatable?: boolean;
  47731. sideOrientation?: number;
  47732. frontUVs?: Vector4;
  47733. backUVs?: Vector4;
  47734. }, scene: Scene): Mesh;
  47735. /**
  47736. * Creates a decal mesh.
  47737. * 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
  47738. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  47739. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  47740. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  47741. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  47742. * @param name defines the name of the mesh
  47743. * @param sourceMesh defines the mesh where the decal must be applied
  47744. * @param options defines the options used to create the mesh
  47745. * @param scene defines the hosting scene
  47746. * @returns the decal mesh
  47747. * @see https://doc.babylonjs.com/how_to/decals
  47748. */
  47749. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  47750. position?: Vector3;
  47751. normal?: Vector3;
  47752. size?: Vector3;
  47753. angle?: number;
  47754. }): Mesh;
  47755. }
  47756. }
  47757. declare module BABYLON {
  47758. /**
  47759. * A simplifier interface for future simplification implementations
  47760. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47761. */
  47762. export interface ISimplifier {
  47763. /**
  47764. * Simplification of a given mesh according to the given settings.
  47765. * Since this requires computation, it is assumed that the function runs async.
  47766. * @param settings The settings of the simplification, including quality and distance
  47767. * @param successCallback A callback that will be called after the mesh was simplified.
  47768. * @param errorCallback in case of an error, this callback will be called. optional.
  47769. */
  47770. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  47771. }
  47772. /**
  47773. * Expected simplification settings.
  47774. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  47775. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47776. */
  47777. export interface ISimplificationSettings {
  47778. /**
  47779. * Gets or sets the expected quality
  47780. */
  47781. quality: number;
  47782. /**
  47783. * Gets or sets the distance when this optimized version should be used
  47784. */
  47785. distance: number;
  47786. /**
  47787. * Gets an already optimized mesh
  47788. */
  47789. optimizeMesh?: boolean;
  47790. }
  47791. /**
  47792. * Class used to specify simplification options
  47793. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47794. */
  47795. export class SimplificationSettings implements ISimplificationSettings {
  47796. /** expected quality */
  47797. quality: number;
  47798. /** distance when this optimized version should be used */
  47799. distance: number;
  47800. /** already optimized mesh */
  47801. optimizeMesh?: boolean | undefined;
  47802. /**
  47803. * Creates a SimplificationSettings
  47804. * @param quality expected quality
  47805. * @param distance distance when this optimized version should be used
  47806. * @param optimizeMesh already optimized mesh
  47807. */
  47808. constructor(
  47809. /** expected quality */
  47810. quality: number,
  47811. /** distance when this optimized version should be used */
  47812. distance: number,
  47813. /** already optimized mesh */
  47814. optimizeMesh?: boolean | undefined);
  47815. }
  47816. /**
  47817. * Interface used to define a simplification task
  47818. */
  47819. export interface ISimplificationTask {
  47820. /**
  47821. * Array of settings
  47822. */
  47823. settings: Array<ISimplificationSettings>;
  47824. /**
  47825. * Simplification type
  47826. */
  47827. simplificationType: SimplificationType;
  47828. /**
  47829. * Mesh to simplify
  47830. */
  47831. mesh: Mesh;
  47832. /**
  47833. * Callback called on success
  47834. */
  47835. successCallback?: () => void;
  47836. /**
  47837. * Defines if parallel processing can be used
  47838. */
  47839. parallelProcessing: boolean;
  47840. }
  47841. /**
  47842. * Queue used to order the simplification tasks
  47843. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47844. */
  47845. export class SimplificationQueue {
  47846. private _simplificationArray;
  47847. /**
  47848. * Gets a boolean indicating that the process is still running
  47849. */
  47850. running: boolean;
  47851. /**
  47852. * Creates a new queue
  47853. */
  47854. constructor();
  47855. /**
  47856. * Adds a new simplification task
  47857. * @param task defines a task to add
  47858. */
  47859. addTask(task: ISimplificationTask): void;
  47860. /**
  47861. * Execute next task
  47862. */
  47863. executeNext(): void;
  47864. /**
  47865. * Execute a simplification task
  47866. * @param task defines the task to run
  47867. */
  47868. runSimplification(task: ISimplificationTask): void;
  47869. private getSimplifier;
  47870. }
  47871. /**
  47872. * The implemented types of simplification
  47873. * At the moment only Quadratic Error Decimation is implemented
  47874. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47875. */
  47876. export enum SimplificationType {
  47877. /** Quadratic error decimation */
  47878. QUADRATIC = 0
  47879. }
  47880. }
  47881. declare module BABYLON {
  47882. interface Scene {
  47883. /** @hidden (Backing field) */
  47884. _simplificationQueue: SimplificationQueue;
  47885. /**
  47886. * Gets or sets the simplification queue attached to the scene
  47887. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47888. */
  47889. simplificationQueue: SimplificationQueue;
  47890. }
  47891. interface Mesh {
  47892. /**
  47893. * Simplify the mesh according to the given array of settings.
  47894. * Function will return immediately and will simplify async
  47895. * @param settings a collection of simplification settings
  47896. * @param parallelProcessing should all levels calculate parallel or one after the other
  47897. * @param simplificationType the type of simplification to run
  47898. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  47899. * @returns the current mesh
  47900. */
  47901. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  47902. }
  47903. /**
  47904. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  47905. * created in a scene
  47906. */
  47907. export class SimplicationQueueSceneComponent implements ISceneComponent {
  47908. /**
  47909. * The component name helpfull to identify the component in the list of scene components.
  47910. */
  47911. readonly name: string;
  47912. /**
  47913. * The scene the component belongs to.
  47914. */
  47915. scene: Scene;
  47916. /**
  47917. * Creates a new instance of the component for the given scene
  47918. * @param scene Defines the scene to register the component in
  47919. */
  47920. constructor(scene: Scene);
  47921. /**
  47922. * Registers the component in a given scene
  47923. */
  47924. register(): void;
  47925. /**
  47926. * Rebuilds the elements related to this component in case of
  47927. * context lost for instance.
  47928. */
  47929. rebuild(): void;
  47930. /**
  47931. * Disposes the component and the associated ressources
  47932. */
  47933. dispose(): void;
  47934. private _beforeCameraUpdate;
  47935. }
  47936. }
  47937. declare module BABYLON {
  47938. /**
  47939. * Class used to enable access to IndexedDB
  47940. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  47941. */
  47942. export class Database implements IOfflineProvider {
  47943. private _callbackManifestChecked;
  47944. private _currentSceneUrl;
  47945. private _db;
  47946. private _enableSceneOffline;
  47947. private _enableTexturesOffline;
  47948. private _manifestVersionFound;
  47949. private _mustUpdateRessources;
  47950. private _hasReachedQuota;
  47951. private _isSupported;
  47952. private _idbFactory;
  47953. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  47954. private static IsUASupportingBlobStorage;
  47955. /**
  47956. * Gets a boolean indicating if Database storate is enabled (off by default)
  47957. */
  47958. static IDBStorageEnabled: boolean;
  47959. /**
  47960. * Gets a boolean indicating if scene must be saved in the database
  47961. */
  47962. readonly enableSceneOffline: boolean;
  47963. /**
  47964. * Gets a boolean indicating if textures must be saved in the database
  47965. */
  47966. readonly enableTexturesOffline: boolean;
  47967. /**
  47968. * Creates a new Database
  47969. * @param urlToScene defines the url to load the scene
  47970. * @param callbackManifestChecked defines the callback to use when manifest is checked
  47971. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  47972. */
  47973. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  47974. private static _ParseURL;
  47975. private static _ReturnFullUrlLocation;
  47976. private _checkManifestFile;
  47977. /**
  47978. * Open the database and make it available
  47979. * @param successCallback defines the callback to call on success
  47980. * @param errorCallback defines the callback to call on error
  47981. */
  47982. open(successCallback: () => void, errorCallback: () => void): void;
  47983. /**
  47984. * Loads an image from the database
  47985. * @param url defines the url to load from
  47986. * @param image defines the target DOM image
  47987. */
  47988. loadImage(url: string, image: HTMLImageElement): void;
  47989. private _loadImageFromDBAsync;
  47990. private _saveImageIntoDBAsync;
  47991. private _checkVersionFromDB;
  47992. private _loadVersionFromDBAsync;
  47993. private _saveVersionIntoDBAsync;
  47994. /**
  47995. * Loads a file from database
  47996. * @param url defines the URL to load from
  47997. * @param sceneLoaded defines a callback to call on success
  47998. * @param progressCallBack defines a callback to call when progress changed
  47999. * @param errorCallback defines a callback to call on error
  48000. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  48001. */
  48002. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  48003. private _loadFileAsync;
  48004. private _saveFileAsync;
  48005. /**
  48006. * Validates if xhr data is correct
  48007. * @param xhr defines the request to validate
  48008. * @param dataType defines the expected data type
  48009. * @returns true if data is correct
  48010. */
  48011. private static _ValidateXHRData;
  48012. }
  48013. }
  48014. declare module BABYLON {
  48015. /** @hidden */
  48016. export var gpuUpdateParticlesPixelShader: {
  48017. name: string;
  48018. shader: string;
  48019. };
  48020. }
  48021. declare module BABYLON {
  48022. /** @hidden */
  48023. export var gpuUpdateParticlesVertexShader: {
  48024. name: string;
  48025. shader: string;
  48026. };
  48027. }
  48028. declare module BABYLON {
  48029. /** @hidden */
  48030. export var clipPlaneFragmentDeclaration2: {
  48031. name: string;
  48032. shader: string;
  48033. };
  48034. }
  48035. declare module BABYLON {
  48036. /** @hidden */
  48037. export var gpuRenderParticlesPixelShader: {
  48038. name: string;
  48039. shader: string;
  48040. };
  48041. }
  48042. declare module BABYLON {
  48043. /** @hidden */
  48044. export var clipPlaneVertexDeclaration2: {
  48045. name: string;
  48046. shader: string;
  48047. };
  48048. }
  48049. declare module BABYLON {
  48050. /** @hidden */
  48051. export var gpuRenderParticlesVertexShader: {
  48052. name: string;
  48053. shader: string;
  48054. };
  48055. }
  48056. declare module BABYLON {
  48057. /**
  48058. * This represents a GPU particle system in Babylon
  48059. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  48060. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  48061. */
  48062. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  48063. /**
  48064. * The layer mask we are rendering the particles through.
  48065. */
  48066. layerMask: number;
  48067. private _capacity;
  48068. private _activeCount;
  48069. private _currentActiveCount;
  48070. private _accumulatedCount;
  48071. private _renderEffect;
  48072. private _updateEffect;
  48073. private _buffer0;
  48074. private _buffer1;
  48075. private _spriteBuffer;
  48076. private _updateVAO;
  48077. private _renderVAO;
  48078. private _targetIndex;
  48079. private _sourceBuffer;
  48080. private _targetBuffer;
  48081. private _engine;
  48082. private _currentRenderId;
  48083. private _started;
  48084. private _stopped;
  48085. private _timeDelta;
  48086. private _randomTexture;
  48087. private _randomTexture2;
  48088. private _attributesStrideSize;
  48089. private _updateEffectOptions;
  48090. private _randomTextureSize;
  48091. private _actualFrame;
  48092. private readonly _rawTextureWidth;
  48093. /**
  48094. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  48095. */
  48096. static readonly IsSupported: boolean;
  48097. /**
  48098. * An event triggered when the system is disposed.
  48099. */
  48100. onDisposeObservable: Observable<GPUParticleSystem>;
  48101. /**
  48102. * Gets the maximum number of particles active at the same time.
  48103. * @returns The max number of active particles.
  48104. */
  48105. getCapacity(): number;
  48106. /**
  48107. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  48108. * to override the particles.
  48109. */
  48110. forceDepthWrite: boolean;
  48111. /**
  48112. * Gets or set the number of active particles
  48113. */
  48114. activeParticleCount: number;
  48115. private _preWarmDone;
  48116. /**
  48117. * Is this system ready to be used/rendered
  48118. * @return true if the system is ready
  48119. */
  48120. isReady(): boolean;
  48121. /**
  48122. * Gets if the system has been started. (Note: this will still be true after stop is called)
  48123. * @returns True if it has been started, otherwise false.
  48124. */
  48125. isStarted(): boolean;
  48126. /**
  48127. * Starts the particle system and begins to emit
  48128. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  48129. */
  48130. start(delay?: number): void;
  48131. /**
  48132. * Stops the particle system.
  48133. */
  48134. stop(): void;
  48135. /**
  48136. * Remove all active particles
  48137. */
  48138. reset(): void;
  48139. /**
  48140. * Returns the string "GPUParticleSystem"
  48141. * @returns a string containing the class name
  48142. */
  48143. getClassName(): string;
  48144. private _colorGradientsTexture;
  48145. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  48146. /**
  48147. * Adds a new color gradient
  48148. * @param gradient defines the gradient to use (between 0 and 1)
  48149. * @param color1 defines the color to affect to the specified gradient
  48150. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  48151. * @returns the current particle system
  48152. */
  48153. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  48154. /**
  48155. * Remove a specific color gradient
  48156. * @param gradient defines the gradient to remove
  48157. * @returns the current particle system
  48158. */
  48159. removeColorGradient(gradient: number): GPUParticleSystem;
  48160. private _angularSpeedGradientsTexture;
  48161. private _sizeGradientsTexture;
  48162. private _velocityGradientsTexture;
  48163. private _limitVelocityGradientsTexture;
  48164. private _dragGradientsTexture;
  48165. private _addFactorGradient;
  48166. /**
  48167. * Adds a new size gradient
  48168. * @param gradient defines the gradient to use (between 0 and 1)
  48169. * @param factor defines the size factor to affect to the specified gradient
  48170. * @returns the current particle system
  48171. */
  48172. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  48173. /**
  48174. * Remove a specific size gradient
  48175. * @param gradient defines the gradient to remove
  48176. * @returns the current particle system
  48177. */
  48178. removeSizeGradient(gradient: number): GPUParticleSystem;
  48179. /**
  48180. * Adds a new angular speed gradient
  48181. * @param gradient defines the gradient to use (between 0 and 1)
  48182. * @param factor defines the angular speed to affect to the specified gradient
  48183. * @returns the current particle system
  48184. */
  48185. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  48186. /**
  48187. * Remove a specific angular speed gradient
  48188. * @param gradient defines the gradient to remove
  48189. * @returns the current particle system
  48190. */
  48191. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  48192. /**
  48193. * Adds a new velocity gradient
  48194. * @param gradient defines the gradient to use (between 0 and 1)
  48195. * @param factor defines the velocity to affect to the specified gradient
  48196. * @returns the current particle system
  48197. */
  48198. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  48199. /**
  48200. * Remove a specific velocity gradient
  48201. * @param gradient defines the gradient to remove
  48202. * @returns the current particle system
  48203. */
  48204. removeVelocityGradient(gradient: number): GPUParticleSystem;
  48205. /**
  48206. * Adds a new limit velocity gradient
  48207. * @param gradient defines the gradient to use (between 0 and 1)
  48208. * @param factor defines the limit velocity value to affect to the specified gradient
  48209. * @returns the current particle system
  48210. */
  48211. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  48212. /**
  48213. * Remove a specific limit velocity gradient
  48214. * @param gradient defines the gradient to remove
  48215. * @returns the current particle system
  48216. */
  48217. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  48218. /**
  48219. * Adds a new drag gradient
  48220. * @param gradient defines the gradient to use (between 0 and 1)
  48221. * @param factor defines the drag value to affect to the specified gradient
  48222. * @returns the current particle system
  48223. */
  48224. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  48225. /**
  48226. * Remove a specific drag gradient
  48227. * @param gradient defines the gradient to remove
  48228. * @returns the current particle system
  48229. */
  48230. removeDragGradient(gradient: number): GPUParticleSystem;
  48231. /**
  48232. * Not supported by GPUParticleSystem
  48233. * @param gradient defines the gradient to use (between 0 and 1)
  48234. * @param factor defines the emit rate value to affect to the specified gradient
  48235. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  48236. * @returns the current particle system
  48237. */
  48238. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  48239. /**
  48240. * Not supported by GPUParticleSystem
  48241. * @param gradient defines the gradient to remove
  48242. * @returns the current particle system
  48243. */
  48244. removeEmitRateGradient(gradient: number): IParticleSystem;
  48245. /**
  48246. * Not supported by GPUParticleSystem
  48247. * @param gradient defines the gradient to use (between 0 and 1)
  48248. * @param factor defines the start size value to affect to the specified gradient
  48249. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  48250. * @returns the current particle system
  48251. */
  48252. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  48253. /**
  48254. * Not supported by GPUParticleSystem
  48255. * @param gradient defines the gradient to remove
  48256. * @returns the current particle system
  48257. */
  48258. removeStartSizeGradient(gradient: number): IParticleSystem;
  48259. /**
  48260. * Not supported by GPUParticleSystem
  48261. * @param gradient defines the gradient to use (between 0 and 1)
  48262. * @param min defines the color remap minimal range
  48263. * @param max defines the color remap maximal range
  48264. * @returns the current particle system
  48265. */
  48266. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  48267. /**
  48268. * Not supported by GPUParticleSystem
  48269. * @param gradient defines the gradient to remove
  48270. * @returns the current particle system
  48271. */
  48272. removeColorRemapGradient(): IParticleSystem;
  48273. /**
  48274. * Not supported by GPUParticleSystem
  48275. * @param gradient defines the gradient to use (between 0 and 1)
  48276. * @param min defines the alpha remap minimal range
  48277. * @param max defines the alpha remap maximal range
  48278. * @returns the current particle system
  48279. */
  48280. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  48281. /**
  48282. * Not supported by GPUParticleSystem
  48283. * @param gradient defines the gradient to remove
  48284. * @returns the current particle system
  48285. */
  48286. removeAlphaRemapGradient(): IParticleSystem;
  48287. /**
  48288. * Not supported by GPUParticleSystem
  48289. * @param gradient defines the gradient to use (between 0 and 1)
  48290. * @param color defines the color to affect to the specified gradient
  48291. * @returns the current particle system
  48292. */
  48293. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  48294. /**
  48295. * Not supported by GPUParticleSystem
  48296. * @param gradient defines the gradient to remove
  48297. * @returns the current particle system
  48298. */
  48299. removeRampGradient(): IParticleSystem;
  48300. /**
  48301. * Not supported by GPUParticleSystem
  48302. * @returns the list of ramp gradients
  48303. */
  48304. getRampGradients(): Nullable<Array<Color3Gradient>>;
  48305. /**
  48306. * Not supported by GPUParticleSystem
  48307. * Gets or sets a boolean indicating that ramp gradients must be used
  48308. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  48309. */
  48310. useRampGradients: boolean;
  48311. /**
  48312. * Not supported by GPUParticleSystem
  48313. * @param gradient defines the gradient to use (between 0 and 1)
  48314. * @param factor defines the life time factor to affect to the specified gradient
  48315. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  48316. * @returns the current particle system
  48317. */
  48318. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  48319. /**
  48320. * Not supported by GPUParticleSystem
  48321. * @param gradient defines the gradient to remove
  48322. * @returns the current particle system
  48323. */
  48324. removeLifeTimeGradient(gradient: number): IParticleSystem;
  48325. /**
  48326. * Instantiates a GPU particle system.
  48327. * 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.
  48328. * @param name The name of the particle system
  48329. * @param options The options used to create the system
  48330. * @param scene The scene the particle system belongs to
  48331. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  48332. */
  48333. constructor(name: string, options: Partial<{
  48334. capacity: number;
  48335. randomTextureSize: number;
  48336. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  48337. protected _reset(): void;
  48338. private _createUpdateVAO;
  48339. private _createRenderVAO;
  48340. private _initialize;
  48341. /** @hidden */
  48342. _recreateUpdateEffect(): void;
  48343. /** @hidden */
  48344. _recreateRenderEffect(): void;
  48345. /**
  48346. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  48347. * @param preWarm defines if we are in the pre-warmimg phase
  48348. */
  48349. animate(preWarm?: boolean): void;
  48350. private _createFactorGradientTexture;
  48351. private _createSizeGradientTexture;
  48352. private _createAngularSpeedGradientTexture;
  48353. private _createVelocityGradientTexture;
  48354. private _createLimitVelocityGradientTexture;
  48355. private _createDragGradientTexture;
  48356. private _createColorGradientTexture;
  48357. /**
  48358. * Renders the particle system in its current state
  48359. * @param preWarm defines if the system should only update the particles but not render them
  48360. * @returns the current number of particles
  48361. */
  48362. render(preWarm?: boolean): number;
  48363. /**
  48364. * Rebuilds the particle system
  48365. */
  48366. rebuild(): void;
  48367. private _releaseBuffers;
  48368. private _releaseVAOs;
  48369. /**
  48370. * Disposes the particle system and free the associated resources
  48371. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  48372. */
  48373. dispose(disposeTexture?: boolean): void;
  48374. /**
  48375. * Clones the particle system.
  48376. * @param name The name of the cloned object
  48377. * @param newEmitter The new emitter to use
  48378. * @returns the cloned particle system
  48379. */
  48380. clone(name: string, newEmitter: any): GPUParticleSystem;
  48381. /**
  48382. * Serializes the particle system to a JSON object.
  48383. * @returns the JSON object
  48384. */
  48385. serialize(): any;
  48386. /**
  48387. * Parses a JSON object to create a GPU particle system.
  48388. * @param parsedParticleSystem The JSON object to parse
  48389. * @param scene The scene to create the particle system in
  48390. * @param rootUrl The root url to use to load external dependencies like texture
  48391. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  48392. * @returns the parsed GPU particle system
  48393. */
  48394. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  48395. }
  48396. }
  48397. declare module BABYLON {
  48398. /**
  48399. * Represents a set of particle systems working together to create a specific effect
  48400. */
  48401. export class ParticleSystemSet implements IDisposable {
  48402. private _emitterCreationOptions;
  48403. private _emitterNode;
  48404. /**
  48405. * Gets the particle system list
  48406. */
  48407. systems: IParticleSystem[];
  48408. /**
  48409. * Gets the emitter node used with this set
  48410. */
  48411. readonly emitterNode: Nullable<TransformNode>;
  48412. /**
  48413. * Creates a new emitter mesh as a sphere
  48414. * @param options defines the options used to create the sphere
  48415. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  48416. * @param scene defines the hosting scene
  48417. */
  48418. setEmitterAsSphere(options: {
  48419. diameter: number;
  48420. segments: number;
  48421. color: Color3;
  48422. }, renderingGroupId: number, scene: Scene): void;
  48423. /**
  48424. * Starts all particle systems of the set
  48425. * @param emitter defines an optional mesh to use as emitter for the particle systems
  48426. */
  48427. start(emitter?: AbstractMesh): void;
  48428. /**
  48429. * Release all associated resources
  48430. */
  48431. dispose(): void;
  48432. /**
  48433. * Serialize the set into a JSON compatible object
  48434. * @returns a JSON compatible representation of the set
  48435. */
  48436. serialize(): any;
  48437. /**
  48438. * Parse a new ParticleSystemSet from a serialized source
  48439. * @param data defines a JSON compatible representation of the set
  48440. * @param scene defines the hosting scene
  48441. * @param gpu defines if we want GPU particles or CPU particles
  48442. * @returns a new ParticleSystemSet
  48443. */
  48444. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  48445. }
  48446. }
  48447. declare module BABYLON {
  48448. /**
  48449. * This class is made for on one-liner static method to help creating particle system set.
  48450. */
  48451. export class ParticleHelper {
  48452. /**
  48453. * Gets or sets base Assets URL
  48454. */
  48455. static BaseAssetsUrl: string;
  48456. /**
  48457. * Create a default particle system that you can tweak
  48458. * @param emitter defines the emitter to use
  48459. * @param capacity defines the system capacity (default is 500 particles)
  48460. * @param scene defines the hosting scene
  48461. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  48462. * @returns the new Particle system
  48463. */
  48464. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  48465. /**
  48466. * This is the main static method (one-liner) of this helper to create different particle systems
  48467. * @param type This string represents the type to the particle system to create
  48468. * @param scene The scene where the particle system should live
  48469. * @param gpu If the system will use gpu
  48470. * @returns the ParticleSystemSet created
  48471. */
  48472. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  48473. /**
  48474. * Static function used to export a particle system to a ParticleSystemSet variable.
  48475. * Please note that the emitter shape is not exported
  48476. * @param systems defines the particle systems to export
  48477. * @returns the created particle system set
  48478. */
  48479. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  48480. }
  48481. }
  48482. declare module BABYLON {
  48483. interface Engine {
  48484. /**
  48485. * Create an effect to use with particle systems.
  48486. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  48487. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  48488. * @param uniformsNames defines a list of attribute names
  48489. * @param samplers defines an array of string used to represent textures
  48490. * @param defines defines the string containing the defines to use to compile the shaders
  48491. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  48492. * @param onCompiled defines a function to call when the effect creation is successful
  48493. * @param onError defines a function to call when the effect creation has failed
  48494. * @returns the new Effect
  48495. */
  48496. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  48497. }
  48498. interface Mesh {
  48499. /**
  48500. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  48501. * @returns an array of IParticleSystem
  48502. */
  48503. getEmittedParticleSystems(): IParticleSystem[];
  48504. /**
  48505. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  48506. * @returns an array of IParticleSystem
  48507. */
  48508. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  48509. }
  48510. /**
  48511. * @hidden
  48512. */
  48513. export var _IDoNeedToBeInTheBuild: number;
  48514. }
  48515. declare module BABYLON {
  48516. interface Scene {
  48517. /** @hidden (Backing field) */
  48518. _physicsEngine: Nullable<IPhysicsEngine>;
  48519. /**
  48520. * Gets the current physics engine
  48521. * @returns a IPhysicsEngine or null if none attached
  48522. */
  48523. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  48524. /**
  48525. * Enables physics to the current scene
  48526. * @param gravity defines the scene's gravity for the physics engine
  48527. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  48528. * @return a boolean indicating if the physics engine was initialized
  48529. */
  48530. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  48531. /**
  48532. * Disables and disposes the physics engine associated with the scene
  48533. */
  48534. disablePhysicsEngine(): void;
  48535. /**
  48536. * Gets a boolean indicating if there is an active physics engine
  48537. * @returns a boolean indicating if there is an active physics engine
  48538. */
  48539. isPhysicsEnabled(): boolean;
  48540. /**
  48541. * Deletes a physics compound impostor
  48542. * @param compound defines the compound to delete
  48543. */
  48544. deleteCompoundImpostor(compound: any): void;
  48545. /**
  48546. * An event triggered when physic simulation is about to be run
  48547. */
  48548. onBeforePhysicsObservable: Observable<Scene>;
  48549. /**
  48550. * An event triggered when physic simulation has been done
  48551. */
  48552. onAfterPhysicsObservable: Observable<Scene>;
  48553. }
  48554. interface AbstractMesh {
  48555. /** @hidden */
  48556. _physicsImpostor: Nullable<PhysicsImpostor>;
  48557. /**
  48558. * Gets or sets impostor used for physic simulation
  48559. * @see http://doc.babylonjs.com/features/physics_engine
  48560. */
  48561. physicsImpostor: Nullable<PhysicsImpostor>;
  48562. /**
  48563. * Gets the current physics impostor
  48564. * @see http://doc.babylonjs.com/features/physics_engine
  48565. * @returns a physics impostor or null
  48566. */
  48567. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  48568. /** Apply a physic impulse to the mesh
  48569. * @param force defines the force to apply
  48570. * @param contactPoint defines where to apply the force
  48571. * @returns the current mesh
  48572. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48573. */
  48574. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  48575. /**
  48576. * Creates a physic joint between two meshes
  48577. * @param otherMesh defines the other mesh to use
  48578. * @param pivot1 defines the pivot to use on this mesh
  48579. * @param pivot2 defines the pivot to use on the other mesh
  48580. * @param options defines additional options (can be plugin dependent)
  48581. * @returns the current mesh
  48582. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  48583. */
  48584. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  48585. /** @hidden */
  48586. _disposePhysicsObserver: Nullable<Observer<Node>>;
  48587. }
  48588. /**
  48589. * Defines the physics engine scene component responsible to manage a physics engine
  48590. */
  48591. export class PhysicsEngineSceneComponent implements ISceneComponent {
  48592. /**
  48593. * The component name helpful to identify the component in the list of scene components.
  48594. */
  48595. readonly name: string;
  48596. /**
  48597. * The scene the component belongs to.
  48598. */
  48599. scene: Scene;
  48600. /**
  48601. * Creates a new instance of the component for the given scene
  48602. * @param scene Defines the scene to register the component in
  48603. */
  48604. constructor(scene: Scene);
  48605. /**
  48606. * Registers the component in a given scene
  48607. */
  48608. register(): void;
  48609. /**
  48610. * Rebuilds the elements related to this component in case of
  48611. * context lost for instance.
  48612. */
  48613. rebuild(): void;
  48614. /**
  48615. * Disposes the component and the associated ressources
  48616. */
  48617. dispose(): void;
  48618. }
  48619. }
  48620. declare module BABYLON {
  48621. /**
  48622. * A helper for physics simulations
  48623. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48624. */
  48625. export class PhysicsHelper {
  48626. private _scene;
  48627. private _physicsEngine;
  48628. /**
  48629. * Initializes the Physics helper
  48630. * @param scene Babylon.js scene
  48631. */
  48632. constructor(scene: Scene);
  48633. /**
  48634. * Applies a radial explosion impulse
  48635. * @param origin the origin of the explosion
  48636. * @param radius the explosion radius
  48637. * @param strength the explosion strength
  48638. * @param falloff possible options: Constant & Linear. Defaults to Constant
  48639. * @returns A physics radial explosion event, or null
  48640. */
  48641. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  48642. /**
  48643. * Applies a radial explosion force
  48644. * @param origin the origin of the explosion
  48645. * @param radius the explosion radius
  48646. * @param strength the explosion strength
  48647. * @param falloff possible options: Constant & Linear. Defaults to Constant
  48648. * @returns A physics radial explosion event, or null
  48649. */
  48650. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  48651. /**
  48652. * Creates a gravitational field
  48653. * @param origin the origin of the explosion
  48654. * @param radius the explosion radius
  48655. * @param strength the explosion strength
  48656. * @param falloff possible options: Constant & Linear. Defaults to Constant
  48657. * @returns A physics gravitational field event, or null
  48658. */
  48659. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  48660. /**
  48661. * Creates a physics updraft event
  48662. * @param origin the origin of the updraft
  48663. * @param radius the radius of the updraft
  48664. * @param strength the strength of the updraft
  48665. * @param height the height of the updraft
  48666. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  48667. * @returns A physics updraft event, or null
  48668. */
  48669. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  48670. /**
  48671. * Creates a physics vortex event
  48672. * @param origin the of the vortex
  48673. * @param radius the radius of the vortex
  48674. * @param strength the strength of the vortex
  48675. * @param height the height of the vortex
  48676. * @returns a Physics vortex event, or null
  48677. * A physics vortex event or null
  48678. */
  48679. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  48680. }
  48681. /**
  48682. * Represents a physics radial explosion event
  48683. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48684. */
  48685. export class PhysicsRadialExplosionEvent {
  48686. private _scene;
  48687. private _sphere;
  48688. private _sphereOptions;
  48689. private _rays;
  48690. private _dataFetched;
  48691. /**
  48692. * Initializes a radial explosioin event
  48693. * @param scene BabylonJS scene
  48694. */
  48695. constructor(scene: Scene);
  48696. /**
  48697. * Returns the data related to the radial explosion event (sphere & rays).
  48698. * @returns The radial explosion event data
  48699. */
  48700. getData(): PhysicsRadialExplosionEventData;
  48701. /**
  48702. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  48703. * @param impostor A physics imposter
  48704. * @param origin the origin of the explosion
  48705. * @param radius the explosion radius
  48706. * @param strength the explosion strength
  48707. * @param falloff possible options: Constant & Linear
  48708. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  48709. */
  48710. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  48711. /**
  48712. * Disposes the sphere.
  48713. * @param force Specifies if the sphere should be disposed by force
  48714. */
  48715. dispose(force?: boolean): void;
  48716. /*** Helpers ***/
  48717. private _prepareSphere;
  48718. private _intersectsWithSphere;
  48719. }
  48720. /**
  48721. * Represents a gravitational field event
  48722. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48723. */
  48724. export class PhysicsGravitationalFieldEvent {
  48725. private _physicsHelper;
  48726. private _scene;
  48727. private _origin;
  48728. private _radius;
  48729. private _strength;
  48730. private _falloff;
  48731. private _tickCallback;
  48732. private _sphere;
  48733. private _dataFetched;
  48734. /**
  48735. * Initializes the physics gravitational field event
  48736. * @param physicsHelper A physics helper
  48737. * @param scene BabylonJS scene
  48738. * @param origin The origin position of the gravitational field event
  48739. * @param radius The radius of the gravitational field event
  48740. * @param strength The strength of the gravitational field event
  48741. * @param falloff The falloff for the gravitational field event
  48742. */
  48743. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  48744. /**
  48745. * Returns the data related to the gravitational field event (sphere).
  48746. * @returns A gravitational field event
  48747. */
  48748. getData(): PhysicsGravitationalFieldEventData;
  48749. /**
  48750. * Enables the gravitational field.
  48751. */
  48752. enable(): void;
  48753. /**
  48754. * Disables the gravitational field.
  48755. */
  48756. disable(): void;
  48757. /**
  48758. * Disposes the sphere.
  48759. * @param force The force to dispose from the gravitational field event
  48760. */
  48761. dispose(force?: boolean): void;
  48762. private _tick;
  48763. }
  48764. /**
  48765. * Represents a physics updraft event
  48766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48767. */
  48768. export class PhysicsUpdraftEvent {
  48769. private _scene;
  48770. private _origin;
  48771. private _radius;
  48772. private _strength;
  48773. private _height;
  48774. private _updraftMode;
  48775. private _physicsEngine;
  48776. private _originTop;
  48777. private _originDirection;
  48778. private _tickCallback;
  48779. private _cylinder;
  48780. private _cylinderPosition;
  48781. private _dataFetched;
  48782. /**
  48783. * Initializes the physics updraft event
  48784. * @param _scene BabylonJS scene
  48785. * @param _origin The origin position of the updraft
  48786. * @param _radius The radius of the updraft
  48787. * @param _strength The strength of the updraft
  48788. * @param _height The height of the updraft
  48789. * @param _updraftMode The mode of the updraft
  48790. */
  48791. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  48792. /**
  48793. * Returns the data related to the updraft event (cylinder).
  48794. * @returns A physics updraft event
  48795. */
  48796. getData(): PhysicsUpdraftEventData;
  48797. /**
  48798. * Enables the updraft.
  48799. */
  48800. enable(): void;
  48801. /**
  48802. * Disables the cortex.
  48803. */
  48804. disable(): void;
  48805. /**
  48806. * Disposes the sphere.
  48807. * @param force Specifies if the updraft should be disposed by force
  48808. */
  48809. dispose(force?: boolean): void;
  48810. private getImpostorForceAndContactPoint;
  48811. private _tick;
  48812. /*** Helpers ***/
  48813. private _prepareCylinder;
  48814. private _intersectsWithCylinder;
  48815. }
  48816. /**
  48817. * Represents a physics vortex event
  48818. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48819. */
  48820. export class PhysicsVortexEvent {
  48821. private _scene;
  48822. private _origin;
  48823. private _radius;
  48824. private _strength;
  48825. private _height;
  48826. private _physicsEngine;
  48827. private _originTop;
  48828. private _centripetalForceThreshold;
  48829. private _updraftMultiplier;
  48830. private _tickCallback;
  48831. private _cylinder;
  48832. private _cylinderPosition;
  48833. private _dataFetched;
  48834. /**
  48835. * Initializes the physics vortex event
  48836. * @param _scene The BabylonJS scene
  48837. * @param _origin The origin position of the vortex
  48838. * @param _radius The radius of the vortex
  48839. * @param _strength The strength of the vortex
  48840. * @param _height The height of the vortex
  48841. */
  48842. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  48843. /**
  48844. * Returns the data related to the vortex event (cylinder).
  48845. * @returns The physics vortex event data
  48846. */
  48847. getData(): PhysicsVortexEventData;
  48848. /**
  48849. * Enables the vortex.
  48850. */
  48851. enable(): void;
  48852. /**
  48853. * Disables the cortex.
  48854. */
  48855. disable(): void;
  48856. /**
  48857. * Disposes the sphere.
  48858. * @param force
  48859. */
  48860. dispose(force?: boolean): void;
  48861. private getImpostorForceAndContactPoint;
  48862. private _tick;
  48863. /*** Helpers ***/
  48864. private _prepareCylinder;
  48865. private _intersectsWithCylinder;
  48866. }
  48867. /**
  48868. * The strenght of the force in correspondence to the distance of the affected object
  48869. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48870. */
  48871. export enum PhysicsRadialImpulseFalloff {
  48872. /** Defines that impulse is constant in strength across it's whole radius */
  48873. Constant = 0,
  48874. /** DEfines that impulse gets weaker if it's further from the origin */
  48875. Linear = 1
  48876. }
  48877. /**
  48878. * The strength of the force in correspondence to the distance of the affected object
  48879. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48880. */
  48881. export enum PhysicsUpdraftMode {
  48882. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  48883. Center = 0,
  48884. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  48885. Perpendicular = 1
  48886. }
  48887. /**
  48888. * Interface for a physics force and contact point
  48889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48890. */
  48891. export interface PhysicsForceAndContactPoint {
  48892. /**
  48893. * The force applied at the contact point
  48894. */
  48895. force: Vector3;
  48896. /**
  48897. * The contact point
  48898. */
  48899. contactPoint: Vector3;
  48900. }
  48901. /**
  48902. * Interface for radial explosion event data
  48903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48904. */
  48905. export interface PhysicsRadialExplosionEventData {
  48906. /**
  48907. * A sphere used for the radial explosion event
  48908. */
  48909. sphere: Mesh;
  48910. /**
  48911. * An array of rays for the radial explosion event
  48912. */
  48913. rays: Array<Ray>;
  48914. }
  48915. /**
  48916. * Interface for gravitational field event data
  48917. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48918. */
  48919. export interface PhysicsGravitationalFieldEventData {
  48920. /**
  48921. * A sphere mesh used for the gravitational field event
  48922. */
  48923. sphere: Mesh;
  48924. }
  48925. /**
  48926. * Interface for updraft event data
  48927. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48928. */
  48929. export interface PhysicsUpdraftEventData {
  48930. /**
  48931. * A cylinder used for the updraft event
  48932. */
  48933. cylinder: Mesh;
  48934. }
  48935. /**
  48936. * Interface for vortex event data
  48937. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48938. */
  48939. export interface PhysicsVortexEventData {
  48940. /**
  48941. * A cylinder used for the vortex event
  48942. */
  48943. cylinder: Mesh;
  48944. }
  48945. }
  48946. declare module BABYLON {
  48947. /**
  48948. * AmmoJS Physics plugin
  48949. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48950. * @see https://github.com/kripken/ammo.js/
  48951. */
  48952. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48953. private _useDeltaForWorldStep;
  48954. /**
  48955. * Reference to the Ammo library
  48956. */
  48957. bjsAMMO: any;
  48958. /**
  48959. * Created ammoJS world which physics bodies are added to
  48960. */
  48961. world: any;
  48962. /**
  48963. * Name of the plugin
  48964. */
  48965. name: string;
  48966. private _timeStep;
  48967. private _fixedTimeStep;
  48968. private _maxSteps;
  48969. private _tmpQuaternion;
  48970. private _tmpAmmoTransform;
  48971. private _tmpAmmoQuaternion;
  48972. private _tmpAmmoConcreteContactResultCallback;
  48973. private _collisionConfiguration;
  48974. private _dispatcher;
  48975. private _overlappingPairCache;
  48976. private _solver;
  48977. private _tmpAmmoVectorA;
  48978. private _tmpAmmoVectorB;
  48979. private _tmpAmmoVectorC;
  48980. private _tmpContactCallbackResult;
  48981. private static readonly DISABLE_COLLISION_FLAG;
  48982. private static readonly KINEMATIC_FLAG;
  48983. private static readonly DISABLE_DEACTIVATION_FLAG;
  48984. /**
  48985. * Initializes the ammoJS plugin
  48986. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48987. * @param ammoInjection can be used to inject your own ammo reference
  48988. */
  48989. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  48990. /**
  48991. * Sets the gravity of the physics world (m/(s^2))
  48992. * @param gravity Gravity to set
  48993. */
  48994. setGravity(gravity: Vector3): void;
  48995. /**
  48996. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48997. * @param timeStep timestep to use in seconds
  48998. */
  48999. setTimeStep(timeStep: number): void;
  49000. /**
  49001. * Increment to step forward in the physics engine (If timeStep is set to 1/60 and fixedTimeStep is set to 1/120 the physics engine should run 2 steps per frame) (Default: 1/60)
  49002. * @param fixedTimeStep fixedTimeStep to use in seconds
  49003. */
  49004. setFixedTimeStep(fixedTimeStep: number): void;
  49005. /**
  49006. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49007. * @param maxSteps the maximum number of steps by the physics engine per frame
  49008. */
  49009. setMaxSteps(maxSteps: number): void;
  49010. /**
  49011. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49012. * @returns the current timestep in seconds
  49013. */
  49014. getTimeStep(): number;
  49015. private _isImpostorInContact;
  49016. private _isImpostorPairInContact;
  49017. private _stepSimulation;
  49018. /**
  49019. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49020. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49021. * After the step the babylon meshes are set to the position of the physics imposters
  49022. * @param delta amount of time to step forward
  49023. * @param impostors array of imposters to update before/after the step
  49024. */
  49025. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49026. private _tmpVector;
  49027. private _tmpMatrix;
  49028. /**
  49029. * Applies an implulse on the imposter
  49030. * @param impostor imposter to apply impulse
  49031. * @param force amount of force to be applied to the imposter
  49032. * @param contactPoint the location to apply the impulse on the imposter
  49033. */
  49034. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49035. /**
  49036. * Applies a force on the imposter
  49037. * @param impostor imposter to apply force
  49038. * @param force amount of force to be applied to the imposter
  49039. * @param contactPoint the location to apply the force on the imposter
  49040. */
  49041. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49042. /**
  49043. * Creates a physics body using the plugin
  49044. * @param impostor the imposter to create the physics body on
  49045. */
  49046. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49047. /**
  49048. * Removes the physics body from the imposter and disposes of the body's memory
  49049. * @param impostor imposter to remove the physics body from
  49050. */
  49051. removePhysicsBody(impostor: PhysicsImpostor): void;
  49052. /**
  49053. * Generates a joint
  49054. * @param impostorJoint the imposter joint to create the joint with
  49055. */
  49056. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49057. /**
  49058. * Removes a joint
  49059. * @param impostorJoint the imposter joint to remove the joint from
  49060. */
  49061. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49062. private _addMeshVerts;
  49063. private _createShape;
  49064. /**
  49065. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49066. * @param impostor imposter containing the physics body and babylon object
  49067. */
  49068. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49069. /**
  49070. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49071. * @param impostor imposter containing the physics body and babylon object
  49072. * @param newPosition new position
  49073. * @param newRotation new rotation
  49074. */
  49075. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49076. /**
  49077. * If this plugin is supported
  49078. * @returns true if its supported
  49079. */
  49080. isSupported(): boolean;
  49081. /**
  49082. * Sets the linear velocity of the physics body
  49083. * @param impostor imposter to set the velocity on
  49084. * @param velocity velocity to set
  49085. */
  49086. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49087. /**
  49088. * Sets the angular velocity of the physics body
  49089. * @param impostor imposter to set the velocity on
  49090. * @param velocity velocity to set
  49091. */
  49092. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49093. /**
  49094. * gets the linear velocity
  49095. * @param impostor imposter to get linear velocity from
  49096. * @returns linear velocity
  49097. */
  49098. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49099. /**
  49100. * gets the angular velocity
  49101. * @param impostor imposter to get angular velocity from
  49102. * @returns angular velocity
  49103. */
  49104. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49105. /**
  49106. * Sets the mass of physics body
  49107. * @param impostor imposter to set the mass on
  49108. * @param mass mass to set
  49109. */
  49110. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49111. /**
  49112. * Gets the mass of the physics body
  49113. * @param impostor imposter to get the mass from
  49114. * @returns mass
  49115. */
  49116. getBodyMass(impostor: PhysicsImpostor): number;
  49117. /**
  49118. * Gets friction of the impostor
  49119. * @param impostor impostor to get friction from
  49120. * @returns friction value
  49121. */
  49122. getBodyFriction(impostor: PhysicsImpostor): number;
  49123. /**
  49124. * Sets friction of the impostor
  49125. * @param impostor impostor to set friction on
  49126. * @param friction friction value
  49127. */
  49128. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49129. /**
  49130. * Gets restitution of the impostor
  49131. * @param impostor impostor to get restitution from
  49132. * @returns restitution value
  49133. */
  49134. getBodyRestitution(impostor: PhysicsImpostor): number;
  49135. /**
  49136. * Sets resitution of the impostor
  49137. * @param impostor impostor to set resitution on
  49138. * @param restitution resitution value
  49139. */
  49140. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49141. /**
  49142. * Sleeps the physics body and stops it from being active
  49143. * @param impostor impostor to sleep
  49144. */
  49145. sleepBody(impostor: PhysicsImpostor): void;
  49146. /**
  49147. * Activates the physics body
  49148. * @param impostor impostor to activate
  49149. */
  49150. wakeUpBody(impostor: PhysicsImpostor): void;
  49151. /**
  49152. * Updates the distance parameters of the joint
  49153. * @param joint joint to update
  49154. * @param maxDistance maximum distance of the joint
  49155. * @param minDistance minimum distance of the joint
  49156. */
  49157. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49158. /**
  49159. * Sets a motor on the joint
  49160. * @param joint joint to set motor on
  49161. * @param speed speed of the motor
  49162. * @param maxForce maximum force of the motor
  49163. * @param motorIndex index of the motor
  49164. */
  49165. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49166. /**
  49167. * Sets the motors limit
  49168. * @param joint joint to set limit on
  49169. * @param upperLimit upper limit
  49170. * @param lowerLimit lower limit
  49171. */
  49172. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49173. /**
  49174. * Syncs the position and rotation of a mesh with the impostor
  49175. * @param mesh mesh to sync
  49176. * @param impostor impostor to update the mesh with
  49177. */
  49178. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49179. /**
  49180. * Gets the radius of the impostor
  49181. * @param impostor impostor to get radius from
  49182. * @returns the radius
  49183. */
  49184. getRadius(impostor: PhysicsImpostor): number;
  49185. /**
  49186. * Gets the box size of the impostor
  49187. * @param impostor impostor to get box size from
  49188. * @param result the resulting box size
  49189. */
  49190. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49191. /**
  49192. * Disposes of the impostor
  49193. */
  49194. dispose(): void;
  49195. }
  49196. }
  49197. declare module BABYLON {
  49198. /** @hidden */
  49199. export var blackAndWhitePixelShader: {
  49200. name: string;
  49201. shader: string;
  49202. };
  49203. }
  49204. declare module BABYLON {
  49205. /**
  49206. * Post process used to render in black and white
  49207. */
  49208. export class BlackAndWhitePostProcess extends PostProcess {
  49209. /**
  49210. * Linear about to convert he result to black and white (default: 1)
  49211. */
  49212. degree: number;
  49213. /**
  49214. * Creates a black and white post process
  49215. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  49216. * @param name The name of the effect.
  49217. * @param options The required width/height ratio to downsize to before computing the render pass.
  49218. * @param camera The camera to apply the render pass to.
  49219. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49220. * @param engine The engine which the post process will be applied. (default: current engine)
  49221. * @param reusable If the post process can be reused on the same frame. (default: false)
  49222. */
  49223. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49224. }
  49225. }
  49226. declare module BABYLON {
  49227. /**
  49228. * This represents a set of one or more post processes in Babylon.
  49229. * A post process can be used to apply a shader to a texture after it is rendered.
  49230. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49231. */
  49232. export class PostProcessRenderEffect {
  49233. private _postProcesses;
  49234. private _getPostProcesses;
  49235. private _singleInstance;
  49236. private _cameras;
  49237. private _indicesForCamera;
  49238. /**
  49239. * Name of the effect
  49240. * @hidden
  49241. */
  49242. _name: string;
  49243. /**
  49244. * Instantiates a post process render effect.
  49245. * A post process can be used to apply a shader to a texture after it is rendered.
  49246. * @param engine The engine the effect is tied to
  49247. * @param name The name of the effect
  49248. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  49249. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  49250. */
  49251. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  49252. /**
  49253. * Checks if all the post processes in the effect are supported.
  49254. */
  49255. readonly isSupported: boolean;
  49256. /**
  49257. * Updates the current state of the effect
  49258. * @hidden
  49259. */
  49260. _update(): void;
  49261. /**
  49262. * Attaches the effect on cameras
  49263. * @param cameras The camera to attach to.
  49264. * @hidden
  49265. */
  49266. _attachCameras(cameras: Camera): void;
  49267. /**
  49268. * Attaches the effect on cameras
  49269. * @param cameras The camera to attach to.
  49270. * @hidden
  49271. */
  49272. _attachCameras(cameras: Camera[]): void;
  49273. /**
  49274. * Detatches the effect on cameras
  49275. * @param cameras The camera to detatch from.
  49276. * @hidden
  49277. */
  49278. _detachCameras(cameras: Camera): void;
  49279. /**
  49280. * Detatches the effect on cameras
  49281. * @param cameras The camera to detatch from.
  49282. * @hidden
  49283. */
  49284. _detachCameras(cameras: Camera[]): void;
  49285. /**
  49286. * Enables the effect on given cameras
  49287. * @param cameras The camera to enable.
  49288. * @hidden
  49289. */
  49290. _enable(cameras: Camera): void;
  49291. /**
  49292. * Enables the effect on given cameras
  49293. * @param cameras The camera to enable.
  49294. * @hidden
  49295. */
  49296. _enable(cameras: Nullable<Camera[]>): void;
  49297. /**
  49298. * Disables the effect on the given cameras
  49299. * @param cameras The camera to disable.
  49300. * @hidden
  49301. */
  49302. _disable(cameras: Camera): void;
  49303. /**
  49304. * Disables the effect on the given cameras
  49305. * @param cameras The camera to disable.
  49306. * @hidden
  49307. */
  49308. _disable(cameras: Nullable<Camera[]>): void;
  49309. /**
  49310. * Gets a list of the post processes contained in the effect.
  49311. * @param camera The camera to get the post processes on.
  49312. * @returns The list of the post processes in the effect.
  49313. */
  49314. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  49315. }
  49316. }
  49317. declare module BABYLON {
  49318. /** @hidden */
  49319. export var extractHighlightsPixelShader: {
  49320. name: string;
  49321. shader: string;
  49322. };
  49323. }
  49324. declare module BABYLON {
  49325. /**
  49326. * 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.
  49327. */
  49328. export class ExtractHighlightsPostProcess extends PostProcess {
  49329. /**
  49330. * The luminance threshold, pixels below this value will be set to black.
  49331. */
  49332. threshold: number;
  49333. /** @hidden */
  49334. _exposure: number;
  49335. /**
  49336. * Post process which has the input texture to be used when performing highlight extraction
  49337. * @hidden
  49338. */
  49339. _inputPostProcess: Nullable<PostProcess>;
  49340. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49341. }
  49342. }
  49343. declare module BABYLON {
  49344. /** @hidden */
  49345. export var bloomMergePixelShader: {
  49346. name: string;
  49347. shader: string;
  49348. };
  49349. }
  49350. declare module BABYLON {
  49351. /**
  49352. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  49353. */
  49354. export class BloomMergePostProcess extends PostProcess {
  49355. /** Weight of the bloom to be added to the original input. */
  49356. weight: number;
  49357. /**
  49358. * Creates a new instance of @see BloomMergePostProcess
  49359. * @param name The name of the effect.
  49360. * @param originalFromInput Post process which's input will be used for the merge.
  49361. * @param blurred Blurred highlights post process which's output will be used.
  49362. * @param weight Weight of the bloom to be added to the original input.
  49363. * @param options The required width/height ratio to downsize to before computing the render pass.
  49364. * @param camera The camera to apply the render pass to.
  49365. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49366. * @param engine The engine which the post process will be applied. (default: current engine)
  49367. * @param reusable If the post process can be reused on the same frame. (default: false)
  49368. * @param textureType Type of textures used when performing the post process. (default: 0)
  49369. * @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)
  49370. */
  49371. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  49372. /** Weight of the bloom to be added to the original input. */
  49373. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49374. }
  49375. }
  49376. declare module BABYLON {
  49377. /**
  49378. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  49379. */
  49380. export class BloomEffect extends PostProcessRenderEffect {
  49381. private bloomScale;
  49382. /**
  49383. * @hidden Internal
  49384. */
  49385. _effects: Array<PostProcess>;
  49386. /**
  49387. * @hidden Internal
  49388. */
  49389. _downscale: ExtractHighlightsPostProcess;
  49390. private _blurX;
  49391. private _blurY;
  49392. private _merge;
  49393. /**
  49394. * The luminance threshold to find bright areas of the image to bloom.
  49395. */
  49396. threshold: number;
  49397. /**
  49398. * The strength of the bloom.
  49399. */
  49400. weight: number;
  49401. /**
  49402. * Specifies the size of the bloom blur kernel, relative to the final output size
  49403. */
  49404. kernel: number;
  49405. /**
  49406. * Creates a new instance of @see BloomEffect
  49407. * @param scene The scene the effect belongs to.
  49408. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  49409. * @param bloomKernel The size of the kernel to be used when applying the blur.
  49410. * @param bloomWeight The the strength of bloom.
  49411. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  49412. * @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)
  49413. */
  49414. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  49415. /**
  49416. * Disposes each of the internal effects for a given camera.
  49417. * @param camera The camera to dispose the effect on.
  49418. */
  49419. disposeEffects(camera: Camera): void;
  49420. /**
  49421. * @hidden Internal
  49422. */
  49423. _updateEffects(): void;
  49424. /**
  49425. * Internal
  49426. * @returns if all the contained post processes are ready.
  49427. * @hidden
  49428. */
  49429. _isReady(): boolean;
  49430. }
  49431. }
  49432. declare module BABYLON {
  49433. /** @hidden */
  49434. export var chromaticAberrationPixelShader: {
  49435. name: string;
  49436. shader: string;
  49437. };
  49438. }
  49439. declare module BABYLON {
  49440. /**
  49441. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  49442. */
  49443. export class ChromaticAberrationPostProcess extends PostProcess {
  49444. /**
  49445. * The amount of seperation of rgb channels (default: 30)
  49446. */
  49447. aberrationAmount: number;
  49448. /**
  49449. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  49450. */
  49451. radialIntensity: number;
  49452. /**
  49453. * 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))
  49454. */
  49455. direction: Vector2;
  49456. /**
  49457. * 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))
  49458. */
  49459. centerPosition: Vector2;
  49460. /**
  49461. * Creates a new instance ChromaticAberrationPostProcess
  49462. * @param name The name of the effect.
  49463. * @param screenWidth The width of the screen to apply the effect on.
  49464. * @param screenHeight The height of the screen to apply the effect on.
  49465. * @param options The required width/height ratio to downsize to before computing the render pass.
  49466. * @param camera The camera to apply the render pass to.
  49467. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49468. * @param engine The engine which the post process will be applied. (default: current engine)
  49469. * @param reusable If the post process can be reused on the same frame. (default: false)
  49470. * @param textureType Type of textures used when performing the post process. (default: 0)
  49471. * @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)
  49472. */
  49473. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49474. }
  49475. }
  49476. declare module BABYLON {
  49477. /** @hidden */
  49478. export var circleOfConfusionPixelShader: {
  49479. name: string;
  49480. shader: string;
  49481. };
  49482. }
  49483. declare module BABYLON {
  49484. /**
  49485. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  49486. */
  49487. export class CircleOfConfusionPostProcess extends PostProcess {
  49488. /**
  49489. * 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.
  49490. */
  49491. lensSize: number;
  49492. /**
  49493. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  49494. */
  49495. fStop: number;
  49496. /**
  49497. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  49498. */
  49499. focusDistance: number;
  49500. /**
  49501. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  49502. */
  49503. focalLength: number;
  49504. private _depthTexture;
  49505. /**
  49506. * Creates a new instance CircleOfConfusionPostProcess
  49507. * @param name The name of the effect.
  49508. * @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.
  49509. * @param options The required width/height ratio to downsize to before computing the render pass.
  49510. * @param camera The camera to apply the render pass to.
  49511. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49512. * @param engine The engine which the post process will be applied. (default: current engine)
  49513. * @param reusable If the post process can be reused on the same frame. (default: false)
  49514. * @param textureType Type of textures used when performing the post process. (default: 0)
  49515. * @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)
  49516. */
  49517. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49518. /**
  49519. * 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.
  49520. */
  49521. depthTexture: RenderTargetTexture;
  49522. }
  49523. }
  49524. declare module BABYLON {
  49525. /** @hidden */
  49526. export var colorCorrectionPixelShader: {
  49527. name: string;
  49528. shader: string;
  49529. };
  49530. }
  49531. declare module BABYLON {
  49532. /**
  49533. *
  49534. * This post-process allows the modification of rendered colors by using
  49535. * a 'look-up table' (LUT). This effect is also called Color Grading.
  49536. *
  49537. * The object needs to be provided an url to a texture containing the color
  49538. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  49539. * Use an image editing software to tweak the LUT to match your needs.
  49540. *
  49541. * For an example of a color LUT, see here:
  49542. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  49543. * For explanations on color grading, see here:
  49544. * @see http://udn.epicgames.com/Three/ColorGrading.html
  49545. *
  49546. */
  49547. export class ColorCorrectionPostProcess extends PostProcess {
  49548. private _colorTableTexture;
  49549. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49550. }
  49551. }
  49552. declare module BABYLON {
  49553. /** @hidden */
  49554. export var convolutionPixelShader: {
  49555. name: string;
  49556. shader: string;
  49557. };
  49558. }
  49559. declare module BABYLON {
  49560. /**
  49561. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  49562. * input texture to perform effects such as edge detection or sharpening
  49563. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  49564. */
  49565. export class ConvolutionPostProcess extends PostProcess {
  49566. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  49567. kernel: number[];
  49568. /**
  49569. * Creates a new instance ConvolutionPostProcess
  49570. * @param name The name of the effect.
  49571. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  49572. * @param options The required width/height ratio to downsize to before computing the render pass.
  49573. * @param camera The camera to apply the render pass to.
  49574. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49575. * @param engine The engine which the post process will be applied. (default: current engine)
  49576. * @param reusable If the post process can be reused on the same frame. (default: false)
  49577. * @param textureType Type of textures used when performing the post process. (default: 0)
  49578. */
  49579. constructor(name: string,
  49580. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  49581. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  49582. /**
  49583. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49584. */
  49585. static EdgeDetect0Kernel: number[];
  49586. /**
  49587. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49588. */
  49589. static EdgeDetect1Kernel: number[];
  49590. /**
  49591. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49592. */
  49593. static EdgeDetect2Kernel: number[];
  49594. /**
  49595. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49596. */
  49597. static SharpenKernel: number[];
  49598. /**
  49599. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49600. */
  49601. static EmbossKernel: number[];
  49602. /**
  49603. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49604. */
  49605. static GaussianKernel: number[];
  49606. }
  49607. }
  49608. declare module BABYLON {
  49609. /**
  49610. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  49611. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  49612. * based on samples that have a large difference in distance than the center pixel.
  49613. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  49614. */
  49615. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  49616. direction: Vector2;
  49617. /**
  49618. * Creates a new instance CircleOfConfusionPostProcess
  49619. * @param name The name of the effect.
  49620. * @param scene The scene the effect belongs to.
  49621. * @param direction The direction the blur should be applied.
  49622. * @param kernel The size of the kernel used to blur.
  49623. * @param options The required width/height ratio to downsize to before computing the render pass.
  49624. * @param camera The camera to apply the render pass to.
  49625. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  49626. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  49627. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49628. * @param engine The engine which the post process will be applied. (default: current engine)
  49629. * @param reusable If the post process can be reused on the same frame. (default: false)
  49630. * @param textureType Type of textures used when performing the post process. (default: 0)
  49631. * @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)
  49632. */
  49633. 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);
  49634. }
  49635. }
  49636. declare module BABYLON {
  49637. /** @hidden */
  49638. export var depthOfFieldMergePixelShader: {
  49639. name: string;
  49640. shader: string;
  49641. };
  49642. }
  49643. declare module BABYLON {
  49644. /**
  49645. * Options to be set when merging outputs from the default pipeline.
  49646. */
  49647. export class DepthOfFieldMergePostProcessOptions {
  49648. /**
  49649. * The original image to merge on top of
  49650. */
  49651. originalFromInput: PostProcess;
  49652. /**
  49653. * Parameters to perform the merge of the depth of field effect
  49654. */
  49655. depthOfField?: {
  49656. circleOfConfusion: PostProcess;
  49657. blurSteps: Array<PostProcess>;
  49658. };
  49659. /**
  49660. * Parameters to perform the merge of bloom effect
  49661. */
  49662. bloom?: {
  49663. blurred: PostProcess;
  49664. weight: number;
  49665. };
  49666. }
  49667. /**
  49668. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  49669. */
  49670. export class DepthOfFieldMergePostProcess extends PostProcess {
  49671. private blurSteps;
  49672. /**
  49673. * Creates a new instance of DepthOfFieldMergePostProcess
  49674. * @param name The name of the effect.
  49675. * @param originalFromInput Post process which's input will be used for the merge.
  49676. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  49677. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  49678. * @param options The required width/height ratio to downsize to before computing the render pass.
  49679. * @param camera The camera to apply the render pass to.
  49680. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49681. * @param engine The engine which the post process will be applied. (default: current engine)
  49682. * @param reusable If the post process can be reused on the same frame. (default: false)
  49683. * @param textureType Type of textures used when performing the post process. (default: 0)
  49684. * @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)
  49685. */
  49686. 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);
  49687. /**
  49688. * Updates the effect with the current post process compile time values and recompiles the shader.
  49689. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  49690. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  49691. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  49692. * @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
  49693. * @param onCompiled Called when the shader has been compiled.
  49694. * @param onError Called if there is an error when compiling a shader.
  49695. */
  49696. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  49697. }
  49698. }
  49699. declare module BABYLON {
  49700. /**
  49701. * Specifies the level of max blur that should be applied when using the depth of field effect
  49702. */
  49703. export enum DepthOfFieldEffectBlurLevel {
  49704. /**
  49705. * Subtle blur
  49706. */
  49707. Low = 0,
  49708. /**
  49709. * Medium blur
  49710. */
  49711. Medium = 1,
  49712. /**
  49713. * Large blur
  49714. */
  49715. High = 2
  49716. }
  49717. /**
  49718. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  49719. */
  49720. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  49721. private _circleOfConfusion;
  49722. /**
  49723. * @hidden Internal, blurs from high to low
  49724. */
  49725. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  49726. private _depthOfFieldBlurY;
  49727. private _dofMerge;
  49728. /**
  49729. * @hidden Internal post processes in depth of field effect
  49730. */
  49731. _effects: Array<PostProcess>;
  49732. /**
  49733. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  49734. */
  49735. focalLength: number;
  49736. /**
  49737. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  49738. */
  49739. fStop: number;
  49740. /**
  49741. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  49742. */
  49743. focusDistance: number;
  49744. /**
  49745. * 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.
  49746. */
  49747. lensSize: number;
  49748. /**
  49749. * Creates a new instance DepthOfFieldEffect
  49750. * @param scene The scene the effect belongs to.
  49751. * @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.
  49752. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  49753. * @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)
  49754. */
  49755. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  49756. /**
  49757. * 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.
  49758. */
  49759. depthTexture: RenderTargetTexture;
  49760. /**
  49761. * Disposes each of the internal effects for a given camera.
  49762. * @param camera The camera to dispose the effect on.
  49763. */
  49764. disposeEffects(camera: Camera): void;
  49765. /**
  49766. * @hidden Internal
  49767. */
  49768. _updateEffects(): void;
  49769. /**
  49770. * Internal
  49771. * @returns if all the contained post processes are ready.
  49772. * @hidden
  49773. */
  49774. _isReady(): boolean;
  49775. }
  49776. }
  49777. declare module BABYLON {
  49778. /** @hidden */
  49779. export var displayPassPixelShader: {
  49780. name: string;
  49781. shader: string;
  49782. };
  49783. }
  49784. declare module BABYLON {
  49785. /**
  49786. * DisplayPassPostProcess which produces an output the same as it's input
  49787. */
  49788. export class DisplayPassPostProcess extends PostProcess {
  49789. /**
  49790. * Creates the DisplayPassPostProcess
  49791. * @param name The name of the effect.
  49792. * @param options The required width/height ratio to downsize to before computing the render pass.
  49793. * @param camera The camera to apply the render pass to.
  49794. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49795. * @param engine The engine which the post process will be applied. (default: current engine)
  49796. * @param reusable If the post process can be reused on the same frame. (default: false)
  49797. */
  49798. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49799. }
  49800. }
  49801. declare module BABYLON {
  49802. /** @hidden */
  49803. export var filterPixelShader: {
  49804. name: string;
  49805. shader: string;
  49806. };
  49807. }
  49808. declare module BABYLON {
  49809. /**
  49810. * Applies a kernel filter to the image
  49811. */
  49812. export class FilterPostProcess extends PostProcess {
  49813. /** The matrix to be applied to the image */
  49814. kernelMatrix: Matrix;
  49815. /**
  49816. *
  49817. * @param name The name of the effect.
  49818. * @param kernelMatrix The matrix to be applied to the image
  49819. * @param options The required width/height ratio to downsize to before computing the render pass.
  49820. * @param camera The camera to apply the render pass to.
  49821. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49822. * @param engine The engine which the post process will be applied. (default: current engine)
  49823. * @param reusable If the post process can be reused on the same frame. (default: false)
  49824. */
  49825. constructor(name: string,
  49826. /** The matrix to be applied to the image */
  49827. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49828. }
  49829. }
  49830. declare module BABYLON {
  49831. /** @hidden */
  49832. export var fxaaPixelShader: {
  49833. name: string;
  49834. shader: string;
  49835. };
  49836. }
  49837. declare module BABYLON {
  49838. /** @hidden */
  49839. export var fxaaVertexShader: {
  49840. name: string;
  49841. shader: string;
  49842. };
  49843. }
  49844. declare module BABYLON {
  49845. /**
  49846. * Fxaa post process
  49847. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  49848. */
  49849. export class FxaaPostProcess extends PostProcess {
  49850. /** @hidden */
  49851. texelWidth: number;
  49852. /** @hidden */
  49853. texelHeight: number;
  49854. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  49855. private _getDefines;
  49856. }
  49857. }
  49858. declare module BABYLON {
  49859. /** @hidden */
  49860. export var grainPixelShader: {
  49861. name: string;
  49862. shader: string;
  49863. };
  49864. }
  49865. declare module BABYLON {
  49866. /**
  49867. * The GrainPostProcess adds noise to the image at mid luminance levels
  49868. */
  49869. export class GrainPostProcess extends PostProcess {
  49870. /**
  49871. * The intensity of the grain added (default: 30)
  49872. */
  49873. intensity: number;
  49874. /**
  49875. * If the grain should be randomized on every frame
  49876. */
  49877. animated: boolean;
  49878. /**
  49879. * Creates a new instance of @see GrainPostProcess
  49880. * @param name The name of the effect.
  49881. * @param options The required width/height ratio to downsize to before computing the render pass.
  49882. * @param camera The camera to apply the render pass to.
  49883. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49884. * @param engine The engine which the post process will be applied. (default: current engine)
  49885. * @param reusable If the post process can be reused on the same frame. (default: false)
  49886. * @param textureType Type of textures used when performing the post process. (default: 0)
  49887. * @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)
  49888. */
  49889. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49890. }
  49891. }
  49892. declare module BABYLON {
  49893. /** @hidden */
  49894. export var highlightsPixelShader: {
  49895. name: string;
  49896. shader: string;
  49897. };
  49898. }
  49899. declare module BABYLON {
  49900. /**
  49901. * Extracts highlights from the image
  49902. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  49903. */
  49904. export class HighlightsPostProcess extends PostProcess {
  49905. /**
  49906. * Extracts highlights from the image
  49907. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  49908. * @param name The name of the effect.
  49909. * @param options The required width/height ratio to downsize to before computing the render pass.
  49910. * @param camera The camera to apply the render pass to.
  49911. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49912. * @param engine The engine which the post process will be applied. (default: current engine)
  49913. * @param reusable If the post process can be reused on the same frame. (default: false)
  49914. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  49915. */
  49916. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  49917. }
  49918. }
  49919. declare module BABYLON {
  49920. /** @hidden */
  49921. export var mrtFragmentDeclaration: {
  49922. name: string;
  49923. shader: string;
  49924. };
  49925. }
  49926. declare module BABYLON {
  49927. /** @hidden */
  49928. export var geometryPixelShader: {
  49929. name: string;
  49930. shader: string;
  49931. };
  49932. }
  49933. declare module BABYLON {
  49934. /** @hidden */
  49935. export var geometryVertexShader: {
  49936. name: string;
  49937. shader: string;
  49938. };
  49939. }
  49940. declare module BABYLON {
  49941. /**
  49942. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  49943. */
  49944. export class GeometryBufferRenderer {
  49945. /**
  49946. * Constant used to retrieve the position texture index in the G-Buffer textures array
  49947. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  49948. */
  49949. static readonly POSITION_TEXTURE_TYPE: number;
  49950. /**
  49951. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  49952. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  49953. */
  49954. static readonly VELOCITY_TEXTURE_TYPE: number;
  49955. /**
  49956. * Dictionary used to store the previous transformation matrices of each rendered mesh
  49957. * in order to compute objects velocities when enableVelocity is set to "true"
  49958. * @hidden
  49959. */
  49960. _previousTransformationMatrices: {
  49961. [index: number]: Matrix;
  49962. };
  49963. private _scene;
  49964. private _multiRenderTarget;
  49965. private _ratio;
  49966. private _enablePosition;
  49967. private _enableVelocity;
  49968. private _positionIndex;
  49969. private _velocityIndex;
  49970. protected _effect: Effect;
  49971. protected _cachedDefines: string;
  49972. /**
  49973. * Set the render list (meshes to be rendered) used in the G buffer.
  49974. */
  49975. renderList: Mesh[];
  49976. /**
  49977. * Gets wether or not G buffer are supported by the running hardware.
  49978. * This requires draw buffer supports
  49979. */
  49980. readonly isSupported: boolean;
  49981. /**
  49982. * Returns the index of the given texture type in the G-Buffer textures array
  49983. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  49984. * @returns the index of the given texture type in the G-Buffer textures array
  49985. */
  49986. getTextureIndex(textureType: number): number;
  49987. /**
  49988. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  49989. */
  49990. /**
  49991. * Sets whether or not objects positions are enabled for the G buffer.
  49992. */
  49993. enablePosition: boolean;
  49994. /**
  49995. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  49996. */
  49997. /**
  49998. * Sets wether or not objects velocities are enabled for the G buffer.
  49999. */
  50000. enableVelocity: boolean;
  50001. /**
  50002. * Gets the scene associated with the buffer.
  50003. */
  50004. readonly scene: Scene;
  50005. /**
  50006. * Gets the ratio used by the buffer during its creation.
  50007. * How big is the buffer related to the main canvas.
  50008. */
  50009. readonly ratio: number;
  50010. /** @hidden */
  50011. static _SceneComponentInitialization: (scene: Scene) => void;
  50012. /**
  50013. * Creates a new G Buffer for the scene
  50014. * @param scene The scene the buffer belongs to
  50015. * @param ratio How big is the buffer related to the main canvas.
  50016. */
  50017. constructor(scene: Scene, ratio?: number);
  50018. /**
  50019. * Checks wether everything is ready to render a submesh to the G buffer.
  50020. * @param subMesh the submesh to check readiness for
  50021. * @param useInstances is the mesh drawn using instance or not
  50022. * @returns true if ready otherwise false
  50023. */
  50024. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50025. /**
  50026. * Gets the current underlying G Buffer.
  50027. * @returns the buffer
  50028. */
  50029. getGBuffer(): MultiRenderTarget;
  50030. /**
  50031. * Gets the number of samples used to render the buffer (anti aliasing).
  50032. */
  50033. /**
  50034. * Sets the number of samples used to render the buffer (anti aliasing).
  50035. */
  50036. samples: number;
  50037. /**
  50038. * Disposes the renderer and frees up associated resources.
  50039. */
  50040. dispose(): void;
  50041. protected _createRenderTargets(): void;
  50042. }
  50043. }
  50044. declare module BABYLON {
  50045. /** @hidden */
  50046. export var motionBlurPixelShader: {
  50047. name: string;
  50048. shader: string;
  50049. };
  50050. }
  50051. declare module BABYLON {
  50052. /**
  50053. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  50054. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  50055. * As an example, all you have to do is to create the post-process:
  50056. * var mb = new BABYLON.MotionBlurPostProcess(
  50057. * 'mb', // The name of the effect.
  50058. * scene, // The scene containing the objects to blur according to their velocity.
  50059. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  50060. * camera // The camera to apply the render pass to.
  50061. * );
  50062. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  50063. */
  50064. export class MotionBlurPostProcess extends PostProcess {
  50065. /**
  50066. * Defines how much the image is blurred by the movement. Default value is equal to 1
  50067. */
  50068. motionStrength: number;
  50069. /**
  50070. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  50071. */
  50072. /**
  50073. * Sets the number of iterations to be used for motion blur quality
  50074. */
  50075. motionBlurSamples: number;
  50076. private _motionBlurSamples;
  50077. private _geometryBufferRenderer;
  50078. /**
  50079. * Creates a new instance MotionBlurPostProcess
  50080. * @param name The name of the effect.
  50081. * @param scene The scene containing the objects to blur according to their velocity.
  50082. * @param options The required width/height ratio to downsize to before computing the render pass.
  50083. * @param camera The camera to apply the render pass to.
  50084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50085. * @param engine The engine which the post process will be applied. (default: current engine)
  50086. * @param reusable If the post process can be reused on the same frame. (default: false)
  50087. * @param textureType Type of textures used when performing the post process. (default: 0)
  50088. * @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)
  50089. */
  50090. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50091. /**
  50092. * Disposes the post process.
  50093. * @param camera The camera to dispose the post process on.
  50094. */
  50095. dispose(camera?: Camera): void;
  50096. }
  50097. }
  50098. declare module BABYLON {
  50099. /** @hidden */
  50100. export var refractionPixelShader: {
  50101. name: string;
  50102. shader: string;
  50103. };
  50104. }
  50105. declare module BABYLON {
  50106. /**
  50107. * Post process which applies a refractin texture
  50108. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  50109. */
  50110. export class RefractionPostProcess extends PostProcess {
  50111. /** the base color of the refraction (used to taint the rendering) */
  50112. color: Color3;
  50113. /** simulated refraction depth */
  50114. depth: number;
  50115. /** the coefficient of the base color (0 to remove base color tainting) */
  50116. colorLevel: number;
  50117. private _refTexture;
  50118. private _ownRefractionTexture;
  50119. /**
  50120. * Gets or sets the refraction texture
  50121. * Please note that you are responsible for disposing the texture if you set it manually
  50122. */
  50123. refractionTexture: Texture;
  50124. /**
  50125. * Initializes the RefractionPostProcess
  50126. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  50127. * @param name The name of the effect.
  50128. * @param refractionTextureUrl Url of the refraction texture to use
  50129. * @param color the base color of the refraction (used to taint the rendering)
  50130. * @param depth simulated refraction depth
  50131. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  50132. * @param camera The camera to apply the render pass to.
  50133. * @param options The required width/height ratio to downsize to before computing the render pass.
  50134. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50135. * @param engine The engine which the post process will be applied. (default: current engine)
  50136. * @param reusable If the post process can be reused on the same frame. (default: false)
  50137. */
  50138. constructor(name: string, refractionTextureUrl: string,
  50139. /** the base color of the refraction (used to taint the rendering) */
  50140. color: Color3,
  50141. /** simulated refraction depth */
  50142. depth: number,
  50143. /** the coefficient of the base color (0 to remove base color tainting) */
  50144. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  50145. /**
  50146. * Disposes of the post process
  50147. * @param camera Camera to dispose post process on
  50148. */
  50149. dispose(camera: Camera): void;
  50150. }
  50151. }
  50152. declare module BABYLON {
  50153. /** @hidden */
  50154. export var sharpenPixelShader: {
  50155. name: string;
  50156. shader: string;
  50157. };
  50158. }
  50159. declare module BABYLON {
  50160. /**
  50161. * The SharpenPostProcess applies a sharpen kernel to every pixel
  50162. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  50163. */
  50164. export class SharpenPostProcess extends PostProcess {
  50165. /**
  50166. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  50167. */
  50168. colorAmount: number;
  50169. /**
  50170. * How much sharpness should be applied (default: 0.3)
  50171. */
  50172. edgeAmount: number;
  50173. /**
  50174. * Creates a new instance ConvolutionPostProcess
  50175. * @param name The name of the effect.
  50176. * @param options The required width/height ratio to downsize to before computing the render pass.
  50177. * @param camera The camera to apply the render pass to.
  50178. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50179. * @param engine The engine which the post process will be applied. (default: current engine)
  50180. * @param reusable If the post process can be reused on the same frame. (default: false)
  50181. * @param textureType Type of textures used when performing the post process. (default: 0)
  50182. * @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)
  50183. */
  50184. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50185. }
  50186. }
  50187. declare module BABYLON {
  50188. /**
  50189. * PostProcessRenderPipeline
  50190. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  50191. */
  50192. export class PostProcessRenderPipeline {
  50193. private engine;
  50194. private _renderEffects;
  50195. private _renderEffectsForIsolatedPass;
  50196. /**
  50197. * @hidden
  50198. */
  50199. protected _cameras: Camera[];
  50200. /** @hidden */
  50201. _name: string;
  50202. /**
  50203. * Initializes a PostProcessRenderPipeline
  50204. * @param engine engine to add the pipeline to
  50205. * @param name name of the pipeline
  50206. */
  50207. constructor(engine: Engine, name: string);
  50208. /**
  50209. * "PostProcessRenderPipeline"
  50210. * @returns "PostProcessRenderPipeline"
  50211. */
  50212. getClassName(): string;
  50213. /**
  50214. * If all the render effects in the pipeline are support
  50215. */
  50216. readonly isSupported: boolean;
  50217. /**
  50218. * Adds an effect to the pipeline
  50219. * @param renderEffect the effect to add
  50220. */
  50221. addEffect(renderEffect: PostProcessRenderEffect): void;
  50222. /** @hidden */
  50223. _rebuild(): void;
  50224. /** @hidden */
  50225. _enableEffect(renderEffectName: string, cameras: Camera): void;
  50226. /** @hidden */
  50227. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  50228. /** @hidden */
  50229. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  50230. /** @hidden */
  50231. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  50232. /** @hidden */
  50233. _attachCameras(cameras: Camera, unique: boolean): void;
  50234. /** @hidden */
  50235. _attachCameras(cameras: Camera[], unique: boolean): void;
  50236. /** @hidden */
  50237. _detachCameras(cameras: Camera): void;
  50238. /** @hidden */
  50239. _detachCameras(cameras: Nullable<Camera[]>): void;
  50240. /** @hidden */
  50241. _update(): void;
  50242. /** @hidden */
  50243. _reset(): void;
  50244. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  50245. /**
  50246. * Disposes of the pipeline
  50247. */
  50248. dispose(): void;
  50249. }
  50250. }
  50251. declare module BABYLON {
  50252. /**
  50253. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  50254. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  50255. */
  50256. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50257. private _scene;
  50258. private _camerasToBeAttached;
  50259. /**
  50260. * ID of the sharpen post process,
  50261. */
  50262. private readonly SharpenPostProcessId;
  50263. /**
  50264. * @ignore
  50265. * ID of the image processing post process;
  50266. */
  50267. readonly ImageProcessingPostProcessId: string;
  50268. /**
  50269. * @ignore
  50270. * ID of the Fast Approximate Anti-Aliasing post process;
  50271. */
  50272. readonly FxaaPostProcessId: string;
  50273. /**
  50274. * ID of the chromatic aberration post process,
  50275. */
  50276. private readonly ChromaticAberrationPostProcessId;
  50277. /**
  50278. * ID of the grain post process
  50279. */
  50280. private readonly GrainPostProcessId;
  50281. /**
  50282. * Sharpen post process which will apply a sharpen convolution to enhance edges
  50283. */
  50284. sharpen: SharpenPostProcess;
  50285. private _sharpenEffect;
  50286. private bloom;
  50287. /**
  50288. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  50289. */
  50290. depthOfField: DepthOfFieldEffect;
  50291. /**
  50292. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50293. */
  50294. fxaa: FxaaPostProcess;
  50295. /**
  50296. * Image post processing pass used to perform operations such as tone mapping or color grading.
  50297. */
  50298. imageProcessing: ImageProcessingPostProcess;
  50299. /**
  50300. * Chromatic aberration post process which will shift rgb colors in the image
  50301. */
  50302. chromaticAberration: ChromaticAberrationPostProcess;
  50303. private _chromaticAberrationEffect;
  50304. /**
  50305. * Grain post process which add noise to the image
  50306. */
  50307. grain: GrainPostProcess;
  50308. private _grainEffect;
  50309. /**
  50310. * Glow post process which adds a glow to emmisive areas of the image
  50311. */
  50312. private _glowLayer;
  50313. /**
  50314. * Animations which can be used to tweak settings over a period of time
  50315. */
  50316. animations: Animation[];
  50317. private _imageProcessingConfigurationObserver;
  50318. private _sharpenEnabled;
  50319. private _bloomEnabled;
  50320. private _depthOfFieldEnabled;
  50321. private _depthOfFieldBlurLevel;
  50322. private _fxaaEnabled;
  50323. private _imageProcessingEnabled;
  50324. private _defaultPipelineTextureType;
  50325. private _bloomScale;
  50326. private _chromaticAberrationEnabled;
  50327. private _grainEnabled;
  50328. private _buildAllowed;
  50329. /**
  50330. * Enable or disable the sharpen process from the pipeline
  50331. */
  50332. sharpenEnabled: boolean;
  50333. private _resizeObserver;
  50334. private _hardwareScaleLevel;
  50335. private _bloomKernel;
  50336. /**
  50337. * Specifies the size of the bloom blur kernel, relative to the final output size
  50338. */
  50339. bloomKernel: number;
  50340. /**
  50341. * Specifies the weight of the bloom in the final rendering
  50342. */
  50343. private _bloomWeight;
  50344. /**
  50345. * Specifies the luma threshold for the area that will be blurred by the bloom
  50346. */
  50347. private _bloomThreshold;
  50348. private _hdr;
  50349. /**
  50350. * The strength of the bloom.
  50351. */
  50352. bloomWeight: number;
  50353. /**
  50354. * The strength of the bloom.
  50355. */
  50356. bloomThreshold: number;
  50357. /**
  50358. * The scale of the bloom, lower value will provide better performance.
  50359. */
  50360. bloomScale: number;
  50361. /**
  50362. * Enable or disable the bloom from the pipeline
  50363. */
  50364. bloomEnabled: boolean;
  50365. private _rebuildBloom;
  50366. /**
  50367. * If the depth of field is enabled.
  50368. */
  50369. depthOfFieldEnabled: boolean;
  50370. /**
  50371. * Blur level of the depth of field effect. (Higher blur will effect performance)
  50372. */
  50373. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  50374. /**
  50375. * If the anti aliasing is enabled.
  50376. */
  50377. fxaaEnabled: boolean;
  50378. private _samples;
  50379. /**
  50380. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50381. */
  50382. samples: number;
  50383. /**
  50384. * If image processing is enabled.
  50385. */
  50386. imageProcessingEnabled: boolean;
  50387. /**
  50388. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  50389. */
  50390. glowLayerEnabled: boolean;
  50391. /**
  50392. * Enable or disable the chromaticAberration process from the pipeline
  50393. */
  50394. chromaticAberrationEnabled: boolean;
  50395. /**
  50396. * Enable or disable the grain process from the pipeline
  50397. */
  50398. grainEnabled: boolean;
  50399. /**
  50400. * @constructor
  50401. * @param name - The rendering pipeline name (default: "")
  50402. * @param hdr - If high dynamic range textures should be used (default: true)
  50403. * @param scene - The scene linked to this pipeline (default: the last created scene)
  50404. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  50405. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  50406. */
  50407. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  50408. /**
  50409. * Force the compilation of the entire pipeline.
  50410. */
  50411. prepare(): void;
  50412. private _hasCleared;
  50413. private _prevPostProcess;
  50414. private _prevPrevPostProcess;
  50415. private _setAutoClearAndTextureSharing;
  50416. private _depthOfFieldSceneObserver;
  50417. private _buildPipeline;
  50418. private _disposePostProcesses;
  50419. /**
  50420. * Adds a camera to the pipeline
  50421. * @param camera the camera to be added
  50422. */
  50423. addCamera(camera: Camera): void;
  50424. /**
  50425. * Removes a camera from the pipeline
  50426. * @param camera the camera to remove
  50427. */
  50428. removeCamera(camera: Camera): void;
  50429. /**
  50430. * Dispose of the pipeline and stop all post processes
  50431. */
  50432. dispose(): void;
  50433. /**
  50434. * Serialize the rendering pipeline (Used when exporting)
  50435. * @returns the serialized object
  50436. */
  50437. serialize(): any;
  50438. /**
  50439. * Parse the serialized pipeline
  50440. * @param source Source pipeline.
  50441. * @param scene The scene to load the pipeline to.
  50442. * @param rootUrl The URL of the serialized pipeline.
  50443. * @returns An instantiated pipeline from the serialized object.
  50444. */
  50445. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  50446. }
  50447. }
  50448. declare module BABYLON {
  50449. /** @hidden */
  50450. export var lensHighlightsPixelShader: {
  50451. name: string;
  50452. shader: string;
  50453. };
  50454. }
  50455. declare module BABYLON {
  50456. /** @hidden */
  50457. export var depthOfFieldPixelShader: {
  50458. name: string;
  50459. shader: string;
  50460. };
  50461. }
  50462. declare module BABYLON {
  50463. /**
  50464. * BABYLON.JS Chromatic Aberration GLSL Shader
  50465. * Author: Olivier Guyot
  50466. * Separates very slightly R, G and B colors on the edges of the screen
  50467. * Inspired by Francois Tarlier & Martins Upitis
  50468. */
  50469. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  50470. /**
  50471. * @ignore
  50472. * The chromatic aberration PostProcess id in the pipeline
  50473. */
  50474. LensChromaticAberrationEffect: string;
  50475. /**
  50476. * @ignore
  50477. * The highlights enhancing PostProcess id in the pipeline
  50478. */
  50479. HighlightsEnhancingEffect: string;
  50480. /**
  50481. * @ignore
  50482. * The depth-of-field PostProcess id in the pipeline
  50483. */
  50484. LensDepthOfFieldEffect: string;
  50485. private _scene;
  50486. private _depthTexture;
  50487. private _grainTexture;
  50488. private _chromaticAberrationPostProcess;
  50489. private _highlightsPostProcess;
  50490. private _depthOfFieldPostProcess;
  50491. private _edgeBlur;
  50492. private _grainAmount;
  50493. private _chromaticAberration;
  50494. private _distortion;
  50495. private _highlightsGain;
  50496. private _highlightsThreshold;
  50497. private _dofDistance;
  50498. private _dofAperture;
  50499. private _dofDarken;
  50500. private _dofPentagon;
  50501. private _blurNoise;
  50502. /**
  50503. * @constructor
  50504. *
  50505. * Effect parameters are as follow:
  50506. * {
  50507. * chromatic_aberration: number; // from 0 to x (1 for realism)
  50508. * edge_blur: number; // from 0 to x (1 for realism)
  50509. * distortion: number; // from 0 to x (1 for realism)
  50510. * grain_amount: number; // from 0 to 1
  50511. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  50512. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  50513. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  50514. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  50515. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  50516. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  50517. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  50518. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  50519. * }
  50520. * Note: if an effect parameter is unset, effect is disabled
  50521. *
  50522. * @param name The rendering pipeline name
  50523. * @param parameters - An object containing all parameters (see above)
  50524. * @param scene The scene linked to this pipeline
  50525. * @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)
  50526. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50527. */
  50528. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  50529. /**
  50530. * Sets the amount of blur at the edges
  50531. * @param amount blur amount
  50532. */
  50533. setEdgeBlur(amount: number): void;
  50534. /**
  50535. * Sets edge blur to 0
  50536. */
  50537. disableEdgeBlur(): void;
  50538. /**
  50539. * Sets the amout of grain
  50540. * @param amount Amount of grain
  50541. */
  50542. setGrainAmount(amount: number): void;
  50543. /**
  50544. * Set grain amount to 0
  50545. */
  50546. disableGrain(): void;
  50547. /**
  50548. * Sets the chromatic aberration amount
  50549. * @param amount amount of chromatic aberration
  50550. */
  50551. setChromaticAberration(amount: number): void;
  50552. /**
  50553. * Sets chromatic aberration amount to 0
  50554. */
  50555. disableChromaticAberration(): void;
  50556. /**
  50557. * Sets the EdgeDistortion amount
  50558. * @param amount amount of EdgeDistortion
  50559. */
  50560. setEdgeDistortion(amount: number): void;
  50561. /**
  50562. * Sets edge distortion to 0
  50563. */
  50564. disableEdgeDistortion(): void;
  50565. /**
  50566. * Sets the FocusDistance amount
  50567. * @param amount amount of FocusDistance
  50568. */
  50569. setFocusDistance(amount: number): void;
  50570. /**
  50571. * Disables depth of field
  50572. */
  50573. disableDepthOfField(): void;
  50574. /**
  50575. * Sets the Aperture amount
  50576. * @param amount amount of Aperture
  50577. */
  50578. setAperture(amount: number): void;
  50579. /**
  50580. * Sets the DarkenOutOfFocus amount
  50581. * @param amount amount of DarkenOutOfFocus
  50582. */
  50583. setDarkenOutOfFocus(amount: number): void;
  50584. /**
  50585. * Creates a pentagon bokeh effect
  50586. */
  50587. enablePentagonBokeh(): void;
  50588. /**
  50589. * Disables the pentagon bokeh effect
  50590. */
  50591. disablePentagonBokeh(): void;
  50592. /**
  50593. * Enables noise blur
  50594. */
  50595. enableNoiseBlur(): void;
  50596. /**
  50597. * Disables noise blur
  50598. */
  50599. disableNoiseBlur(): void;
  50600. /**
  50601. * Sets the HighlightsGain amount
  50602. * @param amount amount of HighlightsGain
  50603. */
  50604. setHighlightsGain(amount: number): void;
  50605. /**
  50606. * Sets the HighlightsThreshold amount
  50607. * @param amount amount of HighlightsThreshold
  50608. */
  50609. setHighlightsThreshold(amount: number): void;
  50610. /**
  50611. * Disables highlights
  50612. */
  50613. disableHighlights(): void;
  50614. /**
  50615. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  50616. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  50617. */
  50618. dispose(disableDepthRender?: boolean): void;
  50619. private _createChromaticAberrationPostProcess;
  50620. private _createHighlightsPostProcess;
  50621. private _createDepthOfFieldPostProcess;
  50622. private _createGrainTexture;
  50623. }
  50624. }
  50625. declare module BABYLON {
  50626. /** @hidden */
  50627. export var ssao2PixelShader: {
  50628. name: string;
  50629. shader: string;
  50630. };
  50631. }
  50632. declare module BABYLON {
  50633. /** @hidden */
  50634. export var ssaoCombinePixelShader: {
  50635. name: string;
  50636. shader: string;
  50637. };
  50638. }
  50639. declare module BABYLON {
  50640. /**
  50641. * Render pipeline to produce ssao effect
  50642. */
  50643. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  50644. /**
  50645. * @ignore
  50646. * The PassPostProcess id in the pipeline that contains the original scene color
  50647. */
  50648. SSAOOriginalSceneColorEffect: string;
  50649. /**
  50650. * @ignore
  50651. * The SSAO PostProcess id in the pipeline
  50652. */
  50653. SSAORenderEffect: string;
  50654. /**
  50655. * @ignore
  50656. * The horizontal blur PostProcess id in the pipeline
  50657. */
  50658. SSAOBlurHRenderEffect: string;
  50659. /**
  50660. * @ignore
  50661. * The vertical blur PostProcess id in the pipeline
  50662. */
  50663. SSAOBlurVRenderEffect: string;
  50664. /**
  50665. * @ignore
  50666. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50667. */
  50668. SSAOCombineRenderEffect: string;
  50669. /**
  50670. * The output strength of the SSAO post-process. Default value is 1.0.
  50671. */
  50672. totalStrength: number;
  50673. /**
  50674. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50675. */
  50676. maxZ: number;
  50677. /**
  50678. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50679. */
  50680. minZAspect: number;
  50681. private _samples;
  50682. /**
  50683. * Number of samples used for the SSAO calculations. Default value is 8
  50684. */
  50685. samples: number;
  50686. private _textureSamples;
  50687. /**
  50688. * Number of samples to use for antialiasing
  50689. */
  50690. textureSamples: number;
  50691. /**
  50692. * Ratio object used for SSAO ratio and blur ratio
  50693. */
  50694. private _ratio;
  50695. /**
  50696. * Dynamically generated sphere sampler.
  50697. */
  50698. private _sampleSphere;
  50699. /**
  50700. * Blur filter offsets
  50701. */
  50702. private _samplerOffsets;
  50703. private _expensiveBlur;
  50704. /**
  50705. * If bilateral blur should be used
  50706. */
  50707. expensiveBlur: boolean;
  50708. /**
  50709. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50710. */
  50711. radius: number;
  50712. /**
  50713. * The base color of the SSAO post-process
  50714. * The final result is "base + ssao" between [0, 1]
  50715. */
  50716. base: number;
  50717. /**
  50718. * Support test.
  50719. */
  50720. static readonly IsSupported: boolean;
  50721. private _scene;
  50722. private _depthTexture;
  50723. private _normalTexture;
  50724. private _randomTexture;
  50725. private _originalColorPostProcess;
  50726. private _ssaoPostProcess;
  50727. private _blurHPostProcess;
  50728. private _blurVPostProcess;
  50729. private _ssaoCombinePostProcess;
  50730. private _firstUpdate;
  50731. /**
  50732. * @constructor
  50733. * @param name The rendering pipeline name
  50734. * @param scene The scene linked to this pipeline
  50735. * @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 }
  50736. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50737. */
  50738. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50739. /**
  50740. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50741. */
  50742. dispose(disableGeometryBufferRenderer?: boolean): void;
  50743. private _createBlurPostProcess;
  50744. /** @hidden */
  50745. _rebuild(): void;
  50746. private _bits;
  50747. private _radicalInverse_VdC;
  50748. private _hammersley;
  50749. private _hemisphereSample_uniform;
  50750. private _generateHemisphere;
  50751. private _createSSAOPostProcess;
  50752. private _createSSAOCombinePostProcess;
  50753. private _createRandomTexture;
  50754. /**
  50755. * Serialize the rendering pipeline (Used when exporting)
  50756. * @returns the serialized object
  50757. */
  50758. serialize(): any;
  50759. /**
  50760. * Parse the serialized pipeline
  50761. * @param source Source pipeline.
  50762. * @param scene The scene to load the pipeline to.
  50763. * @param rootUrl The URL of the serialized pipeline.
  50764. * @returns An instantiated pipeline from the serialized object.
  50765. */
  50766. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50767. }
  50768. }
  50769. declare module BABYLON {
  50770. /** @hidden */
  50771. export var ssaoPixelShader: {
  50772. name: string;
  50773. shader: string;
  50774. };
  50775. }
  50776. declare module BABYLON {
  50777. /**
  50778. * Render pipeline to produce ssao effect
  50779. */
  50780. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50781. /**
  50782. * @ignore
  50783. * The PassPostProcess id in the pipeline that contains the original scene color
  50784. */
  50785. SSAOOriginalSceneColorEffect: string;
  50786. /**
  50787. * @ignore
  50788. * The SSAO PostProcess id in the pipeline
  50789. */
  50790. SSAORenderEffect: string;
  50791. /**
  50792. * @ignore
  50793. * The horizontal blur PostProcess id in the pipeline
  50794. */
  50795. SSAOBlurHRenderEffect: string;
  50796. /**
  50797. * @ignore
  50798. * The vertical blur PostProcess id in the pipeline
  50799. */
  50800. SSAOBlurVRenderEffect: string;
  50801. /**
  50802. * @ignore
  50803. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50804. */
  50805. SSAOCombineRenderEffect: string;
  50806. /**
  50807. * The output strength of the SSAO post-process. Default value is 1.0.
  50808. */
  50809. totalStrength: number;
  50810. /**
  50811. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50812. */
  50813. radius: number;
  50814. /**
  50815. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50816. * Must not be equal to fallOff and superior to fallOff.
  50817. * Default value is 0.975
  50818. */
  50819. area: number;
  50820. /**
  50821. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50822. * Must not be equal to area and inferior to area.
  50823. * Default value is 0.0
  50824. */
  50825. fallOff: number;
  50826. /**
  50827. * The base color of the SSAO post-process
  50828. * The final result is "base + ssao" between [0, 1]
  50829. */
  50830. base: number;
  50831. private _scene;
  50832. private _depthTexture;
  50833. private _randomTexture;
  50834. private _originalColorPostProcess;
  50835. private _ssaoPostProcess;
  50836. private _blurHPostProcess;
  50837. private _blurVPostProcess;
  50838. private _ssaoCombinePostProcess;
  50839. private _firstUpdate;
  50840. /**
  50841. * @constructor
  50842. * @param name - The rendering pipeline name
  50843. * @param scene - The scene linked to this pipeline
  50844. * @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 }
  50845. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  50846. */
  50847. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50848. /**
  50849. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50850. */
  50851. dispose(disableDepthRender?: boolean): void;
  50852. private _createBlurPostProcess;
  50853. /** @hidden */
  50854. _rebuild(): void;
  50855. private _createSSAOPostProcess;
  50856. private _createSSAOCombinePostProcess;
  50857. private _createRandomTexture;
  50858. }
  50859. }
  50860. declare module BABYLON {
  50861. /** @hidden */
  50862. export var standardPixelShader: {
  50863. name: string;
  50864. shader: string;
  50865. };
  50866. }
  50867. declare module BABYLON {
  50868. /**
  50869. * Standard rendering pipeline
  50870. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50871. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  50872. */
  50873. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50874. /**
  50875. * Public members
  50876. */
  50877. /**
  50878. * Post-process which contains the original scene color before the pipeline applies all the effects
  50879. */
  50880. originalPostProcess: Nullable<PostProcess>;
  50881. /**
  50882. * Post-process used to down scale an image x4
  50883. */
  50884. downSampleX4PostProcess: Nullable<PostProcess>;
  50885. /**
  50886. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  50887. */
  50888. brightPassPostProcess: Nullable<PostProcess>;
  50889. /**
  50890. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  50891. */
  50892. blurHPostProcesses: PostProcess[];
  50893. /**
  50894. * Post-process array storing all the vertical blur post-processes used by the pipeline
  50895. */
  50896. blurVPostProcesses: PostProcess[];
  50897. /**
  50898. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  50899. */
  50900. textureAdderPostProcess: Nullable<PostProcess>;
  50901. /**
  50902. * Post-process used to create volumetric lighting effect
  50903. */
  50904. volumetricLightPostProcess: Nullable<PostProcess>;
  50905. /**
  50906. * Post-process used to smooth the previous volumetric light post-process on the X axis
  50907. */
  50908. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  50909. /**
  50910. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  50911. */
  50912. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  50913. /**
  50914. * Post-process used to merge the volumetric light effect and the real scene color
  50915. */
  50916. volumetricLightMergePostProces: Nullable<PostProcess>;
  50917. /**
  50918. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  50919. */
  50920. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  50921. /**
  50922. * Base post-process used to calculate the average luminance of the final image for HDR
  50923. */
  50924. luminancePostProcess: Nullable<PostProcess>;
  50925. /**
  50926. * Post-processes used to create down sample post-processes in order to get
  50927. * the average luminance of the final image for HDR
  50928. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  50929. */
  50930. luminanceDownSamplePostProcesses: PostProcess[];
  50931. /**
  50932. * Post-process used to create a HDR effect (light adaptation)
  50933. */
  50934. hdrPostProcess: Nullable<PostProcess>;
  50935. /**
  50936. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  50937. */
  50938. textureAdderFinalPostProcess: Nullable<PostProcess>;
  50939. /**
  50940. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  50941. */
  50942. lensFlareFinalPostProcess: Nullable<PostProcess>;
  50943. /**
  50944. * Post-process used to merge the final HDR post-process and the real scene color
  50945. */
  50946. hdrFinalPostProcess: Nullable<PostProcess>;
  50947. /**
  50948. * Post-process used to create a lens flare effect
  50949. */
  50950. lensFlarePostProcess: Nullable<PostProcess>;
  50951. /**
  50952. * Post-process that merges the result of the lens flare post-process and the real scene color
  50953. */
  50954. lensFlareComposePostProcess: Nullable<PostProcess>;
  50955. /**
  50956. * Post-process used to create a motion blur effect
  50957. */
  50958. motionBlurPostProcess: Nullable<PostProcess>;
  50959. /**
  50960. * Post-process used to create a depth of field effect
  50961. */
  50962. depthOfFieldPostProcess: Nullable<PostProcess>;
  50963. /**
  50964. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50965. */
  50966. fxaaPostProcess: Nullable<FxaaPostProcess>;
  50967. /**
  50968. * Represents the brightness threshold in order to configure the illuminated surfaces
  50969. */
  50970. brightThreshold: number;
  50971. /**
  50972. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  50973. */
  50974. blurWidth: number;
  50975. /**
  50976. * Sets if the blur for highlighted surfaces must be only horizontal
  50977. */
  50978. horizontalBlur: boolean;
  50979. /**
  50980. * Sets the overall exposure used by the pipeline
  50981. */
  50982. exposure: number;
  50983. /**
  50984. * Texture used typically to simulate "dirty" on camera lens
  50985. */
  50986. lensTexture: Nullable<Texture>;
  50987. /**
  50988. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  50989. */
  50990. volumetricLightCoefficient: number;
  50991. /**
  50992. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  50993. */
  50994. volumetricLightPower: number;
  50995. /**
  50996. * Used the set the blur intensity to smooth the volumetric lights
  50997. */
  50998. volumetricLightBlurScale: number;
  50999. /**
  51000. * Light (spot or directional) used to generate the volumetric lights rays
  51001. * The source light must have a shadow generate so the pipeline can get its
  51002. * depth map
  51003. */
  51004. sourceLight: Nullable<SpotLight | DirectionalLight>;
  51005. /**
  51006. * For eye adaptation, represents the minimum luminance the eye can see
  51007. */
  51008. hdrMinimumLuminance: number;
  51009. /**
  51010. * For eye adaptation, represents the decrease luminance speed
  51011. */
  51012. hdrDecreaseRate: number;
  51013. /**
  51014. * For eye adaptation, represents the increase luminance speed
  51015. */
  51016. hdrIncreaseRate: number;
  51017. /**
  51018. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  51019. */
  51020. lensColorTexture: Nullable<Texture>;
  51021. /**
  51022. * The overall strengh for the lens flare effect
  51023. */
  51024. lensFlareStrength: number;
  51025. /**
  51026. * Dispersion coefficient for lens flare ghosts
  51027. */
  51028. lensFlareGhostDispersal: number;
  51029. /**
  51030. * Main lens flare halo width
  51031. */
  51032. lensFlareHaloWidth: number;
  51033. /**
  51034. * Based on the lens distortion effect, defines how much the lens flare result
  51035. * is distorted
  51036. */
  51037. lensFlareDistortionStrength: number;
  51038. /**
  51039. * Lens star texture must be used to simulate rays on the flares and is available
  51040. * in the documentation
  51041. */
  51042. lensStarTexture: Nullable<Texture>;
  51043. /**
  51044. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  51045. * flare effect by taking account of the dirt texture
  51046. */
  51047. lensFlareDirtTexture: Nullable<Texture>;
  51048. /**
  51049. * Represents the focal length for the depth of field effect
  51050. */
  51051. depthOfFieldDistance: number;
  51052. /**
  51053. * Represents the blur intensity for the blurred part of the depth of field effect
  51054. */
  51055. depthOfFieldBlurWidth: number;
  51056. /**
  51057. * For motion blur, defines how much the image is blurred by the movement
  51058. */
  51059. motionStrength: number;
  51060. /**
  51061. * List of animations for the pipeline (IAnimatable implementation)
  51062. */
  51063. animations: Animation[];
  51064. /**
  51065. * Private members
  51066. */
  51067. private _scene;
  51068. private _currentDepthOfFieldSource;
  51069. private _basePostProcess;
  51070. private _hdrCurrentLuminance;
  51071. private _floatTextureType;
  51072. private _ratio;
  51073. private _bloomEnabled;
  51074. private _depthOfFieldEnabled;
  51075. private _vlsEnabled;
  51076. private _lensFlareEnabled;
  51077. private _hdrEnabled;
  51078. private _motionBlurEnabled;
  51079. private _fxaaEnabled;
  51080. private _motionBlurSamples;
  51081. private _volumetricLightStepsCount;
  51082. private _samples;
  51083. /**
  51084. * @ignore
  51085. * Specifies if the bloom pipeline is enabled
  51086. */
  51087. BloomEnabled: boolean;
  51088. /**
  51089. * @ignore
  51090. * Specifies if the depth of field pipeline is enabed
  51091. */
  51092. DepthOfFieldEnabled: boolean;
  51093. /**
  51094. * @ignore
  51095. * Specifies if the lens flare pipeline is enabed
  51096. */
  51097. LensFlareEnabled: boolean;
  51098. /**
  51099. * @ignore
  51100. * Specifies if the HDR pipeline is enabled
  51101. */
  51102. HDREnabled: boolean;
  51103. /**
  51104. * @ignore
  51105. * Specifies if the volumetric lights scattering effect is enabled
  51106. */
  51107. VLSEnabled: boolean;
  51108. /**
  51109. * @ignore
  51110. * Specifies if the motion blur effect is enabled
  51111. */
  51112. MotionBlurEnabled: boolean;
  51113. /**
  51114. * Specifies if anti-aliasing is enabled
  51115. */
  51116. fxaaEnabled: boolean;
  51117. /**
  51118. * Specifies the number of steps used to calculate the volumetric lights
  51119. * Typically in interval [50, 200]
  51120. */
  51121. volumetricLightStepsCount: number;
  51122. /**
  51123. * Specifies the number of samples used for the motion blur effect
  51124. * Typically in interval [16, 64]
  51125. */
  51126. motionBlurSamples: number;
  51127. /**
  51128. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  51129. */
  51130. samples: number;
  51131. /**
  51132. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  51133. * @constructor
  51134. * @param name The rendering pipeline name
  51135. * @param scene The scene linked to this pipeline
  51136. * @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)
  51137. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  51138. * @param cameras The array of cameras that the rendering pipeline will be attached to
  51139. */
  51140. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  51141. private _buildPipeline;
  51142. private _createDownSampleX4PostProcess;
  51143. private _createBrightPassPostProcess;
  51144. private _createBlurPostProcesses;
  51145. private _createTextureAdderPostProcess;
  51146. private _createVolumetricLightPostProcess;
  51147. private _createLuminancePostProcesses;
  51148. private _createHdrPostProcess;
  51149. private _createLensFlarePostProcess;
  51150. private _createDepthOfFieldPostProcess;
  51151. private _createMotionBlurPostProcess;
  51152. private _getDepthTexture;
  51153. private _disposePostProcesses;
  51154. /**
  51155. * Dispose of the pipeline and stop all post processes
  51156. */
  51157. dispose(): void;
  51158. /**
  51159. * Serialize the rendering pipeline (Used when exporting)
  51160. * @returns the serialized object
  51161. */
  51162. serialize(): any;
  51163. /**
  51164. * Parse the serialized pipeline
  51165. * @param source Source pipeline.
  51166. * @param scene The scene to load the pipeline to.
  51167. * @param rootUrl The URL of the serialized pipeline.
  51168. * @returns An instantiated pipeline from the serialized object.
  51169. */
  51170. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  51171. /**
  51172. * Luminance steps
  51173. */
  51174. static LuminanceSteps: number;
  51175. }
  51176. }
  51177. declare module BABYLON {
  51178. /**
  51179. * PostProcessRenderPipelineManager class
  51180. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51181. */
  51182. export class PostProcessRenderPipelineManager {
  51183. private _renderPipelines;
  51184. /**
  51185. * Initializes a PostProcessRenderPipelineManager
  51186. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51187. */
  51188. constructor();
  51189. /**
  51190. * Adds a pipeline to the manager
  51191. * @param renderPipeline The pipeline to add
  51192. */
  51193. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  51194. /**
  51195. * Attaches a camera to the pipeline
  51196. * @param renderPipelineName The name of the pipeline to attach to
  51197. * @param cameras the camera to attach
  51198. * @param unique if the camera can be attached multiple times to the pipeline
  51199. */
  51200. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  51201. /**
  51202. * Detaches a camera from the pipeline
  51203. * @param renderPipelineName The name of the pipeline to detach from
  51204. * @param cameras the camera to detach
  51205. */
  51206. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  51207. /**
  51208. * Enables an effect by name on a pipeline
  51209. * @param renderPipelineName the name of the pipeline to enable the effect in
  51210. * @param renderEffectName the name of the effect to enable
  51211. * @param cameras the cameras that the effect should be enabled on
  51212. */
  51213. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  51214. /**
  51215. * Disables an effect by name on a pipeline
  51216. * @param renderPipelineName the name of the pipeline to disable the effect in
  51217. * @param renderEffectName the name of the effect to disable
  51218. * @param cameras the cameras that the effect should be disabled on
  51219. */
  51220. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  51221. /**
  51222. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  51223. */
  51224. update(): void;
  51225. /** @hidden */
  51226. _rebuild(): void;
  51227. /**
  51228. * Disposes of the manager and pipelines
  51229. */
  51230. dispose(): void;
  51231. }
  51232. }
  51233. declare module BABYLON {
  51234. interface Scene {
  51235. /** @hidden (Backing field) */
  51236. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  51237. /**
  51238. * Gets the postprocess render pipeline manager
  51239. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51240. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  51241. */
  51242. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  51243. }
  51244. /**
  51245. * Defines the Render Pipeline scene component responsible to rendering pipelines
  51246. */
  51247. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  51248. /**
  51249. * The component name helpfull to identify the component in the list of scene components.
  51250. */
  51251. readonly name: string;
  51252. /**
  51253. * The scene the component belongs to.
  51254. */
  51255. scene: Scene;
  51256. /**
  51257. * Creates a new instance of the component for the given scene
  51258. * @param scene Defines the scene to register the component in
  51259. */
  51260. constructor(scene: Scene);
  51261. /**
  51262. * Registers the component in a given scene
  51263. */
  51264. register(): void;
  51265. /**
  51266. * Rebuilds the elements related to this component in case of
  51267. * context lost for instance.
  51268. */
  51269. rebuild(): void;
  51270. /**
  51271. * Disposes the component and the associated ressources
  51272. */
  51273. dispose(): void;
  51274. private _gatherRenderTargets;
  51275. }
  51276. }
  51277. declare module BABYLON {
  51278. /** @hidden */
  51279. export var tonemapPixelShader: {
  51280. name: string;
  51281. shader: string;
  51282. };
  51283. }
  51284. declare module BABYLON {
  51285. /** Defines operator used for tonemapping */
  51286. export enum TonemappingOperator {
  51287. /** Hable */
  51288. Hable = 0,
  51289. /** Reinhard */
  51290. Reinhard = 1,
  51291. /** HejiDawson */
  51292. HejiDawson = 2,
  51293. /** Photographic */
  51294. Photographic = 3
  51295. }
  51296. /**
  51297. * Defines a post process to apply tone mapping
  51298. */
  51299. export class TonemapPostProcess extends PostProcess {
  51300. private _operator;
  51301. /** Defines the required exposure adjustement */
  51302. exposureAdjustment: number;
  51303. /**
  51304. * Creates a new TonemapPostProcess
  51305. * @param name defines the name of the postprocess
  51306. * @param _operator defines the operator to use
  51307. * @param exposureAdjustment defines the required exposure adjustement
  51308. * @param camera defines the camera to use (can be null)
  51309. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  51310. * @param engine defines the hosting engine (can be ignore if camera is set)
  51311. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51312. */
  51313. constructor(name: string, _operator: TonemappingOperator,
  51314. /** Defines the required exposure adjustement */
  51315. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  51316. }
  51317. }
  51318. declare module BABYLON {
  51319. /** @hidden */
  51320. export var depthVertexShader: {
  51321. name: string;
  51322. shader: string;
  51323. };
  51324. }
  51325. declare module BABYLON {
  51326. /** @hidden */
  51327. export var volumetricLightScatteringPixelShader: {
  51328. name: string;
  51329. shader: string;
  51330. };
  51331. }
  51332. declare module BABYLON {
  51333. /** @hidden */
  51334. export var volumetricLightScatteringPassPixelShader: {
  51335. name: string;
  51336. shader: string;
  51337. };
  51338. }
  51339. declare module BABYLON {
  51340. /**
  51341. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  51342. */
  51343. export class VolumetricLightScatteringPostProcess extends PostProcess {
  51344. private _volumetricLightScatteringPass;
  51345. private _volumetricLightScatteringRTT;
  51346. private _viewPort;
  51347. private _screenCoordinates;
  51348. private _cachedDefines;
  51349. /**
  51350. * If not undefined, the mesh position is computed from the attached node position
  51351. */
  51352. attachedNode: {
  51353. position: Vector3;
  51354. };
  51355. /**
  51356. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  51357. */
  51358. customMeshPosition: Vector3;
  51359. /**
  51360. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  51361. */
  51362. useCustomMeshPosition: boolean;
  51363. /**
  51364. * If the post-process should inverse the light scattering direction
  51365. */
  51366. invert: boolean;
  51367. /**
  51368. * The internal mesh used by the post-process
  51369. */
  51370. mesh: Mesh;
  51371. /**
  51372. * @hidden
  51373. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  51374. */
  51375. useDiffuseColor: boolean;
  51376. /**
  51377. * Array containing the excluded meshes not rendered in the internal pass
  51378. */
  51379. excludedMeshes: AbstractMesh[];
  51380. /**
  51381. * Controls the overall intensity of the post-process
  51382. */
  51383. exposure: number;
  51384. /**
  51385. * Dissipates each sample's contribution in range [0, 1]
  51386. */
  51387. decay: number;
  51388. /**
  51389. * Controls the overall intensity of each sample
  51390. */
  51391. weight: number;
  51392. /**
  51393. * Controls the density of each sample
  51394. */
  51395. density: number;
  51396. /**
  51397. * @constructor
  51398. * @param name The post-process name
  51399. * @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)
  51400. * @param camera The camera that the post-process will be attached to
  51401. * @param mesh The mesh used to create the light scattering
  51402. * @param samples The post-process quality, default 100
  51403. * @param samplingModeThe post-process filtering mode
  51404. * @param engine The babylon engine
  51405. * @param reusable If the post-process is reusable
  51406. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  51407. */
  51408. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  51409. /**
  51410. * Returns the string "VolumetricLightScatteringPostProcess"
  51411. * @returns "VolumetricLightScatteringPostProcess"
  51412. */
  51413. getClassName(): string;
  51414. private _isReady;
  51415. /**
  51416. * Sets the new light position for light scattering effect
  51417. * @param position The new custom light position
  51418. */
  51419. setCustomMeshPosition(position: Vector3): void;
  51420. /**
  51421. * Returns the light position for light scattering effect
  51422. * @return Vector3 The custom light position
  51423. */
  51424. getCustomMeshPosition(): Vector3;
  51425. /**
  51426. * Disposes the internal assets and detaches the post-process from the camera
  51427. */
  51428. dispose(camera: Camera): void;
  51429. /**
  51430. * Returns the render target texture used by the post-process
  51431. * @return the render target texture used by the post-process
  51432. */
  51433. getPass(): RenderTargetTexture;
  51434. private _meshExcluded;
  51435. private _createPass;
  51436. private _updateMeshScreenCoordinates;
  51437. /**
  51438. * Creates a default mesh for the Volumeric Light Scattering post-process
  51439. * @param name The mesh name
  51440. * @param scene The scene where to create the mesh
  51441. * @return the default mesh
  51442. */
  51443. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  51444. }
  51445. }
  51446. declare module BABYLON {
  51447. interface Scene {
  51448. /** @hidden (Backing field) */
  51449. _boundingBoxRenderer: BoundingBoxRenderer;
  51450. /** @hidden (Backing field) */
  51451. _forceShowBoundingBoxes: boolean;
  51452. /**
  51453. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  51454. */
  51455. forceShowBoundingBoxes: boolean;
  51456. /**
  51457. * Gets the bounding box renderer associated with the scene
  51458. * @returns a BoundingBoxRenderer
  51459. */
  51460. getBoundingBoxRenderer(): BoundingBoxRenderer;
  51461. }
  51462. interface AbstractMesh {
  51463. /** @hidden (Backing field) */
  51464. _showBoundingBox: boolean;
  51465. /**
  51466. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  51467. */
  51468. showBoundingBox: boolean;
  51469. }
  51470. /**
  51471. * Component responsible of rendering the bounding box of the meshes in a scene.
  51472. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  51473. */
  51474. export class BoundingBoxRenderer implements ISceneComponent {
  51475. /**
  51476. * The component name helpfull to identify the component in the list of scene components.
  51477. */
  51478. readonly name: string;
  51479. /**
  51480. * The scene the component belongs to.
  51481. */
  51482. scene: Scene;
  51483. /**
  51484. * Color of the bounding box lines placed in front of an object
  51485. */
  51486. frontColor: Color3;
  51487. /**
  51488. * Color of the bounding box lines placed behind an object
  51489. */
  51490. backColor: Color3;
  51491. /**
  51492. * Defines if the renderer should show the back lines or not
  51493. */
  51494. showBackLines: boolean;
  51495. /**
  51496. * @hidden
  51497. */
  51498. renderList: SmartArray<BoundingBox>;
  51499. private _colorShader;
  51500. private _vertexBuffers;
  51501. private _indexBuffer;
  51502. /**
  51503. * Instantiates a new bounding box renderer in a scene.
  51504. * @param scene the scene the renderer renders in
  51505. */
  51506. constructor(scene: Scene);
  51507. /**
  51508. * Registers the component in a given scene
  51509. */
  51510. register(): void;
  51511. private _evaluateSubMesh;
  51512. private _activeMesh;
  51513. private _prepareRessources;
  51514. private _createIndexBuffer;
  51515. /**
  51516. * Rebuilds the elements related to this component in case of
  51517. * context lost for instance.
  51518. */
  51519. rebuild(): void;
  51520. /**
  51521. * @hidden
  51522. */
  51523. reset(): void;
  51524. /**
  51525. * Render the bounding boxes of a specific rendering group
  51526. * @param renderingGroupId defines the rendering group to render
  51527. */
  51528. render(renderingGroupId: number): void;
  51529. /**
  51530. * In case of occlusion queries, we can render the occlusion bounding box through this method
  51531. * @param mesh Define the mesh to render the occlusion bounding box for
  51532. */
  51533. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  51534. /**
  51535. * Dispose and release the resources attached to this renderer.
  51536. */
  51537. dispose(): void;
  51538. }
  51539. }
  51540. declare module BABYLON {
  51541. /** @hidden */
  51542. export var depthPixelShader: {
  51543. name: string;
  51544. shader: string;
  51545. };
  51546. }
  51547. declare module BABYLON {
  51548. /**
  51549. * This represents a depth renderer in Babylon.
  51550. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  51551. */
  51552. export class DepthRenderer {
  51553. private _scene;
  51554. private _depthMap;
  51555. private _effect;
  51556. private _cachedDefines;
  51557. private _camera;
  51558. /**
  51559. * Specifiess that the depth renderer will only be used within
  51560. * the camera it is created for.
  51561. * This can help forcing its rendering during the camera processing.
  51562. */
  51563. useOnlyInActiveCamera: boolean;
  51564. /** @hidden */
  51565. static _SceneComponentInitialization: (scene: Scene) => void;
  51566. /**
  51567. * Instantiates a depth renderer
  51568. * @param scene The scene the renderer belongs to
  51569. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  51570. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  51571. */
  51572. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  51573. /**
  51574. * Creates the depth rendering effect and checks if the effect is ready.
  51575. * @param subMesh The submesh to be used to render the depth map of
  51576. * @param useInstances If multiple world instances should be used
  51577. * @returns if the depth renderer is ready to render the depth map
  51578. */
  51579. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51580. /**
  51581. * Gets the texture which the depth map will be written to.
  51582. * @returns The depth map texture
  51583. */
  51584. getDepthMap(): RenderTargetTexture;
  51585. /**
  51586. * Disposes of the depth renderer.
  51587. */
  51588. dispose(): void;
  51589. }
  51590. }
  51591. declare module BABYLON {
  51592. interface Scene {
  51593. /** @hidden (Backing field) */
  51594. _depthRenderer: {
  51595. [id: string]: DepthRenderer;
  51596. };
  51597. /**
  51598. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  51599. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  51600. * @returns the created depth renderer
  51601. */
  51602. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  51603. /**
  51604. * Disables a depth renderer for a given camera
  51605. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  51606. */
  51607. disableDepthRenderer(camera?: Nullable<Camera>): void;
  51608. }
  51609. /**
  51610. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  51611. * in several rendering techniques.
  51612. */
  51613. export class DepthRendererSceneComponent implements ISceneComponent {
  51614. /**
  51615. * The component name helpfull to identify the component in the list of scene components.
  51616. */
  51617. readonly name: string;
  51618. /**
  51619. * The scene the component belongs to.
  51620. */
  51621. scene: Scene;
  51622. /**
  51623. * Creates a new instance of the component for the given scene
  51624. * @param scene Defines the scene to register the component in
  51625. */
  51626. constructor(scene: Scene);
  51627. /**
  51628. * Registers the component in a given scene
  51629. */
  51630. register(): void;
  51631. /**
  51632. * Rebuilds the elements related to this component in case of
  51633. * context lost for instance.
  51634. */
  51635. rebuild(): void;
  51636. /**
  51637. * Disposes the component and the associated ressources
  51638. */
  51639. dispose(): void;
  51640. private _gatherRenderTargets;
  51641. private _gatherActiveCameraRenderTargets;
  51642. }
  51643. }
  51644. declare module BABYLON {
  51645. interface Scene {
  51646. /** @hidden (Backing field) */
  51647. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  51648. /**
  51649. * Gets or Sets the current geometry buffer associated to the scene.
  51650. */
  51651. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  51652. /**
  51653. * Enables a GeometryBufferRender and associates it with the scene
  51654. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  51655. * @returns the GeometryBufferRenderer
  51656. */
  51657. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  51658. /**
  51659. * Disables the GeometryBufferRender associated with the scene
  51660. */
  51661. disableGeometryBufferRenderer(): void;
  51662. }
  51663. /**
  51664. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  51665. * in several rendering techniques.
  51666. */
  51667. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  51668. /**
  51669. * The component name helpful to identify the component in the list of scene components.
  51670. */
  51671. readonly name: string;
  51672. /**
  51673. * The scene the component belongs to.
  51674. */
  51675. scene: Scene;
  51676. /**
  51677. * Creates a new instance of the component for the given scene
  51678. * @param scene Defines the scene to register the component in
  51679. */
  51680. constructor(scene: Scene);
  51681. /**
  51682. * Registers the component in a given scene
  51683. */
  51684. register(): void;
  51685. /**
  51686. * Rebuilds the elements related to this component in case of
  51687. * context lost for instance.
  51688. */
  51689. rebuild(): void;
  51690. /**
  51691. * Disposes the component and the associated ressources
  51692. */
  51693. dispose(): void;
  51694. private _gatherRenderTargets;
  51695. }
  51696. }
  51697. declare module BABYLON {
  51698. /** @hidden */
  51699. export var outlinePixelShader: {
  51700. name: string;
  51701. shader: string;
  51702. };
  51703. }
  51704. declare module BABYLON {
  51705. /** @hidden */
  51706. export var outlineVertexShader: {
  51707. name: string;
  51708. shader: string;
  51709. };
  51710. }
  51711. declare module BABYLON {
  51712. interface Scene {
  51713. /** @hidden */
  51714. _outlineRenderer: OutlineRenderer;
  51715. /**
  51716. * Gets the outline renderer associated with the scene
  51717. * @returns a OutlineRenderer
  51718. */
  51719. getOutlineRenderer(): OutlineRenderer;
  51720. }
  51721. interface AbstractMesh {
  51722. /** @hidden (Backing field) */
  51723. _renderOutline: boolean;
  51724. /**
  51725. * Gets or sets a boolean indicating if the outline must be rendered as well
  51726. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  51727. */
  51728. renderOutline: boolean;
  51729. /** @hidden (Backing field) */
  51730. _renderOverlay: boolean;
  51731. /**
  51732. * Gets or sets a boolean indicating if the overlay must be rendered as well
  51733. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  51734. */
  51735. renderOverlay: boolean;
  51736. }
  51737. /**
  51738. * This class is responsible to draw bothe outline/overlay of meshes.
  51739. * It should not be used directly but through the available method on mesh.
  51740. */
  51741. export class OutlineRenderer implements ISceneComponent {
  51742. /**
  51743. * The name of the component. Each component must have a unique name.
  51744. */
  51745. name: string;
  51746. /**
  51747. * The scene the component belongs to.
  51748. */
  51749. scene: Scene;
  51750. /**
  51751. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  51752. */
  51753. zOffset: number;
  51754. private _engine;
  51755. private _effect;
  51756. private _cachedDefines;
  51757. private _savedDepthWrite;
  51758. /**
  51759. * Instantiates a new outline renderer. (There could be only one per scene).
  51760. * @param scene Defines the scene it belongs to
  51761. */
  51762. constructor(scene: Scene);
  51763. /**
  51764. * Register the component to one instance of a scene.
  51765. */
  51766. register(): void;
  51767. /**
  51768. * Rebuilds the elements related to this component in case of
  51769. * context lost for instance.
  51770. */
  51771. rebuild(): void;
  51772. /**
  51773. * Disposes the component and the associated ressources.
  51774. */
  51775. dispose(): void;
  51776. /**
  51777. * Renders the outline in the canvas.
  51778. * @param subMesh Defines the sumesh to render
  51779. * @param batch Defines the batch of meshes in case of instances
  51780. * @param useOverlay Defines if the rendering is for the overlay or the outline
  51781. */
  51782. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  51783. /**
  51784. * Returns whether or not the outline renderer is ready for a given submesh.
  51785. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  51786. * @param subMesh Defines the submesh to check readyness for
  51787. * @param useInstances Defines wheter wee are trying to render instances or not
  51788. * @returns true if ready otherwise false
  51789. */
  51790. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51791. private _beforeRenderingMesh;
  51792. private _afterRenderingMesh;
  51793. }
  51794. }
  51795. declare module BABYLON {
  51796. /**
  51797. * Defines the list of states available for a task inside a AssetsManager
  51798. */
  51799. export enum AssetTaskState {
  51800. /**
  51801. * Initialization
  51802. */
  51803. INIT = 0,
  51804. /**
  51805. * Running
  51806. */
  51807. RUNNING = 1,
  51808. /**
  51809. * Done
  51810. */
  51811. DONE = 2,
  51812. /**
  51813. * Error
  51814. */
  51815. ERROR = 3
  51816. }
  51817. /**
  51818. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  51819. */
  51820. export abstract class AbstractAssetTask {
  51821. /**
  51822. * Task name
  51823. */ name: string;
  51824. /**
  51825. * Callback called when the task is successful
  51826. */
  51827. onSuccess: (task: any) => void;
  51828. /**
  51829. * Callback called when the task is not successful
  51830. */
  51831. onError: (task: any, message?: string, exception?: any) => void;
  51832. /**
  51833. * Creates a new AssetsManager
  51834. * @param name defines the name of the task
  51835. */
  51836. constructor(
  51837. /**
  51838. * Task name
  51839. */ name: string);
  51840. private _isCompleted;
  51841. private _taskState;
  51842. private _errorObject;
  51843. /**
  51844. * Get if the task is completed
  51845. */
  51846. readonly isCompleted: boolean;
  51847. /**
  51848. * Gets the current state of the task
  51849. */
  51850. readonly taskState: AssetTaskState;
  51851. /**
  51852. * Gets the current error object (if task is in error)
  51853. */
  51854. readonly errorObject: {
  51855. message?: string;
  51856. exception?: any;
  51857. };
  51858. /**
  51859. * Internal only
  51860. * @hidden
  51861. */
  51862. _setErrorObject(message?: string, exception?: any): void;
  51863. /**
  51864. * Execute the current task
  51865. * @param scene defines the scene where you want your assets to be loaded
  51866. * @param onSuccess is a callback called when the task is successfully executed
  51867. * @param onError is a callback called if an error occurs
  51868. */
  51869. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51870. /**
  51871. * Execute the current task
  51872. * @param scene defines the scene where you want your assets to be loaded
  51873. * @param onSuccess is a callback called when the task is successfully executed
  51874. * @param onError is a callback called if an error occurs
  51875. */
  51876. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51877. /**
  51878. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  51879. * This can be used with failed tasks that have the reason for failure fixed.
  51880. */
  51881. reset(): void;
  51882. private onErrorCallback;
  51883. private onDoneCallback;
  51884. }
  51885. /**
  51886. * Define the interface used by progress events raised during assets loading
  51887. */
  51888. export interface IAssetsProgressEvent {
  51889. /**
  51890. * Defines the number of remaining tasks to process
  51891. */
  51892. remainingCount: number;
  51893. /**
  51894. * Defines the total number of tasks
  51895. */
  51896. totalCount: number;
  51897. /**
  51898. * Defines the task that was just processed
  51899. */
  51900. task: AbstractAssetTask;
  51901. }
  51902. /**
  51903. * Class used to share progress information about assets loading
  51904. */
  51905. export class AssetsProgressEvent implements IAssetsProgressEvent {
  51906. /**
  51907. * Defines the number of remaining tasks to process
  51908. */
  51909. remainingCount: number;
  51910. /**
  51911. * Defines the total number of tasks
  51912. */
  51913. totalCount: number;
  51914. /**
  51915. * Defines the task that was just processed
  51916. */
  51917. task: AbstractAssetTask;
  51918. /**
  51919. * Creates a AssetsProgressEvent
  51920. * @param remainingCount defines the number of remaining tasks to process
  51921. * @param totalCount defines the total number of tasks
  51922. * @param task defines the task that was just processed
  51923. */
  51924. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  51925. }
  51926. /**
  51927. * Define a task used by AssetsManager to load meshes
  51928. */
  51929. export class MeshAssetTask extends AbstractAssetTask {
  51930. /**
  51931. * Defines the name of the task
  51932. */
  51933. name: string;
  51934. /**
  51935. * Defines the list of mesh's names you want to load
  51936. */
  51937. meshesNames: any;
  51938. /**
  51939. * Defines the root url to use as a base to load your meshes and associated resources
  51940. */
  51941. rootUrl: string;
  51942. /**
  51943. * Defines the filename of the scene to load from
  51944. */
  51945. sceneFilename: string;
  51946. /**
  51947. * Gets the list of loaded meshes
  51948. */
  51949. loadedMeshes: Array<AbstractMesh>;
  51950. /**
  51951. * Gets the list of loaded particle systems
  51952. */
  51953. loadedParticleSystems: Array<IParticleSystem>;
  51954. /**
  51955. * Gets the list of loaded skeletons
  51956. */
  51957. loadedSkeletons: Array<Skeleton>;
  51958. /**
  51959. * Gets the list of loaded animation groups
  51960. */
  51961. loadedAnimationGroups: Array<AnimationGroup>;
  51962. /**
  51963. * Callback called when the task is successful
  51964. */
  51965. onSuccess: (task: MeshAssetTask) => void;
  51966. /**
  51967. * Callback called when the task is successful
  51968. */
  51969. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  51970. /**
  51971. * Creates a new MeshAssetTask
  51972. * @param name defines the name of the task
  51973. * @param meshesNames defines the list of mesh's names you want to load
  51974. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  51975. * @param sceneFilename defines the filename of the scene to load from
  51976. */
  51977. constructor(
  51978. /**
  51979. * Defines the name of the task
  51980. */
  51981. name: string,
  51982. /**
  51983. * Defines the list of mesh's names you want to load
  51984. */
  51985. meshesNames: any,
  51986. /**
  51987. * Defines the root url to use as a base to load your meshes and associated resources
  51988. */
  51989. rootUrl: string,
  51990. /**
  51991. * Defines the filename of the scene to load from
  51992. */
  51993. sceneFilename: string);
  51994. /**
  51995. * Execute the current task
  51996. * @param scene defines the scene where you want your assets to be loaded
  51997. * @param onSuccess is a callback called when the task is successfully executed
  51998. * @param onError is a callback called if an error occurs
  51999. */
  52000. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52001. }
  52002. /**
  52003. * Define a task used by AssetsManager to load text content
  52004. */
  52005. export class TextFileAssetTask extends AbstractAssetTask {
  52006. /**
  52007. * Defines the name of the task
  52008. */
  52009. name: string;
  52010. /**
  52011. * Defines the location of the file to load
  52012. */
  52013. url: string;
  52014. /**
  52015. * Gets the loaded text string
  52016. */
  52017. text: string;
  52018. /**
  52019. * Callback called when the task is successful
  52020. */
  52021. onSuccess: (task: TextFileAssetTask) => void;
  52022. /**
  52023. * Callback called when the task is successful
  52024. */
  52025. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  52026. /**
  52027. * Creates a new TextFileAssetTask object
  52028. * @param name defines the name of the task
  52029. * @param url defines the location of the file to load
  52030. */
  52031. constructor(
  52032. /**
  52033. * Defines the name of the task
  52034. */
  52035. name: string,
  52036. /**
  52037. * Defines the location of the file to load
  52038. */
  52039. url: string);
  52040. /**
  52041. * Execute the current task
  52042. * @param scene defines the scene where you want your assets to be loaded
  52043. * @param onSuccess is a callback called when the task is successfully executed
  52044. * @param onError is a callback called if an error occurs
  52045. */
  52046. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52047. }
  52048. /**
  52049. * Define a task used by AssetsManager to load binary data
  52050. */
  52051. export class BinaryFileAssetTask extends AbstractAssetTask {
  52052. /**
  52053. * Defines the name of the task
  52054. */
  52055. name: string;
  52056. /**
  52057. * Defines the location of the file to load
  52058. */
  52059. url: string;
  52060. /**
  52061. * Gets the lodaded data (as an array buffer)
  52062. */
  52063. data: ArrayBuffer;
  52064. /**
  52065. * Callback called when the task is successful
  52066. */
  52067. onSuccess: (task: BinaryFileAssetTask) => void;
  52068. /**
  52069. * Callback called when the task is successful
  52070. */
  52071. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  52072. /**
  52073. * Creates a new BinaryFileAssetTask object
  52074. * @param name defines the name of the new task
  52075. * @param url defines the location of the file to load
  52076. */
  52077. constructor(
  52078. /**
  52079. * Defines the name of the task
  52080. */
  52081. name: string,
  52082. /**
  52083. * Defines the location of the file to load
  52084. */
  52085. url: string);
  52086. /**
  52087. * Execute the current task
  52088. * @param scene defines the scene where you want your assets to be loaded
  52089. * @param onSuccess is a callback called when the task is successfully executed
  52090. * @param onError is a callback called if an error occurs
  52091. */
  52092. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52093. }
  52094. /**
  52095. * Define a task used by AssetsManager to load images
  52096. */
  52097. export class ImageAssetTask extends AbstractAssetTask {
  52098. /**
  52099. * Defines the name of the task
  52100. */
  52101. name: string;
  52102. /**
  52103. * Defines the location of the image to load
  52104. */
  52105. url: string;
  52106. /**
  52107. * Gets the loaded images
  52108. */
  52109. image: HTMLImageElement;
  52110. /**
  52111. * Callback called when the task is successful
  52112. */
  52113. onSuccess: (task: ImageAssetTask) => void;
  52114. /**
  52115. * Callback called when the task is successful
  52116. */
  52117. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  52118. /**
  52119. * Creates a new ImageAssetTask
  52120. * @param name defines the name of the task
  52121. * @param url defines the location of the image to load
  52122. */
  52123. constructor(
  52124. /**
  52125. * Defines the name of the task
  52126. */
  52127. name: string,
  52128. /**
  52129. * Defines the location of the image to load
  52130. */
  52131. url: string);
  52132. /**
  52133. * Execute the current task
  52134. * @param scene defines the scene where you want your assets to be loaded
  52135. * @param onSuccess is a callback called when the task is successfully executed
  52136. * @param onError is a callback called if an error occurs
  52137. */
  52138. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52139. }
  52140. /**
  52141. * Defines the interface used by texture loading tasks
  52142. */
  52143. export interface ITextureAssetTask<TEX extends BaseTexture> {
  52144. /**
  52145. * Gets the loaded texture
  52146. */
  52147. texture: TEX;
  52148. }
  52149. /**
  52150. * Define a task used by AssetsManager to load 2D textures
  52151. */
  52152. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  52153. /**
  52154. * Defines the name of the task
  52155. */
  52156. name: string;
  52157. /**
  52158. * Defines the location of the file to load
  52159. */
  52160. url: string;
  52161. /**
  52162. * Defines if mipmap should not be generated (default is false)
  52163. */
  52164. noMipmap?: boolean | undefined;
  52165. /**
  52166. * Defines if texture must be inverted on Y axis (default is false)
  52167. */
  52168. invertY?: boolean | undefined;
  52169. /**
  52170. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52171. */
  52172. samplingMode: number;
  52173. /**
  52174. * Gets the loaded texture
  52175. */
  52176. texture: Texture;
  52177. /**
  52178. * Callback called when the task is successful
  52179. */
  52180. onSuccess: (task: TextureAssetTask) => void;
  52181. /**
  52182. * Callback called when the task is successful
  52183. */
  52184. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  52185. /**
  52186. * Creates a new TextureAssetTask object
  52187. * @param name defines the name of the task
  52188. * @param url defines the location of the file to load
  52189. * @param noMipmap defines if mipmap should not be generated (default is false)
  52190. * @param invertY defines if texture must be inverted on Y axis (default is false)
  52191. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52192. */
  52193. constructor(
  52194. /**
  52195. * Defines the name of the task
  52196. */
  52197. name: string,
  52198. /**
  52199. * Defines the location of the file to load
  52200. */
  52201. url: string,
  52202. /**
  52203. * Defines if mipmap should not be generated (default is false)
  52204. */
  52205. noMipmap?: boolean | undefined,
  52206. /**
  52207. * Defines if texture must be inverted on Y axis (default is false)
  52208. */
  52209. invertY?: boolean | undefined,
  52210. /**
  52211. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52212. */
  52213. samplingMode?: number);
  52214. /**
  52215. * Execute the current task
  52216. * @param scene defines the scene where you want your assets to be loaded
  52217. * @param onSuccess is a callback called when the task is successfully executed
  52218. * @param onError is a callback called if an error occurs
  52219. */
  52220. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52221. }
  52222. /**
  52223. * Define a task used by AssetsManager to load cube textures
  52224. */
  52225. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  52226. /**
  52227. * Defines the name of the task
  52228. */
  52229. name: string;
  52230. /**
  52231. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  52232. */
  52233. url: string;
  52234. /**
  52235. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  52236. */
  52237. extensions?: string[] | undefined;
  52238. /**
  52239. * Defines if mipmaps should not be generated (default is false)
  52240. */
  52241. noMipmap?: boolean | undefined;
  52242. /**
  52243. * Defines the explicit list of files (undefined by default)
  52244. */
  52245. files?: string[] | undefined;
  52246. /**
  52247. * Gets the loaded texture
  52248. */
  52249. texture: CubeTexture;
  52250. /**
  52251. * Callback called when the task is successful
  52252. */
  52253. onSuccess: (task: CubeTextureAssetTask) => void;
  52254. /**
  52255. * Callback called when the task is successful
  52256. */
  52257. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  52258. /**
  52259. * Creates a new CubeTextureAssetTask
  52260. * @param name defines the name of the task
  52261. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  52262. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  52263. * @param noMipmap defines if mipmaps should not be generated (default is false)
  52264. * @param files defines the explicit list of files (undefined by default)
  52265. */
  52266. constructor(
  52267. /**
  52268. * Defines the name of the task
  52269. */
  52270. name: string,
  52271. /**
  52272. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  52273. */
  52274. url: string,
  52275. /**
  52276. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  52277. */
  52278. extensions?: string[] | undefined,
  52279. /**
  52280. * Defines if mipmaps should not be generated (default is false)
  52281. */
  52282. noMipmap?: boolean | undefined,
  52283. /**
  52284. * Defines the explicit list of files (undefined by default)
  52285. */
  52286. files?: string[] | undefined);
  52287. /**
  52288. * Execute the current task
  52289. * @param scene defines the scene where you want your assets to be loaded
  52290. * @param onSuccess is a callback called when the task is successfully executed
  52291. * @param onError is a callback called if an error occurs
  52292. */
  52293. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52294. }
  52295. /**
  52296. * Define a task used by AssetsManager to load HDR cube textures
  52297. */
  52298. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  52299. /**
  52300. * Defines the name of the task
  52301. */
  52302. name: string;
  52303. /**
  52304. * Defines the location of the file to load
  52305. */
  52306. url: string;
  52307. /**
  52308. * Defines the desired size (the more it increases the longer the generation will be)
  52309. */
  52310. size: number;
  52311. /**
  52312. * Defines if mipmaps should not be generated (default is false)
  52313. */
  52314. noMipmap: boolean;
  52315. /**
  52316. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  52317. */
  52318. generateHarmonics: boolean;
  52319. /**
  52320. * 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)
  52321. */
  52322. gammaSpace: boolean;
  52323. /**
  52324. * Internal Use Only
  52325. */
  52326. reserved: boolean;
  52327. /**
  52328. * Gets the loaded texture
  52329. */
  52330. texture: HDRCubeTexture;
  52331. /**
  52332. * Callback called when the task is successful
  52333. */
  52334. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  52335. /**
  52336. * Callback called when the task is successful
  52337. */
  52338. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  52339. /**
  52340. * Creates a new HDRCubeTextureAssetTask object
  52341. * @param name defines the name of the task
  52342. * @param url defines the location of the file to load
  52343. * @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.
  52344. * @param noMipmap defines if mipmaps should not be generated (default is false)
  52345. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  52346. * @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)
  52347. * @param reserved Internal use only
  52348. */
  52349. constructor(
  52350. /**
  52351. * Defines the name of the task
  52352. */
  52353. name: string,
  52354. /**
  52355. * Defines the location of the file to load
  52356. */
  52357. url: string,
  52358. /**
  52359. * Defines the desired size (the more it increases the longer the generation will be)
  52360. */
  52361. size: number,
  52362. /**
  52363. * Defines if mipmaps should not be generated (default is false)
  52364. */
  52365. noMipmap?: boolean,
  52366. /**
  52367. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  52368. */
  52369. generateHarmonics?: boolean,
  52370. /**
  52371. * 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)
  52372. */
  52373. gammaSpace?: boolean,
  52374. /**
  52375. * Internal Use Only
  52376. */
  52377. reserved?: boolean);
  52378. /**
  52379. * Execute the current task
  52380. * @param scene defines the scene where you want your assets to be loaded
  52381. * @param onSuccess is a callback called when the task is successfully executed
  52382. * @param onError is a callback called if an error occurs
  52383. */
  52384. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52385. }
  52386. /**
  52387. * This class can be used to easily import assets into a scene
  52388. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  52389. */
  52390. export class AssetsManager {
  52391. private _scene;
  52392. private _isLoading;
  52393. protected _tasks: AbstractAssetTask[];
  52394. protected _waitingTasksCount: number;
  52395. protected _totalTasksCount: number;
  52396. /**
  52397. * Callback called when all tasks are processed
  52398. */
  52399. onFinish: (tasks: AbstractAssetTask[]) => void;
  52400. /**
  52401. * Callback called when a task is successful
  52402. */
  52403. onTaskSuccess: (task: AbstractAssetTask) => void;
  52404. /**
  52405. * Callback called when a task had an error
  52406. */
  52407. onTaskError: (task: AbstractAssetTask) => void;
  52408. /**
  52409. * Callback called when a task is done (whatever the result is)
  52410. */
  52411. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  52412. /**
  52413. * Observable called when all tasks are processed
  52414. */
  52415. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  52416. /**
  52417. * Observable called when a task had an error
  52418. */
  52419. onTaskErrorObservable: Observable<AbstractAssetTask>;
  52420. /**
  52421. * Observable called when a task is successful
  52422. */
  52423. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  52424. /**
  52425. * Observable called when a task is done (whatever the result is)
  52426. */
  52427. onProgressObservable: Observable<IAssetsProgressEvent>;
  52428. /**
  52429. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  52430. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  52431. */
  52432. useDefaultLoadingScreen: boolean;
  52433. /**
  52434. * Creates a new AssetsManager
  52435. * @param scene defines the scene to work on
  52436. */
  52437. constructor(scene: Scene);
  52438. /**
  52439. * Add a MeshAssetTask to the list of active tasks
  52440. * @param taskName defines the name of the new task
  52441. * @param meshesNames defines the name of meshes to load
  52442. * @param rootUrl defines the root url to use to locate files
  52443. * @param sceneFilename defines the filename of the scene file
  52444. * @returns a new MeshAssetTask object
  52445. */
  52446. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  52447. /**
  52448. * Add a TextFileAssetTask to the list of active tasks
  52449. * @param taskName defines the name of the new task
  52450. * @param url defines the url of the file to load
  52451. * @returns a new TextFileAssetTask object
  52452. */
  52453. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  52454. /**
  52455. * Add a BinaryFileAssetTask to the list of active tasks
  52456. * @param taskName defines the name of the new task
  52457. * @param url defines the url of the file to load
  52458. * @returns a new BinaryFileAssetTask object
  52459. */
  52460. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  52461. /**
  52462. * Add a ImageAssetTask to the list of active tasks
  52463. * @param taskName defines the name of the new task
  52464. * @param url defines the url of the file to load
  52465. * @returns a new ImageAssetTask object
  52466. */
  52467. addImageTask(taskName: string, url: string): ImageAssetTask;
  52468. /**
  52469. * Add a TextureAssetTask to the list of active tasks
  52470. * @param taskName defines the name of the new task
  52471. * @param url defines the url of the file to load
  52472. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  52473. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  52474. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52475. * @returns a new TextureAssetTask object
  52476. */
  52477. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  52478. /**
  52479. * Add a CubeTextureAssetTask to the list of active tasks
  52480. * @param taskName defines the name of the new task
  52481. * @param url defines the url of the file to load
  52482. * @param extensions defines the extension to use to load the cube map (can be null)
  52483. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  52484. * @param files defines the list of files to load (can be null)
  52485. * @returns a new CubeTextureAssetTask object
  52486. */
  52487. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  52488. /**
  52489. *
  52490. * Add a HDRCubeTextureAssetTask to the list of active tasks
  52491. * @param taskName defines the name of the new task
  52492. * @param url defines the url of the file to load
  52493. * @param size defines the size you want for the cubemap (can be null)
  52494. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  52495. * @param generateHarmonics defines if you want to automatically generate (true by default)
  52496. * @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)
  52497. * @param reserved Internal use only
  52498. * @returns a new HDRCubeTextureAssetTask object
  52499. */
  52500. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  52501. /**
  52502. * Remove a task from the assets manager.
  52503. * @param task the task to remove
  52504. */
  52505. removeTask(task: AbstractAssetTask): void;
  52506. private _decreaseWaitingTasksCount;
  52507. private _runTask;
  52508. /**
  52509. * Reset the AssetsManager and remove all tasks
  52510. * @return the current instance of the AssetsManager
  52511. */
  52512. reset(): AssetsManager;
  52513. /**
  52514. * Start the loading process
  52515. * @return the current instance of the AssetsManager
  52516. */
  52517. load(): AssetsManager;
  52518. }
  52519. }
  52520. declare module BABYLON {
  52521. /**
  52522. * Wrapper class for promise with external resolve and reject.
  52523. */
  52524. export class Deferred<T> {
  52525. /**
  52526. * The promise associated with this deferred object.
  52527. */
  52528. readonly promise: Promise<T>;
  52529. private _resolve;
  52530. private _reject;
  52531. /**
  52532. * The resolve method of the promise associated with this deferred object.
  52533. */
  52534. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  52535. /**
  52536. * The reject method of the promise associated with this deferred object.
  52537. */
  52538. readonly reject: (reason?: any) => void;
  52539. /**
  52540. * Constructor for this deferred object.
  52541. */
  52542. constructor();
  52543. }
  52544. }
  52545. declare module BABYLON {
  52546. /**
  52547. * Class used to help managing file picking and drag'n'drop
  52548. */
  52549. export class FilesInput {
  52550. /**
  52551. * List of files ready to be loaded
  52552. */
  52553. static readonly FilesToLoad: {
  52554. [key: string]: File;
  52555. };
  52556. /**
  52557. * Callback called when a file is processed
  52558. */
  52559. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  52560. private _engine;
  52561. private _currentScene;
  52562. private _sceneLoadedCallback;
  52563. private _progressCallback;
  52564. private _additionalRenderLoopLogicCallback;
  52565. private _textureLoadingCallback;
  52566. private _startingProcessingFilesCallback;
  52567. private _onReloadCallback;
  52568. private _errorCallback;
  52569. private _elementToMonitor;
  52570. private _sceneFileToLoad;
  52571. private _filesToLoad;
  52572. /**
  52573. * Creates a new FilesInput
  52574. * @param engine defines the rendering engine
  52575. * @param scene defines the hosting scene
  52576. * @param sceneLoadedCallback callback called when scene is loaded
  52577. * @param progressCallback callback called to track progress
  52578. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  52579. * @param textureLoadingCallback callback called when a texture is loading
  52580. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  52581. * @param onReloadCallback callback called when a reload is requested
  52582. * @param errorCallback callback call if an error occurs
  52583. */
  52584. 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);
  52585. private _dragEnterHandler;
  52586. private _dragOverHandler;
  52587. private _dropHandler;
  52588. /**
  52589. * Calls this function to listen to drag'n'drop events on a specific DOM element
  52590. * @param elementToMonitor defines the DOM element to track
  52591. */
  52592. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  52593. /**
  52594. * Release all associated resources
  52595. */
  52596. dispose(): void;
  52597. private renderFunction;
  52598. private drag;
  52599. private drop;
  52600. private _traverseFolder;
  52601. private _processFiles;
  52602. /**
  52603. * Load files from a drop event
  52604. * @param event defines the drop event to use as source
  52605. */
  52606. loadFiles(event: any): void;
  52607. private _processReload;
  52608. /**
  52609. * Reload the current scene from the loaded files
  52610. */
  52611. reload(): void;
  52612. }
  52613. }
  52614. declare module BABYLON {
  52615. /**
  52616. * Defines the root class used to create scene optimization to use with SceneOptimizer
  52617. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52618. */
  52619. export class SceneOptimization {
  52620. /**
  52621. * Defines the priority of this optimization (0 by default which means first in the list)
  52622. */
  52623. priority: number;
  52624. /**
  52625. * Gets a string describing the action executed by the current optimization
  52626. * @returns description string
  52627. */
  52628. getDescription(): string;
  52629. /**
  52630. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52631. * @param scene defines the current scene where to apply this optimization
  52632. * @param optimizer defines the current optimizer
  52633. * @returns true if everything that can be done was applied
  52634. */
  52635. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52636. /**
  52637. * Creates the SceneOptimization object
  52638. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52639. * @param desc defines the description associated with the optimization
  52640. */
  52641. constructor(
  52642. /**
  52643. * Defines the priority of this optimization (0 by default which means first in the list)
  52644. */
  52645. priority?: number);
  52646. }
  52647. /**
  52648. * Defines an optimization used to reduce the size of render target textures
  52649. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52650. */
  52651. export class TextureOptimization extends SceneOptimization {
  52652. /**
  52653. * Defines the priority of this optimization (0 by default which means first in the list)
  52654. */
  52655. priority: number;
  52656. /**
  52657. * 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
  52658. */
  52659. maximumSize: number;
  52660. /**
  52661. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  52662. */
  52663. step: number;
  52664. /**
  52665. * Gets a string describing the action executed by the current optimization
  52666. * @returns description string
  52667. */
  52668. getDescription(): string;
  52669. /**
  52670. * Creates the TextureOptimization object
  52671. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52672. * @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
  52673. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  52674. */
  52675. constructor(
  52676. /**
  52677. * Defines the priority of this optimization (0 by default which means first in the list)
  52678. */
  52679. priority?: number,
  52680. /**
  52681. * 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
  52682. */
  52683. maximumSize?: number,
  52684. /**
  52685. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  52686. */
  52687. step?: number);
  52688. /**
  52689. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52690. * @param scene defines the current scene where to apply this optimization
  52691. * @param optimizer defines the current optimizer
  52692. * @returns true if everything that can be done was applied
  52693. */
  52694. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52695. }
  52696. /**
  52697. * Defines an optimization used to increase or decrease the rendering resolution
  52698. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52699. */
  52700. export class HardwareScalingOptimization extends SceneOptimization {
  52701. /**
  52702. * Defines the priority of this optimization (0 by default which means first in the list)
  52703. */
  52704. priority: number;
  52705. /**
  52706. * Defines the maximum scale to use (2 by default)
  52707. */
  52708. maximumScale: number;
  52709. /**
  52710. * Defines the step to use between two passes (0.5 by default)
  52711. */
  52712. step: number;
  52713. private _currentScale;
  52714. private _directionOffset;
  52715. /**
  52716. * Gets a string describing the action executed by the current optimization
  52717. * @return description string
  52718. */
  52719. getDescription(): string;
  52720. /**
  52721. * Creates the HardwareScalingOptimization object
  52722. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52723. * @param maximumScale defines the maximum scale to use (2 by default)
  52724. * @param step defines the step to use between two passes (0.5 by default)
  52725. */
  52726. constructor(
  52727. /**
  52728. * Defines the priority of this optimization (0 by default which means first in the list)
  52729. */
  52730. priority?: number,
  52731. /**
  52732. * Defines the maximum scale to use (2 by default)
  52733. */
  52734. maximumScale?: number,
  52735. /**
  52736. * Defines the step to use between two passes (0.5 by default)
  52737. */
  52738. step?: number);
  52739. /**
  52740. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52741. * @param scene defines the current scene where to apply this optimization
  52742. * @param optimizer defines the current optimizer
  52743. * @returns true if everything that can be done was applied
  52744. */
  52745. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52746. }
  52747. /**
  52748. * Defines an optimization used to remove shadows
  52749. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52750. */
  52751. export class ShadowsOptimization extends SceneOptimization {
  52752. /**
  52753. * Gets a string describing the action executed by the current optimization
  52754. * @return description string
  52755. */
  52756. getDescription(): string;
  52757. /**
  52758. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52759. * @param scene defines the current scene where to apply this optimization
  52760. * @param optimizer defines the current optimizer
  52761. * @returns true if everything that can be done was applied
  52762. */
  52763. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52764. }
  52765. /**
  52766. * Defines an optimization used to turn post-processes off
  52767. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52768. */
  52769. export class PostProcessesOptimization extends SceneOptimization {
  52770. /**
  52771. * Gets a string describing the action executed by the current optimization
  52772. * @return description string
  52773. */
  52774. getDescription(): string;
  52775. /**
  52776. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52777. * @param scene defines the current scene where to apply this optimization
  52778. * @param optimizer defines the current optimizer
  52779. * @returns true if everything that can be done was applied
  52780. */
  52781. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52782. }
  52783. /**
  52784. * Defines an optimization used to turn lens flares off
  52785. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52786. */
  52787. export class LensFlaresOptimization extends SceneOptimization {
  52788. /**
  52789. * Gets a string describing the action executed by the current optimization
  52790. * @return description string
  52791. */
  52792. getDescription(): string;
  52793. /**
  52794. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52795. * @param scene defines the current scene where to apply this optimization
  52796. * @param optimizer defines the current optimizer
  52797. * @returns true if everything that can be done was applied
  52798. */
  52799. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52800. }
  52801. /**
  52802. * Defines an optimization based on user defined callback.
  52803. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52804. */
  52805. export class CustomOptimization extends SceneOptimization {
  52806. /**
  52807. * Callback called to apply the custom optimization.
  52808. */
  52809. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  52810. /**
  52811. * Callback called to get custom description
  52812. */
  52813. onGetDescription: () => string;
  52814. /**
  52815. * Gets a string describing the action executed by the current optimization
  52816. * @returns description string
  52817. */
  52818. getDescription(): string;
  52819. /**
  52820. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52821. * @param scene defines the current scene where to apply this optimization
  52822. * @param optimizer defines the current optimizer
  52823. * @returns true if everything that can be done was applied
  52824. */
  52825. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52826. }
  52827. /**
  52828. * Defines an optimization used to turn particles off
  52829. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52830. */
  52831. export class ParticlesOptimization extends SceneOptimization {
  52832. /**
  52833. * Gets a string describing the action executed by the current optimization
  52834. * @return description string
  52835. */
  52836. getDescription(): string;
  52837. /**
  52838. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52839. * @param scene defines the current scene where to apply this optimization
  52840. * @param optimizer defines the current optimizer
  52841. * @returns true if everything that can be done was applied
  52842. */
  52843. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52844. }
  52845. /**
  52846. * Defines an optimization used to turn render targets off
  52847. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52848. */
  52849. export class RenderTargetsOptimization extends SceneOptimization {
  52850. /**
  52851. * Gets a string describing the action executed by the current optimization
  52852. * @return description string
  52853. */
  52854. getDescription(): string;
  52855. /**
  52856. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52857. * @param scene defines the current scene where to apply this optimization
  52858. * @param optimizer defines the current optimizer
  52859. * @returns true if everything that can be done was applied
  52860. */
  52861. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52862. }
  52863. /**
  52864. * Defines an optimization used to merge meshes with compatible materials
  52865. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52866. */
  52867. export class MergeMeshesOptimization extends SceneOptimization {
  52868. private static _UpdateSelectionTree;
  52869. /**
  52870. * Gets or sets a boolean which defines if optimization octree has to be updated
  52871. */
  52872. /**
  52873. * Gets or sets a boolean which defines if optimization octree has to be updated
  52874. */
  52875. static UpdateSelectionTree: boolean;
  52876. /**
  52877. * Gets a string describing the action executed by the current optimization
  52878. * @return description string
  52879. */
  52880. getDescription(): string;
  52881. private _canBeMerged;
  52882. /**
  52883. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52884. * @param scene defines the current scene where to apply this optimization
  52885. * @param optimizer defines the current optimizer
  52886. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  52887. * @returns true if everything that can be done was applied
  52888. */
  52889. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  52890. }
  52891. /**
  52892. * Defines a list of options used by SceneOptimizer
  52893. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52894. */
  52895. export class SceneOptimizerOptions {
  52896. /**
  52897. * Defines the target frame rate to reach (60 by default)
  52898. */
  52899. targetFrameRate: number;
  52900. /**
  52901. * Defines the interval between two checkes (2000ms by default)
  52902. */
  52903. trackerDuration: number;
  52904. /**
  52905. * Gets the list of optimizations to apply
  52906. */
  52907. optimizations: SceneOptimization[];
  52908. /**
  52909. * Creates a new list of options used by SceneOptimizer
  52910. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  52911. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  52912. */
  52913. constructor(
  52914. /**
  52915. * Defines the target frame rate to reach (60 by default)
  52916. */
  52917. targetFrameRate?: number,
  52918. /**
  52919. * Defines the interval between two checkes (2000ms by default)
  52920. */
  52921. trackerDuration?: number);
  52922. /**
  52923. * Add a new optimization
  52924. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  52925. * @returns the current SceneOptimizerOptions
  52926. */
  52927. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  52928. /**
  52929. * Add a new custom optimization
  52930. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  52931. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  52932. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52933. * @returns the current SceneOptimizerOptions
  52934. */
  52935. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  52936. /**
  52937. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  52938. * @param targetFrameRate defines the target frame rate (60 by default)
  52939. * @returns a SceneOptimizerOptions object
  52940. */
  52941. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  52942. /**
  52943. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  52944. * @param targetFrameRate defines the target frame rate (60 by default)
  52945. * @returns a SceneOptimizerOptions object
  52946. */
  52947. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  52948. /**
  52949. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  52950. * @param targetFrameRate defines the target frame rate (60 by default)
  52951. * @returns a SceneOptimizerOptions object
  52952. */
  52953. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  52954. }
  52955. /**
  52956. * Class used to run optimizations in order to reach a target frame rate
  52957. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52958. */
  52959. export class SceneOptimizer implements IDisposable {
  52960. private _isRunning;
  52961. private _options;
  52962. private _scene;
  52963. private _currentPriorityLevel;
  52964. private _targetFrameRate;
  52965. private _trackerDuration;
  52966. private _currentFrameRate;
  52967. private _sceneDisposeObserver;
  52968. private _improvementMode;
  52969. /**
  52970. * Defines an observable called when the optimizer reaches the target frame rate
  52971. */
  52972. onSuccessObservable: Observable<SceneOptimizer>;
  52973. /**
  52974. * Defines an observable called when the optimizer enables an optimization
  52975. */
  52976. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  52977. /**
  52978. * Defines an observable called when the optimizer is not able to reach the target frame rate
  52979. */
  52980. onFailureObservable: Observable<SceneOptimizer>;
  52981. /**
  52982. * Gets a boolean indicating if the optimizer is in improvement mode
  52983. */
  52984. readonly isInImprovementMode: boolean;
  52985. /**
  52986. * Gets the current priority level (0 at start)
  52987. */
  52988. readonly currentPriorityLevel: number;
  52989. /**
  52990. * Gets the current frame rate checked by the SceneOptimizer
  52991. */
  52992. readonly currentFrameRate: number;
  52993. /**
  52994. * Gets or sets the current target frame rate (60 by default)
  52995. */
  52996. /**
  52997. * Gets or sets the current target frame rate (60 by default)
  52998. */
  52999. targetFrameRate: number;
  53000. /**
  53001. * Gets or sets the current interval between two checks (every 2000ms by default)
  53002. */
  53003. /**
  53004. * Gets or sets the current interval between two checks (every 2000ms by default)
  53005. */
  53006. trackerDuration: number;
  53007. /**
  53008. * Gets the list of active optimizations
  53009. */
  53010. readonly optimizations: SceneOptimization[];
  53011. /**
  53012. * Creates a new SceneOptimizer
  53013. * @param scene defines the scene to work on
  53014. * @param options defines the options to use with the SceneOptimizer
  53015. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  53016. * @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)
  53017. */
  53018. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  53019. /**
  53020. * Stops the current optimizer
  53021. */
  53022. stop(): void;
  53023. /**
  53024. * Reset the optimizer to initial step (current priority level = 0)
  53025. */
  53026. reset(): void;
  53027. /**
  53028. * Start the optimizer. By default it will try to reach a specific framerate
  53029. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  53030. */
  53031. start(): void;
  53032. private _checkCurrentState;
  53033. /**
  53034. * Release all resources
  53035. */
  53036. dispose(): void;
  53037. /**
  53038. * Helper function to create a SceneOptimizer with one single line of code
  53039. * @param scene defines the scene to work on
  53040. * @param options defines the options to use with the SceneOptimizer
  53041. * @param onSuccess defines a callback to call on success
  53042. * @param onFailure defines a callback to call on failure
  53043. * @returns the new SceneOptimizer object
  53044. */
  53045. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  53046. }
  53047. }
  53048. declare module BABYLON {
  53049. /**
  53050. * Class used to serialize a scene into a string
  53051. */
  53052. export class SceneSerializer {
  53053. /**
  53054. * Clear cache used by a previous serialization
  53055. */
  53056. static ClearCache(): void;
  53057. /**
  53058. * Serialize a scene into a JSON compatible object
  53059. * @param scene defines the scene to serialize
  53060. * @returns a JSON compatible object
  53061. */
  53062. static Serialize(scene: Scene): any;
  53063. /**
  53064. * Serialize a mesh into a JSON compatible object
  53065. * @param toSerialize defines the mesh to serialize
  53066. * @param withParents defines if parents must be serialized as well
  53067. * @param withChildren defines if children must be serialized as well
  53068. * @returns a JSON compatible object
  53069. */
  53070. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  53071. }
  53072. }
  53073. declare module BABYLON {
  53074. /**
  53075. * This represents the different options avilable for the video capture.
  53076. */
  53077. export interface VideoRecorderOptions {
  53078. /** Defines the mime type of the video */
  53079. mimeType: string;
  53080. /** Defines the video the video should be recorded at */
  53081. fps: number;
  53082. /** Defines the chunk size for the recording data */
  53083. recordChunckSize: number;
  53084. }
  53085. /**
  53086. * This can helps recording videos from BabylonJS.
  53087. * This is based on the available WebRTC functionalities of the browser.
  53088. *
  53089. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  53090. */
  53091. export class VideoRecorder {
  53092. private static readonly _defaultOptions;
  53093. /**
  53094. * Returns wehther or not the VideoRecorder is available in your browser.
  53095. * @param engine Defines the Babylon Engine to check the support for
  53096. * @returns true if supported otherwise false
  53097. */
  53098. static IsSupported(engine: Engine): boolean;
  53099. private readonly _options;
  53100. private _canvas;
  53101. private _mediaRecorder;
  53102. private _recordedChunks;
  53103. private _fileName;
  53104. private _resolve;
  53105. private _reject;
  53106. /**
  53107. * True wether a recording is already in progress.
  53108. */
  53109. readonly isRecording: boolean;
  53110. /**
  53111. * Create a new VideoCapture object which can help converting what you see in Babylon to
  53112. * a video file.
  53113. * @param engine Defines the BabylonJS Engine you wish to record
  53114. * @param options Defines options that can be used to customized the capture
  53115. */
  53116. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  53117. /**
  53118. * Stops the current recording before the default capture timeout passed in the startRecording
  53119. * functions.
  53120. */
  53121. stopRecording(): void;
  53122. /**
  53123. * Starts recording the canvas for a max duration specified in parameters.
  53124. * @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.
  53125. * @param maxDuration Defines the maximum recording time in seconds.
  53126. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  53127. * @return a promise callback at the end of the recording with the video data in Blob.
  53128. */
  53129. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  53130. /**
  53131. * Releases internal resources used during the recording.
  53132. */
  53133. dispose(): void;
  53134. private _handleDataAvailable;
  53135. private _handleError;
  53136. private _handleStop;
  53137. }
  53138. }
  53139. declare module BABYLON {
  53140. /**
  53141. * Helper class to push actions to a pool of workers.
  53142. */
  53143. export class WorkerPool implements IDisposable {
  53144. private _workerInfos;
  53145. private _pendingActions;
  53146. /**
  53147. * Constructor
  53148. * @param workers Array of workers to use for actions
  53149. */
  53150. constructor(workers: Array<Worker>);
  53151. /**
  53152. * Terminates all workers and clears any pending actions.
  53153. */
  53154. dispose(): void;
  53155. /**
  53156. * Pushes an action to the worker pool. If all the workers are active, the action will be
  53157. * pended until a worker has completed its action.
  53158. * @param action The action to perform. Call onComplete when the action is complete.
  53159. */
  53160. push(action: (worker: Worker, onComplete: () => void) => void): void;
  53161. private _execute;
  53162. }
  53163. }
  53164. declare module BABYLON {
  53165. /**
  53166. * Class containing a set of static utilities functions for screenshots
  53167. */
  53168. export class ScreenshotTools {
  53169. /**
  53170. * Captures a screenshot of the current rendering
  53171. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  53172. * @param engine defines the rendering engine
  53173. * @param camera defines the source camera
  53174. * @param size This parameter can be set to a single number or to an object with the
  53175. * following (optional) properties: precision, width, height. If a single number is passed,
  53176. * it will be used for both width and height. If an object is passed, the screenshot size
  53177. * will be derived from the parameters. The precision property is a multiplier allowing
  53178. * rendering at a higher or lower resolution
  53179. * @param successCallback defines the callback receives a single parameter which contains the
  53180. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  53181. * src parameter of an <img> to display it
  53182. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  53183. * Check your browser for supported MIME types
  53184. */
  53185. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  53186. /**
  53187. * Generates an image screenshot from the specified camera.
  53188. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  53189. * @param engine The engine to use for rendering
  53190. * @param camera The camera to use for rendering
  53191. * @param size This parameter can be set to a single number or to an object with the
  53192. * following (optional) properties: precision, width, height. If a single number is passed,
  53193. * it will be used for both width and height. If an object is passed, the screenshot size
  53194. * will be derived from the parameters. The precision property is a multiplier allowing
  53195. * rendering at a higher or lower resolution
  53196. * @param successCallback The callback receives a single parameter which contains the
  53197. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  53198. * src parameter of an <img> to display it
  53199. * @param mimeType The MIME type of the screenshot image (default: image/png).
  53200. * Check your browser for supported MIME types
  53201. * @param samples Texture samples (default: 1)
  53202. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  53203. * @param fileName A name for for the downloaded file.
  53204. */
  53205. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  53206. }
  53207. }
  53208. declare module BABYLON {
  53209. /**
  53210. * A cursor which tracks a point on a path
  53211. */
  53212. export class PathCursor {
  53213. private path;
  53214. /**
  53215. * Stores path cursor callbacks for when an onchange event is triggered
  53216. */
  53217. private _onchange;
  53218. /**
  53219. * The value of the path cursor
  53220. */
  53221. value: number;
  53222. /**
  53223. * The animation array of the path cursor
  53224. */
  53225. animations: Animation[];
  53226. /**
  53227. * Initializes the path cursor
  53228. * @param path The path to track
  53229. */
  53230. constructor(path: Path2);
  53231. /**
  53232. * Gets the cursor point on the path
  53233. * @returns A point on the path cursor at the cursor location
  53234. */
  53235. getPoint(): Vector3;
  53236. /**
  53237. * Moves the cursor ahead by the step amount
  53238. * @param step The amount to move the cursor forward
  53239. * @returns This path cursor
  53240. */
  53241. moveAhead(step?: number): PathCursor;
  53242. /**
  53243. * Moves the cursor behind by the step amount
  53244. * @param step The amount to move the cursor back
  53245. * @returns This path cursor
  53246. */
  53247. moveBack(step?: number): PathCursor;
  53248. /**
  53249. * Moves the cursor by the step amount
  53250. * If the step amount is greater than one, an exception is thrown
  53251. * @param step The amount to move the cursor
  53252. * @returns This path cursor
  53253. */
  53254. move(step: number): PathCursor;
  53255. /**
  53256. * Ensures that the value is limited between zero and one
  53257. * @returns This path cursor
  53258. */
  53259. private ensureLimits;
  53260. /**
  53261. * Runs onchange callbacks on change (used by the animation engine)
  53262. * @returns This path cursor
  53263. */
  53264. private raiseOnChange;
  53265. /**
  53266. * Executes a function on change
  53267. * @param f A path cursor onchange callback
  53268. * @returns This path cursor
  53269. */
  53270. onchange(f: (cursor: PathCursor) => void): PathCursor;
  53271. }
  53272. }
  53273. declare module BABYLON {
  53274. /** @hidden */
  53275. export var blurPixelShader: {
  53276. name: string;
  53277. shader: string;
  53278. };
  53279. }
  53280. declare module BABYLON {
  53281. /** @hidden */
  53282. export var bones300Declaration: {
  53283. name: string;
  53284. shader: string;
  53285. };
  53286. }
  53287. declare module BABYLON {
  53288. /** @hidden */
  53289. export var instances300Declaration: {
  53290. name: string;
  53291. shader: string;
  53292. };
  53293. }
  53294. declare module BABYLON {
  53295. /** @hidden */
  53296. export var pointCloudVertexDeclaration: {
  53297. name: string;
  53298. shader: string;
  53299. };
  53300. }
  53301. // Mixins
  53302. interface Window {
  53303. mozIndexedDB: IDBFactory;
  53304. webkitIndexedDB: IDBFactory;
  53305. msIndexedDB: IDBFactory;
  53306. webkitURL: typeof URL;
  53307. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  53308. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  53309. WebGLRenderingContext: WebGLRenderingContext;
  53310. MSGesture: MSGesture;
  53311. CANNON: any;
  53312. AudioContext: AudioContext;
  53313. webkitAudioContext: AudioContext;
  53314. PointerEvent: any;
  53315. Math: Math;
  53316. Uint8Array: Uint8ArrayConstructor;
  53317. Float32Array: Float32ArrayConstructor;
  53318. mozURL: typeof URL;
  53319. msURL: typeof URL;
  53320. VRFrameData: any; // WebVR, from specs 1.1
  53321. DracoDecoderModule: any;
  53322. setImmediate(handler: (...args: any[]) => void): number;
  53323. }
  53324. interface Document {
  53325. mozCancelFullScreen(): void;
  53326. msCancelFullScreen(): void;
  53327. webkitCancelFullScreen(): void;
  53328. requestPointerLock(): void;
  53329. exitPointerLock(): void;
  53330. mozFullScreen: boolean;
  53331. msIsFullScreen: boolean;
  53332. readonly webkitIsFullScreen: boolean;
  53333. readonly pointerLockElement: Element;
  53334. mozPointerLockElement: HTMLElement;
  53335. msPointerLockElement: HTMLElement;
  53336. webkitPointerLockElement: HTMLElement;
  53337. }
  53338. interface HTMLCanvasElement {
  53339. requestPointerLock(): void;
  53340. msRequestPointerLock?(): void;
  53341. mozRequestPointerLock?(): void;
  53342. webkitRequestPointerLock?(): void;
  53343. /** Track wether a record is in progress */
  53344. isRecording: boolean;
  53345. /** Capture Stream method defined by some browsers */
  53346. captureStream(fps?: number): MediaStream;
  53347. }
  53348. interface CanvasRenderingContext2D {
  53349. msImageSmoothingEnabled: boolean;
  53350. }
  53351. interface MouseEvent {
  53352. mozMovementX: number;
  53353. mozMovementY: number;
  53354. webkitMovementX: number;
  53355. webkitMovementY: number;
  53356. msMovementX: number;
  53357. msMovementY: number;
  53358. }
  53359. interface Navigator {
  53360. mozGetVRDevices: (any: any) => any;
  53361. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  53362. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  53363. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  53364. webkitGetGamepads(): Gamepad[];
  53365. msGetGamepads(): Gamepad[];
  53366. webkitGamepads(): Gamepad[];
  53367. }
  53368. interface HTMLVideoElement {
  53369. mozSrcObject: any;
  53370. }
  53371. interface Math {
  53372. fround(x: number): number;
  53373. imul(a: number, b: number): number;
  53374. }
  53375. interface WebGLProgram {
  53376. context?: WebGLRenderingContext;
  53377. vertexShader?: WebGLShader;
  53378. fragmentShader?: WebGLShader;
  53379. isParallelCompiled: boolean;
  53380. onCompiled?: () => void;
  53381. }
  53382. interface WebGLRenderingContext {
  53383. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  53384. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  53385. vertexAttribDivisor(index: number, divisor: number): void;
  53386. createVertexArray(): any;
  53387. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  53388. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  53389. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  53390. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  53391. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  53392. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  53393. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  53394. // Queries
  53395. createQuery(): WebGLQuery;
  53396. deleteQuery(query: WebGLQuery): void;
  53397. beginQuery(target: number, query: WebGLQuery): void;
  53398. endQuery(target: number): void;
  53399. getQueryParameter(query: WebGLQuery, pname: number): any;
  53400. getQuery(target: number, pname: number): any;
  53401. MAX_SAMPLES: number;
  53402. RGBA8: number;
  53403. READ_FRAMEBUFFER: number;
  53404. DRAW_FRAMEBUFFER: number;
  53405. UNIFORM_BUFFER: number;
  53406. HALF_FLOAT_OES: number;
  53407. RGBA16F: number;
  53408. RGBA32F: number;
  53409. R32F: number;
  53410. RG32F: number;
  53411. RGB32F: number;
  53412. R16F: number;
  53413. RG16F: number;
  53414. RGB16F: number;
  53415. RED: number;
  53416. RG: number;
  53417. R8: number;
  53418. RG8: number;
  53419. UNSIGNED_INT_24_8: number;
  53420. DEPTH24_STENCIL8: number;
  53421. /* Multiple Render Targets */
  53422. drawBuffers(buffers: number[]): void;
  53423. readBuffer(src: number): void;
  53424. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  53425. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  53426. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  53427. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  53428. // Occlusion Query
  53429. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  53430. ANY_SAMPLES_PASSED: number;
  53431. QUERY_RESULT_AVAILABLE: number;
  53432. QUERY_RESULT: number;
  53433. }
  53434. interface WebGLBuffer {
  53435. references: number;
  53436. capacity: number;
  53437. is32Bits: boolean;
  53438. }
  53439. interface WebGLProgram {
  53440. transformFeedback?: WebGLTransformFeedback | null;
  53441. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  53442. }
  53443. interface EXT_disjoint_timer_query {
  53444. QUERY_COUNTER_BITS_EXT: number;
  53445. TIME_ELAPSED_EXT: number;
  53446. TIMESTAMP_EXT: number;
  53447. GPU_DISJOINT_EXT: number;
  53448. QUERY_RESULT_EXT: number;
  53449. QUERY_RESULT_AVAILABLE_EXT: number;
  53450. queryCounterEXT(query: WebGLQuery, target: number): void;
  53451. createQueryEXT(): WebGLQuery;
  53452. beginQueryEXT(target: number, query: WebGLQuery): void;
  53453. endQueryEXT(target: number): void;
  53454. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  53455. deleteQueryEXT(query: WebGLQuery): void;
  53456. }
  53457. interface WebGLUniformLocation {
  53458. _currentState: any;
  53459. }
  53460. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  53461. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  53462. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  53463. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  53464. interface WebGLRenderingContext {
  53465. readonly RASTERIZER_DISCARD: number;
  53466. readonly DEPTH_COMPONENT24: number;
  53467. readonly TEXTURE_3D: number;
  53468. readonly TEXTURE_2D_ARRAY: number;
  53469. readonly TEXTURE_COMPARE_FUNC: number;
  53470. readonly TEXTURE_COMPARE_MODE: number;
  53471. readonly COMPARE_REF_TO_TEXTURE: number;
  53472. readonly TEXTURE_WRAP_R: number;
  53473. readonly HALF_FLOAT: number;
  53474. readonly RGB8: number;
  53475. readonly RED_INTEGER: number;
  53476. readonly RG_INTEGER: number;
  53477. readonly RGB_INTEGER: number;
  53478. readonly RGBA_INTEGER: number;
  53479. readonly R8_SNORM: number;
  53480. readonly RG8_SNORM: number;
  53481. readonly RGB8_SNORM: number;
  53482. readonly RGBA8_SNORM: number;
  53483. readonly R8I: number;
  53484. readonly RG8I: number;
  53485. readonly RGB8I: number;
  53486. readonly RGBA8I: number;
  53487. readonly R8UI: number;
  53488. readonly RG8UI: number;
  53489. readonly RGB8UI: number;
  53490. readonly RGBA8UI: number;
  53491. readonly R16I: number;
  53492. readonly RG16I: number;
  53493. readonly RGB16I: number;
  53494. readonly RGBA16I: number;
  53495. readonly R16UI: number;
  53496. readonly RG16UI: number;
  53497. readonly RGB16UI: number;
  53498. readonly RGBA16UI: number;
  53499. readonly R32I: number;
  53500. readonly RG32I: number;
  53501. readonly RGB32I: number;
  53502. readonly RGBA32I: number;
  53503. readonly R32UI: number;
  53504. readonly RG32UI: number;
  53505. readonly RGB32UI: number;
  53506. readonly RGBA32UI: number;
  53507. readonly RGB10_A2UI: number;
  53508. readonly R11F_G11F_B10F: number;
  53509. readonly RGB9_E5: number;
  53510. readonly RGB10_A2: number;
  53511. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  53512. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  53513. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  53514. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  53515. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  53516. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  53517. 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;
  53518. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  53519. readonly TRANSFORM_FEEDBACK: number;
  53520. readonly INTERLEAVED_ATTRIBS: number;
  53521. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  53522. createTransformFeedback(): WebGLTransformFeedback;
  53523. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  53524. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  53525. beginTransformFeedback(primitiveMode: number): void;
  53526. endTransformFeedback(): void;
  53527. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  53528. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  53529. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  53530. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  53531. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  53532. }
  53533. interface ImageBitmap {
  53534. readonly width: number;
  53535. readonly height: number;
  53536. close(): void;
  53537. }
  53538. interface WebGLQuery extends WebGLObject {
  53539. }
  53540. declare var WebGLQuery: {
  53541. prototype: WebGLQuery;
  53542. new(): WebGLQuery;
  53543. };
  53544. interface WebGLSampler extends WebGLObject {
  53545. }
  53546. declare var WebGLSampler: {
  53547. prototype: WebGLSampler;
  53548. new(): WebGLSampler;
  53549. };
  53550. interface WebGLSync extends WebGLObject {
  53551. }
  53552. declare var WebGLSync: {
  53553. prototype: WebGLSync;
  53554. new(): WebGLSync;
  53555. };
  53556. interface WebGLTransformFeedback extends WebGLObject {
  53557. }
  53558. declare var WebGLTransformFeedback: {
  53559. prototype: WebGLTransformFeedback;
  53560. new(): WebGLTransformFeedback;
  53561. };
  53562. interface WebGLVertexArrayObject extends WebGLObject {
  53563. }
  53564. declare var WebGLVertexArrayObject: {
  53565. prototype: WebGLVertexArrayObject;
  53566. new(): WebGLVertexArrayObject;
  53567. };
  53568. // Type definitions for WebVR API
  53569. // Project: https://w3c.github.io/webvr/
  53570. // Definitions by: six a <https://github.com/lostfictions>
  53571. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  53572. interface VRDisplay extends EventTarget {
  53573. /**
  53574. * Dictionary of capabilities describing the VRDisplay.
  53575. */
  53576. readonly capabilities: VRDisplayCapabilities;
  53577. /**
  53578. * z-depth defining the far plane of the eye view frustum
  53579. * enables mapping of values in the render target depth
  53580. * attachment to scene coordinates. Initially set to 10000.0.
  53581. */
  53582. depthFar: number;
  53583. /**
  53584. * z-depth defining the near plane of the eye view frustum
  53585. * enables mapping of values in the render target depth
  53586. * attachment to scene coordinates. Initially set to 0.01.
  53587. */
  53588. depthNear: number;
  53589. /**
  53590. * An identifier for this distinct VRDisplay. Used as an
  53591. * association point in the Gamepad API.
  53592. */
  53593. readonly displayId: number;
  53594. /**
  53595. * A display name, a user-readable name identifying it.
  53596. */
  53597. readonly displayName: string;
  53598. readonly isConnected: boolean;
  53599. readonly isPresenting: boolean;
  53600. /**
  53601. * If this VRDisplay supports room-scale experiences, the optional
  53602. * stage attribute contains details on the room-scale parameters.
  53603. */
  53604. readonly stageParameters: VRStageParameters | null;
  53605. /**
  53606. * Passing the value returned by `requestAnimationFrame` to
  53607. * `cancelAnimationFrame` will unregister the callback.
  53608. * @param handle Define the hanle of the request to cancel
  53609. */
  53610. cancelAnimationFrame(handle: number): void;
  53611. /**
  53612. * Stops presenting to the VRDisplay.
  53613. * @returns a promise to know when it stopped
  53614. */
  53615. exitPresent(): Promise<void>;
  53616. /**
  53617. * Return the current VREyeParameters for the given eye.
  53618. * @param whichEye Define the eye we want the parameter for
  53619. * @returns the eye parameters
  53620. */
  53621. getEyeParameters(whichEye: string): VREyeParameters;
  53622. /**
  53623. * Populates the passed VRFrameData with the information required to render
  53624. * the current frame.
  53625. * @param frameData Define the data structure to populate
  53626. * @returns true if ok otherwise false
  53627. */
  53628. getFrameData(frameData: VRFrameData): boolean;
  53629. /**
  53630. * Get the layers currently being presented.
  53631. * @returns the list of VR layers
  53632. */
  53633. getLayers(): VRLayer[];
  53634. /**
  53635. * Return a VRPose containing the future predicted pose of the VRDisplay
  53636. * when the current frame will be presented. The value returned will not
  53637. * change until JavaScript has returned control to the browser.
  53638. *
  53639. * The VRPose will contain the position, orientation, velocity,
  53640. * and acceleration of each of these properties.
  53641. * @returns the pose object
  53642. */
  53643. getPose(): VRPose;
  53644. /**
  53645. * Return the current instantaneous pose of the VRDisplay, with no
  53646. * prediction applied.
  53647. * @returns the current instantaneous pose
  53648. */
  53649. getImmediatePose(): VRPose;
  53650. /**
  53651. * The callback passed to `requestAnimationFrame` will be called
  53652. * any time a new frame should be rendered. When the VRDisplay is
  53653. * presenting the callback will be called at the native refresh
  53654. * rate of the HMD. When not presenting this function acts
  53655. * identically to how window.requestAnimationFrame acts. Content should
  53656. * make no assumptions of frame rate or vsync behavior as the HMD runs
  53657. * asynchronously from other displays and at differing refresh rates.
  53658. * @param callback Define the eaction to run next frame
  53659. * @returns the request handle it
  53660. */
  53661. requestAnimationFrame(callback: FrameRequestCallback): number;
  53662. /**
  53663. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  53664. * Repeat calls while already presenting will update the VRLayers being displayed.
  53665. * @param layers Define the list of layer to present
  53666. * @returns a promise to know when the request has been fulfilled
  53667. */
  53668. requestPresent(layers: VRLayer[]): Promise<void>;
  53669. /**
  53670. * Reset the pose for this display, treating its current position and
  53671. * orientation as the "origin/zero" values. VRPose.position,
  53672. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  53673. * updated when calling resetPose(). This should be called in only
  53674. * sitting-space experiences.
  53675. */
  53676. resetPose(): void;
  53677. /**
  53678. * The VRLayer provided to the VRDisplay will be captured and presented
  53679. * in the HMD. Calling this function has the same effect on the source
  53680. * canvas as any other operation that uses its source image, and canvases
  53681. * created without preserveDrawingBuffer set to true will be cleared.
  53682. * @param pose Define the pose to submit
  53683. */
  53684. submitFrame(pose?: VRPose): void;
  53685. }
  53686. declare var VRDisplay: {
  53687. prototype: VRDisplay;
  53688. new(): VRDisplay;
  53689. };
  53690. interface VRLayer {
  53691. leftBounds?: number[] | Float32Array | null;
  53692. rightBounds?: number[] | Float32Array | null;
  53693. source?: HTMLCanvasElement | null;
  53694. }
  53695. interface VRDisplayCapabilities {
  53696. readonly canPresent: boolean;
  53697. readonly hasExternalDisplay: boolean;
  53698. readonly hasOrientation: boolean;
  53699. readonly hasPosition: boolean;
  53700. readonly maxLayers: number;
  53701. }
  53702. interface VREyeParameters {
  53703. /** @deprecated */
  53704. readonly fieldOfView: VRFieldOfView;
  53705. readonly offset: Float32Array;
  53706. readonly renderHeight: number;
  53707. readonly renderWidth: number;
  53708. }
  53709. interface VRFieldOfView {
  53710. readonly downDegrees: number;
  53711. readonly leftDegrees: number;
  53712. readonly rightDegrees: number;
  53713. readonly upDegrees: number;
  53714. }
  53715. interface VRFrameData {
  53716. readonly leftProjectionMatrix: Float32Array;
  53717. readonly leftViewMatrix: Float32Array;
  53718. readonly pose: VRPose;
  53719. readonly rightProjectionMatrix: Float32Array;
  53720. readonly rightViewMatrix: Float32Array;
  53721. readonly timestamp: number;
  53722. }
  53723. interface VRPose {
  53724. readonly angularAcceleration: Float32Array | null;
  53725. readonly angularVelocity: Float32Array | null;
  53726. readonly linearAcceleration: Float32Array | null;
  53727. readonly linearVelocity: Float32Array | null;
  53728. readonly orientation: Float32Array | null;
  53729. readonly position: Float32Array | null;
  53730. readonly timestamp: number;
  53731. }
  53732. interface VRStageParameters {
  53733. sittingToStandingTransform?: Float32Array;
  53734. sizeX?: number;
  53735. sizeY?: number;
  53736. }
  53737. interface Navigator {
  53738. getVRDisplays(): Promise<VRDisplay[]>;
  53739. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  53740. }
  53741. interface Window {
  53742. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  53743. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  53744. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  53745. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  53746. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  53747. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  53748. }
  53749. interface Gamepad {
  53750. readonly displayId: number;
  53751. }
  53752. interface XRDevice {
  53753. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  53754. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  53755. }
  53756. interface XRSession {
  53757. getInputSources(): Array<any>;
  53758. baseLayer: XRWebGLLayer;
  53759. requestFrameOfReference(type: string): Promise<void>;
  53760. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  53761. end(): Promise<void>;
  53762. requestAnimationFrame: Function;
  53763. addEventListener: Function;
  53764. }
  53765. interface XRSessionCreationOptions {
  53766. outputContext?: WebGLRenderingContext | null;
  53767. immersive?: boolean;
  53768. environmentIntegration?: boolean;
  53769. }
  53770. interface XRLayer {
  53771. getViewport: Function;
  53772. framebufferWidth: number;
  53773. framebufferHeight: number;
  53774. }
  53775. interface XRView {
  53776. projectionMatrix: Float32Array;
  53777. }
  53778. interface XRFrame {
  53779. getDevicePose: Function;
  53780. getInputPose: Function;
  53781. views: Array<XRView>;
  53782. baseLayer: XRLayer;
  53783. }
  53784. interface XRFrameOfReference {
  53785. }
  53786. interface XRWebGLLayer extends XRLayer {
  53787. framebuffer: WebGLFramebuffer;
  53788. }
  53789. declare var XRWebGLLayer: {
  53790. prototype: XRWebGLLayer;
  53791. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  53792. };