babylon.d.ts 2.1 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  8. */
  9. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  10. /**
  11. * Defines how the individual parser contract is defined.
  12. * These parser can parse an individual asset
  13. */
  14. type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  15. /**
  16. * Base class of the scene acting as a container for the different elements composing a scene.
  17. * This class is dynamically extended by the different components of the scene increasing
  18. * flexibility and reducing coupling
  19. */
  20. abstract class AbstractScene {
  21. /**
  22. * Stores the list of available parsers in the application.
  23. */
  24. private static _BabylonFileParsers;
  25. /**
  26. * Stores the list of available individual parsers in the application.
  27. */
  28. private static _IndividualBabylonFileParsers;
  29. /**
  30. * Adds a parser in the list of available ones
  31. * @param name Defines the name of the parser
  32. * @param parser Defines the parser to add
  33. */
  34. static AddParser(name: string, parser: BabylonFileParser): void;
  35. /**
  36. * Gets a general parser from the list of avaialble ones
  37. * @param name Defines the name of the parser
  38. * @returns the requested parser or null
  39. */
  40. static GetParser(name: string): Nullable<BabylonFileParser>;
  41. /**
  42. * Adds n individual parser in the list of available ones
  43. * @param name Defines the name of the parser
  44. * @param parser Defines the parser to add
  45. */
  46. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47. /**
  48. * Gets an individual parser from the list of avaialble ones
  49. * @param name Defines the name of the parser
  50. * @returns the requested parser or null
  51. */
  52. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  53. /**
  54. * Parser json data and populate both a scene and its associated container object
  55. * @param jsonData Defines the data to parse
  56. * @param scene Defines the scene to parse the data for
  57. * @param container Defines the container attached to the parsing sequence
  58. * @param rootUrl Defines the root url of the data
  59. */
  60. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  61. /**
  62. * Gets the list of root nodes (ie. nodes with no parent)
  63. */
  64. rootNodes: Node[];
  65. /** All of the cameras added to this scene
  66. * @see http://doc.babylonjs.com/babylon101/cameras
  67. */
  68. cameras: Camera[];
  69. /**
  70. * All of the lights added to this scene
  71. * @see http://doc.babylonjs.com/babylon101/lights
  72. */
  73. lights: Light[];
  74. /**
  75. * All of the (abstract) meshes added to this scene
  76. */
  77. meshes: AbstractMesh[];
  78. /**
  79. * The list of skeletons added to the scene
  80. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81. */
  82. skeletons: Skeleton[];
  83. /**
  84. * All of the particle systems added to this scene
  85. * @see http://doc.babylonjs.com/babylon101/particles
  86. */
  87. particleSystems: IParticleSystem[];
  88. /**
  89. * Gets a list of Animations associated with the scene
  90. */
  91. animations: Animation[];
  92. /**
  93. * All of the animation groups added to this scene
  94. * @see http://doc.babylonjs.com/how_to/group
  95. */
  96. animationGroups: AnimationGroup[];
  97. /**
  98. * All of the multi-materials added to this scene
  99. * @see http://doc.babylonjs.com/how_to/multi_materials
  100. */
  101. multiMaterials: MultiMaterial[];
  102. /**
  103. * All of the materials added to this scene
  104. * In the context of a Scene, it is not supposed to be modified manually.
  105. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  106. * Note also that the order of the Material wihin the array is not significant and might change.
  107. * @see http://doc.babylonjs.com/babylon101/materials
  108. */
  109. materials: Material[];
  110. /**
  111. * The list of morph target managers added to the scene
  112. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  113. */
  114. morphTargetManagers: MorphTargetManager[];
  115. /**
  116. * The list of geometries used in the scene.
  117. */
  118. geometries: Geometry[];
  119. /**
  120. * All of the tranform nodes added to this scene
  121. * In the context of a Scene, it is not supposed to be modified manually.
  122. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  123. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  124. * @see http://doc.babylonjs.com/how_to/transformnode
  125. */
  126. transformNodes: TransformNode[];
  127. /**
  128. * ActionManagers available on the scene.
  129. */
  130. actionManagers: ActionManager[];
  131. /**
  132. * Textures to keep.
  133. */
  134. textures: BaseTexture[];
  135. }
  136. }
  137. declare module BABYLON {
  138. /**
  139. * Set of assets to keep when moving a scene into an asset container.
  140. */
  141. class KeepAssets extends AbstractScene {
  142. }
  143. /**
  144. * Container with a set of assets that can be added or removed from a scene.
  145. */
  146. class AssetContainer extends AbstractScene {
  147. /**
  148. * The scene the AssetContainer belongs to.
  149. */
  150. scene: Scene;
  151. /**
  152. * Instantiates an AssetContainer.
  153. * @param scene The scene the AssetContainer belongs to.
  154. */
  155. constructor(scene: Scene);
  156. /**
  157. * Adds all the assets from the container to the scene.
  158. */
  159. addAllToScene(): void;
  160. /**
  161. * Removes all the assets in the container from the scene
  162. */
  163. removeAllFromScene(): void;
  164. /**
  165. * Disposes all the assets in the container
  166. */
  167. dispose(): void;
  168. private _moveAssets;
  169. /**
  170. * Removes all the assets contained in the scene and adds them to the container.
  171. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  172. */
  173. moveAllFromScene(keepAssets?: KeepAssets): void;
  174. /**
  175. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  176. * @returns the root mesh
  177. */
  178. createRootMesh(): Mesh;
  179. }
  180. }
  181. interface Window {
  182. mozIndexedDB: IDBFactory;
  183. webkitIndexedDB: IDBFactory;
  184. msIndexedDB: IDBFactory;
  185. webkitURL: typeof URL;
  186. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  187. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  188. WebGLRenderingContext: WebGLRenderingContext;
  189. MSGesture: MSGesture;
  190. CANNON: any;
  191. AudioContext: AudioContext;
  192. webkitAudioContext: AudioContext;
  193. PointerEvent: any;
  194. Math: Math;
  195. Uint8Array: Uint8ArrayConstructor;
  196. Float32Array: Float32ArrayConstructor;
  197. mozURL: typeof URL;
  198. msURL: typeof URL;
  199. VRFrameData: any;
  200. DracoDecoderModule: any;
  201. setImmediate(handler: (...args: any[]) => void): number;
  202. }
  203. interface WebGLProgram {
  204. context?: WebGLRenderingContext;
  205. vertexShader?: WebGLShader;
  206. fragmentShader?: WebGLShader;
  207. isParallelCompiled: boolean;
  208. onCompiled?: () => void;
  209. }
  210. interface WebGLRenderingContext {
  211. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  212. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  213. vertexAttribDivisor(index: number, divisor: number): void;
  214. createVertexArray(): any;
  215. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  216. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  217. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  218. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  219. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  220. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  221. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  222. createQuery(): WebGLQuery;
  223. deleteQuery(query: WebGLQuery): void;
  224. beginQuery(target: number, query: WebGLQuery): void;
  225. endQuery(target: number): void;
  226. getQueryParameter(query: WebGLQuery, pname: number): any;
  227. getQuery(target: number, pname: number): any;
  228. MAX_SAMPLES: number;
  229. RGBA8: number;
  230. READ_FRAMEBUFFER: number;
  231. DRAW_FRAMEBUFFER: number;
  232. UNIFORM_BUFFER: number;
  233. HALF_FLOAT_OES: number;
  234. RGBA16F: number;
  235. RGBA32F: number;
  236. R32F: number;
  237. RG32F: number;
  238. RGB32F: number;
  239. R16F: number;
  240. RG16F: number;
  241. RGB16F: number;
  242. RED: number;
  243. RG: number;
  244. R8: number;
  245. RG8: number;
  246. UNSIGNED_INT_24_8: number;
  247. DEPTH24_STENCIL8: number;
  248. drawBuffers(buffers: number[]): void;
  249. readBuffer(src: number): void;
  250. readonly COLOR_ATTACHMENT0: number;
  251. readonly COLOR_ATTACHMENT1: number;
  252. readonly COLOR_ATTACHMENT2: number;
  253. readonly COLOR_ATTACHMENT3: number;
  254. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  255. ANY_SAMPLES_PASSED: number;
  256. QUERY_RESULT_AVAILABLE: number;
  257. QUERY_RESULT: number;
  258. }
  259. interface Document {
  260. mozCancelFullScreen(): void;
  261. msCancelFullScreen(): void;
  262. webkitCancelFullScreen(): void;
  263. requestPointerLock(): void;
  264. exitPointerLock(): void;
  265. mozFullScreen: boolean;
  266. msIsFullScreen: boolean;
  267. readonly webkitIsFullScreen: boolean;
  268. readonly pointerLockElement: Element;
  269. mozPointerLockElement: HTMLElement;
  270. msPointerLockElement: HTMLElement;
  271. webkitPointerLockElement: HTMLElement;
  272. }
  273. interface HTMLCanvasElement {
  274. requestPointerLock(): void;
  275. msRequestPointerLock?(): void;
  276. mozRequestPointerLock?(): void;
  277. webkitRequestPointerLock?(): void;
  278. }
  279. interface CanvasRenderingContext2D {
  280. msImageSmoothingEnabled: boolean;
  281. }
  282. interface WebGLBuffer {
  283. references: number;
  284. capacity: number;
  285. is32Bits: boolean;
  286. }
  287. interface WebGLProgram {
  288. transformFeedback?: WebGLTransformFeedback | null;
  289. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  290. }
  291. interface MouseEvent {
  292. mozMovementX: number;
  293. mozMovementY: number;
  294. webkitMovementX: number;
  295. webkitMovementY: number;
  296. msMovementX: number;
  297. msMovementY: number;
  298. }
  299. interface Navigator {
  300. mozGetVRDevices: (any: any) => any;
  301. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  302. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  303. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  304. webkitGetGamepads(): Gamepad[];
  305. msGetGamepads(): Gamepad[];
  306. webkitGamepads(): Gamepad[];
  307. }
  308. interface HTMLVideoElement {
  309. mozSrcObject: any;
  310. }
  311. interface Math {
  312. fround(x: number): number;
  313. imul(a: number, b: number): number;
  314. }
  315. interface EXT_disjoint_timer_query {
  316. QUERY_COUNTER_BITS_EXT: number;
  317. TIME_ELAPSED_EXT: number;
  318. TIMESTAMP_EXT: number;
  319. GPU_DISJOINT_EXT: number;
  320. QUERY_RESULT_EXT: number;
  321. QUERY_RESULT_AVAILABLE_EXT: number;
  322. queryCounterEXT(query: WebGLQuery, target: number): void;
  323. createQueryEXT(): WebGLQuery;
  324. beginQueryEXT(target: number, query: WebGLQuery): void;
  325. endQueryEXT(target: number): void;
  326. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  327. deleteQueryEXT(query: WebGLQuery): void;
  328. }
  329. interface WebGLUniformLocation {
  330. _currentState: any;
  331. }
  332. interface XRDevice {
  333. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  334. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  335. }
  336. interface XRSession {
  337. getInputSources(): Array<any>;
  338. baseLayer: XRWebGLLayer;
  339. requestFrameOfReference(type: string): Promise<void>;
  340. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  341. end(): Promise<void>;
  342. requestAnimationFrame: Function;
  343. addEventListener: Function;
  344. }
  345. interface XRSessionCreationOptions {
  346. outputContext?: WebGLRenderingContext | null;
  347. immersive?: boolean;
  348. environmentIntegration?: boolean;
  349. }
  350. interface XRLayer {
  351. getViewport: Function;
  352. framebufferWidth: number;
  353. framebufferHeight: number;
  354. }
  355. interface XRView {
  356. projectionMatrix: Float32Array;
  357. }
  358. interface XRFrame {
  359. getDevicePose: Function;
  360. getInputPose: Function;
  361. views: Array<XRView>;
  362. baseLayer: XRLayer;
  363. }
  364. interface XRFrameOfReference {
  365. }
  366. interface XRWebGLLayer extends XRLayer {
  367. framebuffer: WebGLFramebuffer;
  368. }
  369. declare var XRWebGLLayer: {
  370. prototype: XRWebGLLayer;
  371. new (session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  372. };
  373. declare module BABYLON {
  374. /**
  375. * Defines how a node can be built from a string name.
  376. */
  377. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  378. /**
  379. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  380. */
  381. class Node implements IBehaviorAware<Node> {
  382. private static _NodeConstructors;
  383. /**
  384. * Add a new node constructor
  385. * @param type defines the type name of the node to construct
  386. * @param constructorFunc defines the constructor function
  387. */
  388. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  389. /**
  390. * Returns a node constructor based on type name
  391. * @param type defines the type name
  392. * @param name defines the new node name
  393. * @param scene defines the hosting scene
  394. * @param options defines optional options to transmit to constructors
  395. * @returns the new constructor or null
  396. */
  397. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  398. /**
  399. * Gets or sets the name of the node
  400. */
  401. name: string;
  402. /**
  403. * Gets or sets the id of the node
  404. */
  405. id: string;
  406. /**
  407. * Gets or sets the unique id of the node
  408. */
  409. uniqueId: number;
  410. /**
  411. * Gets or sets a string used to store user defined state for the node
  412. */
  413. state: string;
  414. /**
  415. * Gets or sets an object used to store user defined information for the node
  416. */
  417. metadata: any;
  418. /**
  419. * For internal use only. Please do not use.
  420. */
  421. reservedDataStore: any;
  422. /**
  423. * Gets or sets a boolean used to define if the node must be serialized
  424. */
  425. doNotSerialize: boolean;
  426. /** @hidden */
  427. _isDisposed: boolean;
  428. /**
  429. * Gets a list of Animations associated with the node
  430. */
  431. animations: Animation[];
  432. protected _ranges: {
  433. [name: string]: Nullable<AnimationRange>;
  434. };
  435. /**
  436. * Callback raised when the node is ready to be used
  437. */
  438. onReady: (node: Node) => void;
  439. private _isEnabled;
  440. private _isParentEnabled;
  441. private _isReady;
  442. /** @hidden */
  443. _currentRenderId: number;
  444. private _parentRenderId;
  445. protected _childRenderId: number;
  446. /** @hidden */
  447. _waitingParentId: Nullable<string>;
  448. /** @hidden */
  449. _scene: Scene;
  450. /** @hidden */
  451. _cache: any;
  452. private _parentNode;
  453. private _children;
  454. /** @hidden */
  455. _worldMatrix: Matrix;
  456. /** @hidden */
  457. _worldMatrixDeterminant: number;
  458. /** @hidden */
  459. private _sceneRootNodesIndex;
  460. /**
  461. * Gets a boolean indicating if the node has been disposed
  462. * @returns true if the node was disposed
  463. */
  464. isDisposed(): boolean;
  465. /**
  466. * Gets or sets the parent of the node
  467. */
  468. parent: Nullable<Node>;
  469. private addToSceneRootNodes;
  470. private removeFromSceneRootNodes;
  471. private _animationPropertiesOverride;
  472. /**
  473. * Gets or sets the animation properties override
  474. */
  475. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  476. /**
  477. * Gets a string idenfifying the name of the class
  478. * @returns "Node" string
  479. */
  480. getClassName(): string;
  481. /**
  482. * An event triggered when the mesh is disposed
  483. */
  484. onDisposeObservable: Observable<Node>;
  485. private _onDisposeObserver;
  486. /**
  487. * Sets a callback that will be raised when the node will be disposed
  488. */
  489. onDispose: () => void;
  490. /**
  491. * Creates a new Node
  492. * @param name the name and id to be given to this node
  493. * @param scene the scene this node will be added to
  494. * @param addToRootNodes the node will be added to scene.rootNodes
  495. */
  496. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  497. /**
  498. * Gets the scene of the node
  499. * @returns a scene
  500. */
  501. getScene(): Scene;
  502. /**
  503. * Gets the engine of the node
  504. * @returns a Engine
  505. */
  506. getEngine(): Engine;
  507. private _behaviors;
  508. /**
  509. * Attach a behavior to the node
  510. * @see http://doc.babylonjs.com/features/behaviour
  511. * @param behavior defines the behavior to attach
  512. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  513. * @returns the current Node
  514. */
  515. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  516. /**
  517. * Remove an attached behavior
  518. * @see http://doc.babylonjs.com/features/behaviour
  519. * @param behavior defines the behavior to attach
  520. * @returns the current Node
  521. */
  522. removeBehavior(behavior: Behavior<Node>): Node;
  523. /**
  524. * Gets the list of attached behaviors
  525. * @see http://doc.babylonjs.com/features/behaviour
  526. */
  527. readonly behaviors: Behavior<Node>[];
  528. /**
  529. * Gets an attached behavior by name
  530. * @param name defines the name of the behavior to look for
  531. * @see http://doc.babylonjs.com/features/behaviour
  532. * @returns null if behavior was not found else the requested behavior
  533. */
  534. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  535. /**
  536. * Returns the latest update of the World matrix
  537. * @returns a Matrix
  538. */
  539. getWorldMatrix(): Matrix;
  540. /** @hidden */
  541. _getWorldMatrixDeterminant(): number;
  542. /**
  543. * Returns directly the latest state of the mesh World matrix.
  544. * A Matrix is returned.
  545. */
  546. readonly worldMatrixFromCache: Matrix;
  547. /** @hidden */
  548. _initCache(): void;
  549. /** @hidden */
  550. updateCache(force?: boolean): void;
  551. /** @hidden */
  552. _updateCache(ignoreParentClass?: boolean): void;
  553. /** @hidden */
  554. _isSynchronized(): boolean;
  555. /** @hidden */
  556. _markSyncedWithParent(): void;
  557. /** @hidden */
  558. isSynchronizedWithParent(): boolean;
  559. /** @hidden */
  560. isSynchronized(): boolean;
  561. /**
  562. * Is this node ready to be used/rendered
  563. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  564. * @return true if the node is ready
  565. */
  566. isReady(completeCheck?: boolean): boolean;
  567. /**
  568. * Is this node enabled?
  569. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  570. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  571. * @return whether this node (and its parent) is enabled
  572. */
  573. isEnabled(checkAncestors?: boolean): boolean;
  574. /** @hidden */
  575. protected _syncParentEnabledState(): void;
  576. /**
  577. * Set the enabled state of this node
  578. * @param value defines the new enabled state
  579. */
  580. setEnabled(value: boolean): void;
  581. /**
  582. * Is this node a descendant of the given node?
  583. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  584. * @param ancestor defines the parent node to inspect
  585. * @returns a boolean indicating if this node is a descendant of the given node
  586. */
  587. isDescendantOf(ancestor: Node): boolean;
  588. /** @hidden */
  589. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  590. /**
  591. * Will return all nodes that have this node as ascendant
  592. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  593. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  594. * @return all children nodes of all types
  595. */
  596. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  597. /**
  598. * Get all child-meshes of this node
  599. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  600. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  601. * @returns an array of AbstractMesh
  602. */
  603. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  604. /**
  605. * Get all child-transformNodes of this node
  606. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  607. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  608. * @returns an array of TransformNode
  609. */
  610. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  611. /**
  612. * Get all direct children of this node
  613. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  614. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  615. * @returns an array of Node
  616. */
  617. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  618. /** @hidden */
  619. _setReady(state: boolean): void;
  620. /**
  621. * Get an animation by name
  622. * @param name defines the name of the animation to look for
  623. * @returns null if not found else the requested animation
  624. */
  625. getAnimationByName(name: string): Nullable<Animation>;
  626. /**
  627. * Creates an animation range for this node
  628. * @param name defines the name of the range
  629. * @param from defines the starting key
  630. * @param to defines the end key
  631. */
  632. createAnimationRange(name: string, from: number, to: number): void;
  633. /**
  634. * Delete a specific animation range
  635. * @param name defines the name of the range to delete
  636. * @param deleteFrames defines if animation frames from the range must be deleted as well
  637. */
  638. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  639. /**
  640. * Get an animation range by name
  641. * @param name defines the name of the animation range to look for
  642. * @returns null if not found else the requested animation range
  643. */
  644. getAnimationRange(name: string): Nullable<AnimationRange>;
  645. /**
  646. * Will start the animation sequence
  647. * @param name defines the range frames for animation sequence
  648. * @param loop defines if the animation should loop (false by default)
  649. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  650. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  651. * @returns the object created for this animation. If range does not exist, it will return null
  652. */
  653. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  654. /**
  655. * Serialize animation ranges into a JSON compatible object
  656. * @returns serialization object
  657. */
  658. serializeAnimationRanges(): any;
  659. /**
  660. * Computes the world matrix of the node
  661. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  662. * @returns the world matrix
  663. */
  664. computeWorldMatrix(force?: boolean): Matrix;
  665. /**
  666. * Releases resources associated with this node.
  667. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  668. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  669. */
  670. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  671. /**
  672. * Parse animation range data from a serialization object and store them into a given node
  673. * @param node defines where to store the animation ranges
  674. * @param parsedNode defines the serialization object to read data from
  675. * @param scene defines the hosting scene
  676. */
  677. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  678. }
  679. }
  680. declare module BABYLON {
  681. /**
  682. * Define an interface for all classes that will hold resources
  683. */
  684. interface IDisposable {
  685. /**
  686. * Releases all held resources
  687. */
  688. dispose(): void;
  689. }
  690. /**
  691. * This class is used by the onRenderingGroupObservable
  692. */
  693. class RenderingGroupInfo {
  694. /**
  695. * The Scene that being rendered
  696. */
  697. scene: Scene;
  698. /**
  699. * The camera currently used for the rendering pass
  700. */
  701. camera: Nullable<Camera>;
  702. /**
  703. * The ID of the renderingGroup being processed
  704. */
  705. renderingGroupId: number;
  706. }
  707. /** Interface defining initialization parameters for Scene class */
  708. interface SceneOptions {
  709. /**
  710. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by Id
  711. * It will improve performance when the number of geometries becomes important.
  712. */
  713. useGeometryIdsMap?: boolean;
  714. /**
  715. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  716. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  717. */
  718. useMaterialMeshMap?: boolean;
  719. /**
  720. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  721. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  722. */
  723. useClonedMeshhMap?: boolean;
  724. }
  725. /**
  726. * Represents a scene to be rendered by the engine.
  727. * @see http://doc.babylonjs.com/features/scene
  728. */
  729. class Scene extends AbstractScene implements IAnimatable {
  730. private static _uniqueIdCounter;
  731. /** The fog is deactivated */
  732. static readonly FOGMODE_NONE: number;
  733. /** The fog density is following an exponential function */
  734. static readonly FOGMODE_EXP: number;
  735. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  736. static readonly FOGMODE_EXP2: number;
  737. /** The fog density is following a linear function. */
  738. static readonly FOGMODE_LINEAR: number;
  739. /**
  740. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  741. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  742. */
  743. static MinDeltaTime: number;
  744. /**
  745. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  746. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  747. */
  748. static MaxDeltaTime: number;
  749. /**
  750. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  751. */
  752. autoClear: boolean;
  753. /**
  754. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  755. */
  756. autoClearDepthAndStencil: boolean;
  757. /**
  758. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  759. */
  760. clearColor: Color4;
  761. /**
  762. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  763. */
  764. ambientColor: Color3;
  765. /** @hidden */
  766. _environmentBRDFTexture: BaseTexture;
  767. /** @hidden */
  768. protected _environmentTexture: Nullable<BaseTexture>;
  769. /**
  770. * Texture used in all pbr material as the reflection texture.
  771. * As in the majority of the scene they are the same (exception for multi room and so on),
  772. * this is easier to reference from here than from all the materials.
  773. */
  774. /**
  775. * Texture used in all pbr material as the reflection texture.
  776. * As in the majority of the scene they are the same (exception for multi room and so on),
  777. * this is easier to set here than in all the materials.
  778. */
  779. environmentTexture: Nullable<BaseTexture>;
  780. /** @hidden */
  781. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  782. /**
  783. * Default image processing configuration used either in the rendering
  784. * Forward main pass or through the imageProcessingPostProcess if present.
  785. * As in the majority of the scene they are the same (exception for multi camera),
  786. * this is easier to reference from here than from all the materials and post process.
  787. *
  788. * No setter as we it is a shared configuration, you can set the values instead.
  789. */
  790. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  791. private _forceWireframe;
  792. /**
  793. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  794. */
  795. forceWireframe: boolean;
  796. private _forcePointsCloud;
  797. /**
  798. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  799. */
  800. forcePointsCloud: boolean;
  801. /**
  802. * Gets or sets the active clipplane 1
  803. */
  804. clipPlane: Nullable<Plane>;
  805. /**
  806. * Gets or sets the active clipplane 2
  807. */
  808. clipPlane2: Nullable<Plane>;
  809. /**
  810. * Gets or sets the active clipplane 3
  811. */
  812. clipPlane3: Nullable<Plane>;
  813. /**
  814. * Gets or sets the active clipplane 4
  815. */
  816. clipPlane4: Nullable<Plane>;
  817. /**
  818. * Gets or sets a boolean indicating if animations are enabled
  819. */
  820. animationsEnabled: boolean;
  821. private _animationPropertiesOverride;
  822. /**
  823. * Gets or sets the animation properties override
  824. */
  825. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  826. /**
  827. * Gets or sets a boolean indicating if a constant deltatime has to be used
  828. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  829. */
  830. useConstantAnimationDeltaTime: boolean;
  831. /**
  832. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  833. * Please note that it requires to run a ray cast through the scene on every frame
  834. */
  835. constantlyUpdateMeshUnderPointer: boolean;
  836. /**
  837. * Defines the HTML cursor to use when hovering over interactive elements
  838. */
  839. hoverCursor: string;
  840. /**
  841. * Defines the HTML default cursor to use (empty by default)
  842. */
  843. defaultCursor: string;
  844. /**
  845. * This is used to call preventDefault() on pointer down
  846. * in order to block unwanted artifacts like system double clicks
  847. */
  848. preventDefaultOnPointerDown: boolean;
  849. /**
  850. * This is used to call preventDefault() on pointer up
  851. * in order to block unwanted artifacts like system double clicks
  852. */
  853. preventDefaultOnPointerUp: boolean;
  854. /**
  855. * Gets or sets user defined metadata
  856. */
  857. metadata: any;
  858. /**
  859. * For internal use only. Please do not use.
  860. */
  861. reservedDataStore: any;
  862. /**
  863. * Gets the name of the plugin used to load this scene (null by default)
  864. */
  865. loadingPluginName: string;
  866. /**
  867. * Use this array to add regular expressions used to disable offline support for specific urls
  868. */
  869. disableOfflineSupportExceptionRules: RegExp[];
  870. /**
  871. * An event triggered when the scene is disposed.
  872. */
  873. onDisposeObservable: Observable<Scene>;
  874. private _onDisposeObserver;
  875. /** Sets a function to be executed when this scene is disposed. */
  876. onDispose: () => void;
  877. /**
  878. * An event triggered before rendering the scene (right after animations and physics)
  879. */
  880. onBeforeRenderObservable: Observable<Scene>;
  881. private _onBeforeRenderObserver;
  882. /** Sets a function to be executed before rendering this scene */
  883. beforeRender: Nullable<() => void>;
  884. /**
  885. * An event triggered after rendering the scene
  886. */
  887. onAfterRenderObservable: Observable<Scene>;
  888. private _onAfterRenderObserver;
  889. /** Sets a function to be executed after rendering this scene */
  890. afterRender: Nullable<() => void>;
  891. /**
  892. * An event triggered before animating the scene
  893. */
  894. onBeforeAnimationsObservable: Observable<Scene>;
  895. /**
  896. * An event triggered after animations processing
  897. */
  898. onAfterAnimationsObservable: Observable<Scene>;
  899. /**
  900. * An event triggered before draw calls are ready to be sent
  901. */
  902. onBeforeDrawPhaseObservable: Observable<Scene>;
  903. /**
  904. * An event triggered after draw calls have been sent
  905. */
  906. onAfterDrawPhaseObservable: Observable<Scene>;
  907. /**
  908. * An event triggered when the scene is ready
  909. */
  910. onReadyObservable: Observable<Scene>;
  911. /**
  912. * An event triggered before rendering a camera
  913. */
  914. onBeforeCameraRenderObservable: Observable<Camera>;
  915. private _onBeforeCameraRenderObserver;
  916. /** Sets a function to be executed before rendering a camera*/
  917. beforeCameraRender: () => void;
  918. /**
  919. * An event triggered after rendering a camera
  920. */
  921. onAfterCameraRenderObservable: Observable<Camera>;
  922. private _onAfterCameraRenderObserver;
  923. /** Sets a function to be executed after rendering a camera*/
  924. afterCameraRender: () => void;
  925. /**
  926. * An event triggered when active meshes evaluation is about to start
  927. */
  928. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  929. /**
  930. * An event triggered when active meshes evaluation is done
  931. */
  932. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  933. /**
  934. * An event triggered when particles rendering is about to start
  935. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  936. */
  937. onBeforeParticlesRenderingObservable: Observable<Scene>;
  938. /**
  939. * An event triggered when particles rendering is done
  940. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  941. */
  942. onAfterParticlesRenderingObservable: Observable<Scene>;
  943. /**
  944. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  945. */
  946. onDataLoadedObservable: Observable<Scene>;
  947. /**
  948. * An event triggered when a camera is created
  949. */
  950. onNewCameraAddedObservable: Observable<Camera>;
  951. /**
  952. * An event triggered when a camera is removed
  953. */
  954. onCameraRemovedObservable: Observable<Camera>;
  955. /**
  956. * An event triggered when a light is created
  957. */
  958. onNewLightAddedObservable: Observable<Light>;
  959. /**
  960. * An event triggered when a light is removed
  961. */
  962. onLightRemovedObservable: Observable<Light>;
  963. /**
  964. * An event triggered when a geometry is created
  965. */
  966. onNewGeometryAddedObservable: Observable<Geometry>;
  967. /**
  968. * An event triggered when a geometry is removed
  969. */
  970. onGeometryRemovedObservable: Observable<Geometry>;
  971. /**
  972. * An event triggered when a transform node is created
  973. */
  974. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  975. /**
  976. * An event triggered when a transform node is removed
  977. */
  978. onTransformNodeRemovedObservable: Observable<TransformNode>;
  979. /**
  980. * An event triggered when a mesh is created
  981. */
  982. onNewMeshAddedObservable: Observable<AbstractMesh>;
  983. /**
  984. * An event triggered when a mesh is removed
  985. */
  986. onMeshRemovedObservable: Observable<AbstractMesh>;
  987. /**
  988. * An event triggered when a material is created
  989. */
  990. onNewMaterialAddedObservable: Observable<Material>;
  991. /**
  992. * An event triggered when a material is removed
  993. */
  994. onMaterialRemovedObservable: Observable<Material>;
  995. /**
  996. * An event triggered when a texture is created
  997. */
  998. onNewTextureAddedObservable: Observable<BaseTexture>;
  999. /**
  1000. * An event triggered when a texture is removed
  1001. */
  1002. onTextureRemovedObservable: Observable<BaseTexture>;
  1003. /**
  1004. * An event triggered when render targets are about to be rendered
  1005. * Can happen multiple times per frame.
  1006. */
  1007. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  1008. /**
  1009. * An event triggered when render targets were rendered.
  1010. * Can happen multiple times per frame.
  1011. */
  1012. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  1013. /**
  1014. * An event triggered before calculating deterministic simulation step
  1015. */
  1016. onBeforeStepObservable: Observable<Scene>;
  1017. /**
  1018. * An event triggered after calculating deterministic simulation step
  1019. */
  1020. onAfterStepObservable: Observable<Scene>;
  1021. /**
  1022. * An event triggered when the activeCamera property is updated
  1023. */
  1024. onActiveCameraChanged: Observable<Scene>;
  1025. /**
  1026. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  1027. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1028. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  1029. */
  1030. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1031. /**
  1032. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  1033. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1034. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  1035. */
  1036. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1037. /**
  1038. * This Observable will when a mesh has been imported into the scene.
  1039. */
  1040. onMeshImportedObservable: Observable<AbstractMesh>;
  1041. private _registeredForLateAnimationBindings;
  1042. /**
  1043. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  1044. */
  1045. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  1046. /**
  1047. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  1048. */
  1049. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  1050. /**
  1051. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  1052. */
  1053. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  1054. private _onPointerMove;
  1055. private _onPointerDown;
  1056. private _onPointerUp;
  1057. /** Callback called when a pointer move is detected */
  1058. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1059. /** Callback called when a pointer down is detected */
  1060. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1061. /** Callback called when a pointer up is detected */
  1062. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  1063. /** Callback called when a pointer pick is detected */
  1064. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  1065. /**
  1066. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  1067. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  1068. */
  1069. onPrePointerObservable: Observable<PointerInfoPre>;
  1070. /**
  1071. * Observable event triggered each time an input event is received from the rendering canvas
  1072. */
  1073. onPointerObservable: Observable<PointerInfo>;
  1074. /**
  1075. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  1076. */
  1077. readonly unTranslatedPointer: Vector2;
  1078. /** The distance in pixel that you have to move to prevent some events */
  1079. static DragMovementThreshold: number;
  1080. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  1081. static LongPressDelay: number;
  1082. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  1083. static DoubleClickDelay: number;
  1084. /** If you need to check double click without raising a single click at first click, enable this flag */
  1085. static ExclusiveDoubleClickMode: boolean;
  1086. private _initClickEvent;
  1087. private _initActionManager;
  1088. private _delayedSimpleClick;
  1089. private _delayedSimpleClickTimeout;
  1090. private _previousDelayedSimpleClickTimeout;
  1091. private _meshPickProceed;
  1092. private _previousButtonPressed;
  1093. private _currentPickResult;
  1094. private _previousPickResult;
  1095. private _totalPointersPressed;
  1096. private _doubleClickOccured;
  1097. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1098. cameraToUseForPointers: Nullable<Camera>;
  1099. private _pointerX;
  1100. private _pointerY;
  1101. private _unTranslatedPointerX;
  1102. private _unTranslatedPointerY;
  1103. private _startingPointerPosition;
  1104. private _previousStartingPointerPosition;
  1105. private _startingPointerTime;
  1106. private _previousStartingPointerTime;
  1107. private _pointerCaptures;
  1108. private _timeAccumulator;
  1109. private _currentStepId;
  1110. private _currentInternalStep;
  1111. /** @hidden */
  1112. _mirroredCameraPosition: Nullable<Vector3>;
  1113. /**
  1114. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1115. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1116. */
  1117. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1118. /**
  1119. * Observable event triggered each time an keyboard event is received from the hosting window
  1120. */
  1121. onKeyboardObservable: Observable<KeyboardInfo>;
  1122. private _onKeyDown;
  1123. private _onKeyUp;
  1124. private _onCanvasFocusObserver;
  1125. private _onCanvasBlurObserver;
  1126. private _useRightHandedSystem;
  1127. /**
  1128. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1129. */
  1130. useRightHandedSystem: boolean;
  1131. /**
  1132. * Sets the step Id used by deterministic lock step
  1133. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1134. * @param newStepId defines the step Id
  1135. */
  1136. setStepId(newStepId: number): void;
  1137. /**
  1138. * Gets the step Id used by deterministic lock step
  1139. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1140. * @returns the step Id
  1141. */
  1142. getStepId(): number;
  1143. /**
  1144. * Gets the internal step used by deterministic lock step
  1145. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1146. * @returns the internal step
  1147. */
  1148. getInternalStep(): number;
  1149. private _fogEnabled;
  1150. /**
  1151. * Gets or sets a boolean indicating if fog is enabled on this scene
  1152. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1153. * (Default is true)
  1154. */
  1155. fogEnabled: boolean;
  1156. private _fogMode;
  1157. /**
  1158. * Gets or sets the fog mode to use
  1159. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1160. * | mode | value |
  1161. * | --- | --- |
  1162. * | FOGMODE_NONE | 0 |
  1163. * | FOGMODE_EXP | 1 |
  1164. * | FOGMODE_EXP2 | 2 |
  1165. * | FOGMODE_LINEAR | 3 |
  1166. */
  1167. fogMode: number;
  1168. /**
  1169. * Gets or sets the fog color to use
  1170. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1171. * (Default is Color3(0.2, 0.2, 0.3))
  1172. */
  1173. fogColor: Color3;
  1174. /**
  1175. * Gets or sets the fog density to use
  1176. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1177. * (Default is 0.1)
  1178. */
  1179. fogDensity: number;
  1180. /**
  1181. * Gets or sets the fog start distance to use
  1182. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1183. * (Default is 0)
  1184. */
  1185. fogStart: number;
  1186. /**
  1187. * Gets or sets the fog end distance to use
  1188. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1189. * (Default is 1000)
  1190. */
  1191. fogEnd: number;
  1192. private _shadowsEnabled;
  1193. /**
  1194. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1195. */
  1196. shadowsEnabled: boolean;
  1197. private _lightsEnabled;
  1198. /**
  1199. * Gets or sets a boolean indicating if lights are enabled on this scene
  1200. */
  1201. lightsEnabled: boolean;
  1202. /** All of the active cameras added to this scene. */
  1203. activeCameras: Camera[];
  1204. private _activeCamera;
  1205. /** Gets or sets the current active camera */
  1206. activeCamera: Nullable<Camera>;
  1207. private _defaultMaterial;
  1208. /** The default material used on meshes when no material is affected */
  1209. /** The default material used on meshes when no material is affected */
  1210. defaultMaterial: Material;
  1211. private _texturesEnabled;
  1212. /**
  1213. * Gets or sets a boolean indicating if textures are enabled on this scene
  1214. */
  1215. texturesEnabled: boolean;
  1216. /**
  1217. * Gets or sets a boolean indicating if particles are enabled on this scene
  1218. */
  1219. particlesEnabled: boolean;
  1220. /**
  1221. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1222. */
  1223. spritesEnabled: boolean;
  1224. private _skeletonsEnabled;
  1225. /**
  1226. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1227. */
  1228. skeletonsEnabled: boolean;
  1229. /**
  1230. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1231. */
  1232. lensFlaresEnabled: boolean;
  1233. /**
  1234. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1235. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1236. */
  1237. collisionsEnabled: boolean;
  1238. private _workerCollisions;
  1239. /** @hidden */
  1240. collisionCoordinator: ICollisionCoordinator;
  1241. /**
  1242. * Defines the gravity applied to this scene (used only for collisions)
  1243. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1244. */
  1245. gravity: Vector3;
  1246. /**
  1247. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1248. */
  1249. postProcessesEnabled: boolean;
  1250. /**
  1251. * The list of postprocesses added to the scene
  1252. */
  1253. postProcesses: PostProcess[];
  1254. /**
  1255. * Gets the current postprocess manager
  1256. */
  1257. postProcessManager: PostProcessManager;
  1258. /**
  1259. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1260. */
  1261. renderTargetsEnabled: boolean;
  1262. /**
  1263. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1264. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1265. */
  1266. dumpNextRenderTargets: boolean;
  1267. /**
  1268. * The list of user defined render targets added to the scene
  1269. */
  1270. customRenderTargets: RenderTargetTexture[];
  1271. /**
  1272. * Defines if texture loading must be delayed
  1273. * If true, textures will only be loaded when they need to be rendered
  1274. */
  1275. useDelayedTextureLoading: boolean;
  1276. /**
  1277. * Gets the list of meshes imported to the scene through SceneLoader
  1278. */
  1279. importedMeshesFiles: String[];
  1280. /**
  1281. * Gets or sets a boolean indicating if probes are enabled on this scene
  1282. */
  1283. probesEnabled: boolean;
  1284. /**
  1285. * Gets or sets the current offline provider to use to store scene data
  1286. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1287. */
  1288. offlineProvider: IOfflineProvider;
  1289. /**
  1290. * Gets or sets the action manager associated with the scene
  1291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1292. */
  1293. actionManager: ActionManager;
  1294. private _meshesForIntersections;
  1295. /**
  1296. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1297. */
  1298. proceduralTexturesEnabled: boolean;
  1299. private _engine;
  1300. private _totalVertices;
  1301. /** @hidden */
  1302. _activeIndices: PerfCounter;
  1303. /** @hidden */
  1304. _activeParticles: PerfCounter;
  1305. /** @hidden */
  1306. _activeBones: PerfCounter;
  1307. private _animationRatio;
  1308. private _animationTimeLast;
  1309. private _animationTime;
  1310. /**
  1311. * Gets or sets a general scale for animation speed
  1312. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1313. */
  1314. animationTimeScale: number;
  1315. /** @hidden */
  1316. _cachedMaterial: Nullable<Material>;
  1317. /** @hidden */
  1318. _cachedEffect: Nullable<Effect>;
  1319. /** @hidden */
  1320. _cachedVisibility: Nullable<number>;
  1321. private _renderId;
  1322. private _frameId;
  1323. private _executeWhenReadyTimeoutId;
  1324. private _intermediateRendering;
  1325. private _viewUpdateFlag;
  1326. private _projectionUpdateFlag;
  1327. private _alternateViewUpdateFlag;
  1328. private _alternateProjectionUpdateFlag;
  1329. /** @hidden */
  1330. _toBeDisposed: Nullable<IDisposable>[];
  1331. private _activeRequests;
  1332. private _pendingData;
  1333. private _isDisposed;
  1334. /**
  1335. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1336. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1337. */
  1338. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1339. private _activeMeshes;
  1340. private _processedMaterials;
  1341. private _renderTargets;
  1342. /** @hidden */
  1343. _activeParticleSystems: SmartArray<IParticleSystem>;
  1344. private _activeSkeletons;
  1345. private _softwareSkinnedMeshes;
  1346. private _renderingManager;
  1347. /** @hidden */
  1348. _activeAnimatables: Animatable[];
  1349. private _transformMatrix;
  1350. private _sceneUbo;
  1351. private _alternateSceneUbo;
  1352. private _pickWithRayInverseMatrix;
  1353. private _viewMatrix;
  1354. private _projectionMatrix;
  1355. private _alternateViewMatrix;
  1356. private _alternateProjectionMatrix;
  1357. private _alternateTransformMatrix;
  1358. private _useAlternateCameraConfiguration;
  1359. private _alternateRendering;
  1360. private _wheelEventName;
  1361. /** @hidden */
  1362. _forcedViewPosition: Nullable<Vector3>;
  1363. /** @hidden */
  1364. readonly _isAlternateRenderingEnabled: boolean;
  1365. private _frustumPlanes;
  1366. /**
  1367. * Gets the list of frustum planes (built from the active camera)
  1368. */
  1369. readonly frustumPlanes: Plane[];
  1370. /**
  1371. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1372. * This is useful if there are more lights that the maximum simulteanous authorized
  1373. */
  1374. requireLightSorting: boolean;
  1375. /** @hidden */
  1376. readonly useMaterialMeshMap: boolean;
  1377. /** @hidden */
  1378. readonly useClonedMeshhMap: boolean;
  1379. private _pointerOverMesh;
  1380. private _pickedDownMesh;
  1381. private _pickedUpMesh;
  1382. private _externalData;
  1383. private _uid;
  1384. /**
  1385. * @hidden
  1386. * Backing store of defined scene components.
  1387. */
  1388. _components: ISceneComponent[];
  1389. /**
  1390. * @hidden
  1391. * Backing store of defined scene components.
  1392. */
  1393. _serializableComponents: ISceneSerializableComponent[];
  1394. /**
  1395. * List of components to register on the next registration step.
  1396. */
  1397. private _transientComponents;
  1398. /**
  1399. * Registers the transient components if needed.
  1400. */
  1401. private _registerTransientComponents;
  1402. /**
  1403. * @hidden
  1404. * Add a component to the scene.
  1405. * Note that the ccomponent could be registered on th next frame if this is called after
  1406. * the register component stage.
  1407. * @param component Defines the component to add to the scene
  1408. */
  1409. _addComponent(component: ISceneComponent): void;
  1410. /**
  1411. * @hidden
  1412. * Gets a component from the scene.
  1413. * @param name defines the name of the component to retrieve
  1414. * @returns the component or null if not present
  1415. */
  1416. _getComponent(name: string): Nullable<ISceneComponent>;
  1417. /**
  1418. * @hidden
  1419. * Defines the actions happening before camera updates.
  1420. */
  1421. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1422. /**
  1423. * @hidden
  1424. * Defines the actions happening before clear the canvas.
  1425. */
  1426. _beforeClearStage: Stage<SimpleStageAction>;
  1427. /**
  1428. * @hidden
  1429. * Defines the actions when collecting render targets for the frame.
  1430. */
  1431. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1432. /**
  1433. * @hidden
  1434. * Defines the actions happening for one camera in the frame.
  1435. */
  1436. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1437. /**
  1438. * @hidden
  1439. * Defines the actions happening during the per mesh ready checks.
  1440. */
  1441. _isReadyForMeshStage: Stage<MeshStageAction>;
  1442. /**
  1443. * @hidden
  1444. * Defines the actions happening before evaluate active mesh checks.
  1445. */
  1446. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1447. /**
  1448. * @hidden
  1449. * Defines the actions happening during the evaluate sub mesh checks.
  1450. */
  1451. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1452. /**
  1453. * @hidden
  1454. * Defines the actions happening during the active mesh stage.
  1455. */
  1456. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1457. /**
  1458. * @hidden
  1459. * Defines the actions happening during the per camera render target step.
  1460. */
  1461. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1462. /**
  1463. * @hidden
  1464. * Defines the actions happening just before the active camera is drawing.
  1465. */
  1466. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1467. /**
  1468. * @hidden
  1469. * Defines the actions happening just before a render target is drawing.
  1470. */
  1471. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  1472. /**
  1473. * @hidden
  1474. * Defines the actions happening just before a rendering group is drawing.
  1475. */
  1476. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1477. /**
  1478. * @hidden
  1479. * Defines the actions happening just before a mesh is drawing.
  1480. */
  1481. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1482. /**
  1483. * @hidden
  1484. * Defines the actions happening just after a mesh has been drawn.
  1485. */
  1486. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1487. /**
  1488. * @hidden
  1489. * Defines the actions happening just after a rendering group has been drawn.
  1490. */
  1491. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1492. /**
  1493. * @hidden
  1494. * Defines the actions happening just after the active camera has been drawn.
  1495. */
  1496. _afterCameraDrawStage: Stage<CameraStageAction>;
  1497. /**
  1498. * @hidden
  1499. * Defines the actions happening just after a render target has been drawn.
  1500. */
  1501. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  1502. /**
  1503. * @hidden
  1504. * Defines the actions happening just after rendering all cameras and computing intersections.
  1505. */
  1506. _afterRenderStage: Stage<SimpleStageAction>;
  1507. /**
  1508. * @hidden
  1509. * Defines the actions happening when a pointer move event happens.
  1510. */
  1511. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1512. /**
  1513. * @hidden
  1514. * Defines the actions happening when a pointer down event happens.
  1515. */
  1516. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1517. /**
  1518. * @hidden
  1519. * Defines the actions happening when a pointer up event happens.
  1520. */
  1521. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1522. /**
  1523. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  1524. */
  1525. private geometriesById;
  1526. /**
  1527. * Creates a new Scene
  1528. * @param engine defines the engine to use to render this scene
  1529. */
  1530. constructor(engine: Engine, options?: SceneOptions);
  1531. private _defaultMeshCandidates;
  1532. /**
  1533. * @hidden
  1534. */
  1535. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1536. private _defaultSubMeshCandidates;
  1537. /**
  1538. * @hidden
  1539. */
  1540. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1541. /**
  1542. * Sets the default candidate providers for the scene.
  1543. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1544. * and getCollidingSubMeshCandidates to their default function
  1545. */
  1546. setDefaultCandidateProviders(): void;
  1547. /**
  1548. * Gets a boolean indicating if collisions are processed on a web worker
  1549. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1550. */
  1551. workerCollisions: boolean;
  1552. /**
  1553. * Gets the mesh that is currently under the pointer
  1554. */
  1555. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1556. /**
  1557. * Gets the current on-screen X position of the pointer
  1558. */
  1559. readonly pointerX: number;
  1560. /**
  1561. * Gets the current on-screen Y position of the pointer
  1562. */
  1563. readonly pointerY: number;
  1564. /**
  1565. * Gets the cached material (ie. the latest rendered one)
  1566. * @returns the cached material
  1567. */
  1568. getCachedMaterial(): Nullable<Material>;
  1569. /**
  1570. * Gets the cached effect (ie. the latest rendered one)
  1571. * @returns the cached effect
  1572. */
  1573. getCachedEffect(): Nullable<Effect>;
  1574. /**
  1575. * Gets the cached visibility state (ie. the latest rendered one)
  1576. * @returns the cached visibility state
  1577. */
  1578. getCachedVisibility(): Nullable<number>;
  1579. /**
  1580. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1581. * @param material defines the current material
  1582. * @param effect defines the current effect
  1583. * @param visibility defines the current visibility state
  1584. * @returns true if one parameter is not cached
  1585. */
  1586. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1587. /**
  1588. * Gets the engine associated with the scene
  1589. * @returns an Engine
  1590. */
  1591. getEngine(): Engine;
  1592. /**
  1593. * Gets the total number of vertices rendered per frame
  1594. * @returns the total number of vertices rendered per frame
  1595. */
  1596. getTotalVertices(): number;
  1597. /**
  1598. * Gets the performance counter for total vertices
  1599. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1600. */
  1601. readonly totalVerticesPerfCounter: PerfCounter;
  1602. /**
  1603. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1604. * @returns the total number of active indices rendered per frame
  1605. */
  1606. getActiveIndices(): number;
  1607. /**
  1608. * Gets the performance counter for active indices
  1609. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1610. */
  1611. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1612. /**
  1613. * Gets the total number of active particles rendered per frame
  1614. * @returns the total number of active particles rendered per frame
  1615. */
  1616. getActiveParticles(): number;
  1617. /**
  1618. * Gets the performance counter for active particles
  1619. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1620. */
  1621. readonly activeParticlesPerfCounter: PerfCounter;
  1622. /**
  1623. * Gets the total number of active bones rendered per frame
  1624. * @returns the total number of active bones rendered per frame
  1625. */
  1626. getActiveBones(): number;
  1627. /**
  1628. * Gets the performance counter for active bones
  1629. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1630. */
  1631. readonly activeBonesPerfCounter: PerfCounter;
  1632. /**
  1633. * Gets the array of active meshes
  1634. * @returns an array of AbstractMesh
  1635. */
  1636. getActiveMeshes(): SmartArray<AbstractMesh>;
  1637. /**
  1638. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1639. * @returns a number
  1640. */
  1641. getAnimationRatio(): number;
  1642. /**
  1643. * Gets an unique Id for the current render phase
  1644. * @returns a number
  1645. */
  1646. getRenderId(): number;
  1647. /**
  1648. * Gets an unique Id for the current frame
  1649. * @returns a number
  1650. */
  1651. getFrameId(): number;
  1652. /** Call this function if you want to manually increment the render Id*/
  1653. incrementRenderId(): void;
  1654. private _updatePointerPosition;
  1655. private _createUbo;
  1656. private _createAlternateUbo;
  1657. private _setRayOnPointerInfo;
  1658. /**
  1659. * Use this method to simulate a pointer move on a mesh
  1660. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1661. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1662. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1663. * @returns the current scene
  1664. */
  1665. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1666. private _processPointerMove;
  1667. private _checkPrePointerObservable;
  1668. /**
  1669. * Use this method to simulate a pointer down on a mesh
  1670. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1671. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1672. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1673. * @returns the current scene
  1674. */
  1675. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1676. private _processPointerDown;
  1677. /**
  1678. * Use this method to simulate a pointer up on a mesh
  1679. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1680. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1681. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1682. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  1683. * @returns the current scene
  1684. */
  1685. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  1686. private _processPointerUp;
  1687. /**
  1688. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1689. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1690. * @returns true if the pointer was captured
  1691. */
  1692. isPointerCaptured(pointerId?: number): boolean;
  1693. /** @hidden */
  1694. _isPointerSwiping(): boolean;
  1695. /**
  1696. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1697. * @param attachUp defines if you want to attach events to pointerup
  1698. * @param attachDown defines if you want to attach events to pointerdown
  1699. * @param attachMove defines if you want to attach events to pointermove
  1700. */
  1701. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1702. /** Detaches all event handlers*/
  1703. detachControl(): void;
  1704. /**
  1705. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1706. * Delay loaded resources are not taking in account
  1707. * @return true if all required resources are ready
  1708. */
  1709. isReady(): boolean;
  1710. /** Resets all cached information relative to material (including effect and visibility) */
  1711. resetCachedMaterial(): void;
  1712. /**
  1713. * Registers a function to be called before every frame render
  1714. * @param func defines the function to register
  1715. */
  1716. registerBeforeRender(func: () => void): void;
  1717. /**
  1718. * Unregisters a function called before every frame render
  1719. * @param func defines the function to unregister
  1720. */
  1721. unregisterBeforeRender(func: () => void): void;
  1722. /**
  1723. * Registers a function to be called after every frame render
  1724. * @param func defines the function to register
  1725. */
  1726. registerAfterRender(func: () => void): void;
  1727. /**
  1728. * Unregisters a function called after every frame render
  1729. * @param func defines the function to unregister
  1730. */
  1731. unregisterAfterRender(func: () => void): void;
  1732. private _executeOnceBeforeRender;
  1733. /**
  1734. * The provided function will run before render once and will be disposed afterwards.
  1735. * A timeout delay can be provided so that the function will be executed in N ms.
  1736. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1737. * @param func The function to be executed.
  1738. * @param timeout optional delay in ms
  1739. */
  1740. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1741. /** @hidden */
  1742. _addPendingData(data: any): void;
  1743. /** @hidden */
  1744. _removePendingData(data: any): void;
  1745. /**
  1746. * Returns the number of items waiting to be loaded
  1747. * @returns the number of items waiting to be loaded
  1748. */
  1749. getWaitingItemsCount(): number;
  1750. /**
  1751. * Returns a boolean indicating if the scene is still loading data
  1752. */
  1753. readonly isLoading: boolean;
  1754. /**
  1755. * Registers a function to be executed when the scene is ready
  1756. * @param {Function} func - the function to be executed
  1757. */
  1758. executeWhenReady(func: () => void): void;
  1759. /**
  1760. * Returns a promise that resolves when the scene is ready
  1761. * @returns A promise that resolves when the scene is ready
  1762. */
  1763. whenReadyAsync(): Promise<void>;
  1764. /** @hidden */
  1765. _checkIsReady(): void;
  1766. /**
  1767. * Will start the animation sequence of a given target
  1768. * @param target defines the target
  1769. * @param from defines from which frame should animation start
  1770. * @param to defines until which frame should animation run.
  1771. * @param weight defines the weight to apply to the animation (1.0 by default)
  1772. * @param loop defines if the animation loops
  1773. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1774. * @param onAnimationEnd defines the function to be executed when the animation ends
  1775. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1776. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1777. * @param onAnimationLoop defines the callback to call when an animation loops
  1778. * @returns the animatable object created for this animation
  1779. */
  1780. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  1781. /**
  1782. * Will start the animation sequence of a given target
  1783. * @param target defines the target
  1784. * @param from defines from which frame should animation start
  1785. * @param to defines until which frame should animation run.
  1786. * @param loop defines if the animation loops
  1787. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1788. * @param onAnimationEnd defines the function to be executed when the animation ends
  1789. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1790. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1791. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  1792. * @param onAnimationLoop defines the callback to call when an animation loops
  1793. * @returns the animatable object created for this animation
  1794. */
  1795. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  1796. /**
  1797. * Will start the animation sequence of a given target and its hierarchy
  1798. * @param target defines the target
  1799. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  1800. * @param from defines from which frame should animation start
  1801. * @param to defines until which frame should animation run.
  1802. * @param loop defines if the animation loops
  1803. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1804. * @param onAnimationEnd defines the function to be executed when the animation ends
  1805. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1806. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1807. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1808. * @param onAnimationLoop defines the callback to call when an animation loops
  1809. * @returns the list of created animatables
  1810. */
  1811. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  1812. /**
  1813. * Begin a new animation on a given node
  1814. * @param target defines the target where the animation will take place
  1815. * @param animations defines the list of animations to start
  1816. * @param from defines the initial value
  1817. * @param to defines the final value
  1818. * @param loop defines if you want animation to loop (off by default)
  1819. * @param speedRatio defines the speed ratio to apply to all animations
  1820. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1821. * @param onAnimationLoop defines the callback to call when an animation loops
  1822. * @returns the list of created animatables
  1823. */
  1824. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  1825. /**
  1826. * Begin a new animation on a given node and its hierarchy
  1827. * @param target defines the root node where the animation will take place
  1828. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  1829. * @param animations defines the list of animations to start
  1830. * @param from defines the initial value
  1831. * @param to defines the final value
  1832. * @param loop defines if you want animation to loop (off by default)
  1833. * @param speedRatio defines the speed ratio to apply to all animations
  1834. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1835. * @param onAnimationLoop defines the callback to call when an animation loops
  1836. * @returns the list of animatables created for all nodes
  1837. */
  1838. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  1839. /**
  1840. * Gets the animatable associated with a specific target
  1841. * @param target defines the target of the animatable
  1842. * @returns the required animatable if found
  1843. */
  1844. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1845. /**
  1846. * Gets all animatables associated with a given target
  1847. * @param target defines the target to look animatables for
  1848. * @returns an array of Animatables
  1849. */
  1850. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1851. /**
  1852. * Gets all animatable attached to the scene
  1853. */
  1854. readonly animatables: Animatable[];
  1855. /**
  1856. * Will stop the animation of the given target
  1857. * @param target - the target
  1858. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1859. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  1860. */
  1861. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1862. /**
  1863. * Stops and removes all animations that have been applied to the scene
  1864. */
  1865. stopAllAnimations(): void;
  1866. private _animate;
  1867. /** @hidden */
  1868. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1869. private _processLateAnimationBindingsForMatrices;
  1870. private _processLateAnimationBindingsForQuaternions;
  1871. private _processLateAnimationBindings;
  1872. /** @hidden */
  1873. _switchToAlternateCameraConfiguration(active: boolean): void;
  1874. /**
  1875. * Gets the current view matrix
  1876. * @returns a Matrix
  1877. */
  1878. getViewMatrix(): Matrix;
  1879. /**
  1880. * Gets the current projection matrix
  1881. * @returns a Matrix
  1882. */
  1883. getProjectionMatrix(): Matrix;
  1884. /**
  1885. * Gets the current transform matrix
  1886. * @returns a Matrix made of View * Projection
  1887. */
  1888. getTransformMatrix(): Matrix;
  1889. /**
  1890. * Sets the current transform matrix
  1891. * @param view defines the View matrix to use
  1892. * @param projection defines the Projection matrix to use
  1893. */
  1894. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1895. /** @hidden */
  1896. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1897. /**
  1898. * Gets the uniform buffer used to store scene data
  1899. * @returns a UniformBuffer
  1900. */
  1901. getSceneUniformBuffer(): UniformBuffer;
  1902. /**
  1903. * Gets an unique (relatively to the current scene) Id
  1904. * @returns an unique number for the scene
  1905. */
  1906. getUniqueId(): number;
  1907. /**
  1908. * Add a mesh to the list of scene's meshes
  1909. * @param newMesh defines the mesh to add
  1910. * @param recursive if all child meshes should also be added to the scene
  1911. */
  1912. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1913. /**
  1914. * Remove a mesh for the list of scene's meshes
  1915. * @param toRemove defines the mesh to remove
  1916. * @param recursive if all child meshes should also be removed from the scene
  1917. * @returns the index where the mesh was in the mesh list
  1918. */
  1919. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1920. /**
  1921. * Add a transform node to the list of scene's transform nodes
  1922. * @param newTransformNode defines the transform node to add
  1923. */
  1924. addTransformNode(newTransformNode: TransformNode): void;
  1925. /**
  1926. * Remove a transform node for the list of scene's transform nodes
  1927. * @param toRemove defines the transform node to remove
  1928. * @returns the index where the transform node was in the transform node list
  1929. */
  1930. removeTransformNode(toRemove: TransformNode): number;
  1931. /**
  1932. * Remove a skeleton for the list of scene's skeletons
  1933. * @param toRemove defines the skeleton to remove
  1934. * @returns the index where the skeleton was in the skeleton list
  1935. */
  1936. removeSkeleton(toRemove: Skeleton): number;
  1937. /**
  1938. * Remove a morph target for the list of scene's morph targets
  1939. * @param toRemove defines the morph target to remove
  1940. * @returns the index where the morph target was in the morph target list
  1941. */
  1942. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1943. /**
  1944. * Remove a light for the list of scene's lights
  1945. * @param toRemove defines the light to remove
  1946. * @returns the index where the light was in the light list
  1947. */
  1948. removeLight(toRemove: Light): number;
  1949. /**
  1950. * Remove a camera for the list of scene's cameras
  1951. * @param toRemove defines the camera to remove
  1952. * @returns the index where the camera was in the camera list
  1953. */
  1954. removeCamera(toRemove: Camera): number;
  1955. /**
  1956. * Remove a particle system for the list of scene's particle systems
  1957. * @param toRemove defines the particle system to remove
  1958. * @returns the index where the particle system was in the particle system list
  1959. */
  1960. removeParticleSystem(toRemove: IParticleSystem): number;
  1961. /**
  1962. * Remove a animation for the list of scene's animations
  1963. * @param toRemove defines the animation to remove
  1964. * @returns the index where the animation was in the animation list
  1965. */
  1966. removeAnimation(toRemove: Animation): number;
  1967. /**
  1968. * Removes the given animation group from this scene.
  1969. * @param toRemove The animation group to remove
  1970. * @returns The index of the removed animation group
  1971. */
  1972. removeAnimationGroup(toRemove: AnimationGroup): number;
  1973. /**
  1974. * Removes the given multi-material from this scene.
  1975. * @param toRemove The multi-material to remove
  1976. * @returns The index of the removed multi-material
  1977. */
  1978. removeMultiMaterial(toRemove: MultiMaterial): number;
  1979. /**
  1980. * Removes the given material from this scene.
  1981. * @param toRemove The material to remove
  1982. * @returns The index of the removed material
  1983. */
  1984. removeMaterial(toRemove: Material): number;
  1985. /**
  1986. * Removes the given action manager from this scene.
  1987. * @param toRemove The action manager to remove
  1988. * @returns The index of the removed action manager
  1989. */
  1990. removeActionManager(toRemove: ActionManager): number;
  1991. /**
  1992. * Removes the given texture from this scene.
  1993. * @param toRemove The texture to remove
  1994. * @returns The index of the removed texture
  1995. */
  1996. removeTexture(toRemove: BaseTexture): number;
  1997. /**
  1998. * Adds the given light to this scene
  1999. * @param newLight The light to add
  2000. */
  2001. addLight(newLight: Light): void;
  2002. /**
  2003. * Sorts the list list based on light priorities
  2004. */
  2005. sortLightsByPriority(): void;
  2006. /**
  2007. * Adds the given camera to this scene
  2008. * @param newCamera The camera to add
  2009. */
  2010. addCamera(newCamera: Camera): void;
  2011. /**
  2012. * Adds the given skeleton to this scene
  2013. * @param newSkeleton The skeleton to add
  2014. */
  2015. addSkeleton(newSkeleton: Skeleton): void;
  2016. /**
  2017. * Adds the given particle system to this scene
  2018. * @param newParticleSystem The particle system to add
  2019. */
  2020. addParticleSystem(newParticleSystem: IParticleSystem): void;
  2021. /**
  2022. * Adds the given animation to this scene
  2023. * @param newAnimation The animation to add
  2024. */
  2025. addAnimation(newAnimation: Animation): void;
  2026. /**
  2027. * Adds the given animation group to this scene.
  2028. * @param newAnimationGroup The animation group to add
  2029. */
  2030. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  2031. /**
  2032. * Adds the given multi-material to this scene
  2033. * @param newMultiMaterial The multi-material to add
  2034. */
  2035. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  2036. /**
  2037. * Adds the given material to this scene
  2038. * @param newMaterial The material to add
  2039. */
  2040. addMaterial(newMaterial: Material): void;
  2041. /**
  2042. * Adds the given morph target to this scene
  2043. * @param newMorphTargetManager The morph target to add
  2044. */
  2045. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  2046. /**
  2047. * Adds the given geometry to this scene
  2048. * @param newGeometry The geometry to add
  2049. */
  2050. addGeometry(newGeometry: Geometry): void;
  2051. /**
  2052. * Adds the given action manager to this scene
  2053. * @param newActionManager The action manager to add
  2054. */
  2055. addActionManager(newActionManager: ActionManager): void;
  2056. /**
  2057. * Adds the given texture to this scene.
  2058. * @param newTexture The texture to add
  2059. */
  2060. addTexture(newTexture: BaseTexture): void;
  2061. /**
  2062. * Switch active camera
  2063. * @param newCamera defines the new active camera
  2064. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  2065. */
  2066. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  2067. /**
  2068. * sets the active camera of the scene using its ID
  2069. * @param id defines the camera's ID
  2070. * @return the new active camera or null if none found.
  2071. */
  2072. setActiveCameraByID(id: string): Nullable<Camera>;
  2073. /**
  2074. * sets the active camera of the scene using its name
  2075. * @param name defines the camera's name
  2076. * @returns the new active camera or null if none found.
  2077. */
  2078. setActiveCameraByName(name: string): Nullable<Camera>;
  2079. /**
  2080. * get an animation group using its name
  2081. * @param name defines the material's name
  2082. * @return the animation group or null if none found.
  2083. */
  2084. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  2085. /**
  2086. * get a material using its id
  2087. * @param id defines the material's ID
  2088. * @return the material or null if none found.
  2089. */
  2090. getMaterialByID(id: string): Nullable<Material>;
  2091. /**
  2092. * Gets a material using its name
  2093. * @param name defines the material's name
  2094. * @return the material or null if none found.
  2095. */
  2096. getMaterialByName(name: string): Nullable<Material>;
  2097. /**
  2098. * Gets a camera using its id
  2099. * @param id defines the id to look for
  2100. * @returns the camera or null if not found
  2101. */
  2102. getCameraByID(id: string): Nullable<Camera>;
  2103. /**
  2104. * Gets a camera using its unique id
  2105. * @param uniqueId defines the unique id to look for
  2106. * @returns the camera or null if not found
  2107. */
  2108. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2109. /**
  2110. * Gets a camera using its name
  2111. * @param name defines the camera's name
  2112. * @return the camera or null if none found.
  2113. */
  2114. getCameraByName(name: string): Nullable<Camera>;
  2115. /**
  2116. * Gets a bone using its id
  2117. * @param id defines the bone's id
  2118. * @return the bone or null if not found
  2119. */
  2120. getBoneByID(id: string): Nullable<Bone>;
  2121. /**
  2122. * Gets a bone using its id
  2123. * @param name defines the bone's name
  2124. * @return the bone or null if not found
  2125. */
  2126. getBoneByName(name: string): Nullable<Bone>;
  2127. /**
  2128. * Gets a light node using its name
  2129. * @param name defines the the light's name
  2130. * @return the light or null if none found.
  2131. */
  2132. getLightByName(name: string): Nullable<Light>;
  2133. /**
  2134. * Gets a light node using its id
  2135. * @param id defines the light's id
  2136. * @return the light or null if none found.
  2137. */
  2138. getLightByID(id: string): Nullable<Light>;
  2139. /**
  2140. * Gets a light node using its scene-generated unique ID
  2141. * @param uniqueId defines the light's unique id
  2142. * @return the light or null if none found.
  2143. */
  2144. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2145. /**
  2146. * Gets a particle system by id
  2147. * @param id defines the particle system id
  2148. * @return the corresponding system or null if none found
  2149. */
  2150. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2151. /**
  2152. * Gets a geometry using its ID
  2153. * @param id defines the geometry's id
  2154. * @return the geometry or null if none found.
  2155. */
  2156. getGeometryByID(id: string): Nullable<Geometry>;
  2157. private _getGeometryByUniqueID;
  2158. /**
  2159. * Add a new geometry to this scene
  2160. * @param geometry defines the geometry to be added to the scene.
  2161. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2162. * @return a boolean defining if the geometry was added or not
  2163. */
  2164. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2165. /**
  2166. * Removes an existing geometry
  2167. * @param geometry defines the geometry to be removed from the scene
  2168. * @return a boolean defining if the geometry was removed or not
  2169. */
  2170. removeGeometry(geometry: Geometry): boolean;
  2171. /**
  2172. * Gets the list of geometries attached to the scene
  2173. * @returns an array of Geometry
  2174. */
  2175. getGeometries(): Geometry[];
  2176. /**
  2177. * Gets the first added mesh found of a given ID
  2178. * @param id defines the id to search for
  2179. * @return the mesh found or null if not found at all
  2180. */
  2181. getMeshByID(id: string): Nullable<AbstractMesh>;
  2182. /**
  2183. * Gets a list of meshes using their id
  2184. * @param id defines the id to search for
  2185. * @returns a list of meshes
  2186. */
  2187. getMeshesByID(id: string): Array<AbstractMesh>;
  2188. /**
  2189. * Gets the first added transform node found of a given ID
  2190. * @param id defines the id to search for
  2191. * @return the found transform node or null if not found at all.
  2192. */
  2193. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2194. /**
  2195. * Gets a list of transform nodes using their id
  2196. * @param id defines the id to search for
  2197. * @returns a list of transform nodes
  2198. */
  2199. getTransformNodesByID(id: string): Array<TransformNode>;
  2200. /**
  2201. * Gets a mesh with its auto-generated unique id
  2202. * @param uniqueId defines the unique id to search for
  2203. * @return the found mesh or null if not found at all.
  2204. */
  2205. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2206. /**
  2207. * Gets a the last added mesh using a given id
  2208. * @param id defines the id to search for
  2209. * @return the found mesh or null if not found at all.
  2210. */
  2211. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2212. /**
  2213. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2214. * @param id defines the id to search for
  2215. * @return the found node or null if not found at all
  2216. */
  2217. getLastEntryByID(id: string): Nullable<Node>;
  2218. /**
  2219. * Gets a node (Mesh, Camera, Light) using a given id
  2220. * @param id defines the id to search for
  2221. * @return the found node or null if not found at all
  2222. */
  2223. getNodeByID(id: string): Nullable<Node>;
  2224. /**
  2225. * Gets a node (Mesh, Camera, Light) using a given name
  2226. * @param name defines the name to search for
  2227. * @return the found node or null if not found at all.
  2228. */
  2229. getNodeByName(name: string): Nullable<Node>;
  2230. /**
  2231. * Gets a mesh using a given name
  2232. * @param name defines the name to search for
  2233. * @return the found mesh or null if not found at all.
  2234. */
  2235. getMeshByName(name: string): Nullable<AbstractMesh>;
  2236. /**
  2237. * Gets a transform node using a given name
  2238. * @param name defines the name to search for
  2239. * @return the found transform node or null if not found at all.
  2240. */
  2241. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2242. /**
  2243. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2244. * @param id defines the id to search for
  2245. * @return the found skeleton or null if not found at all.
  2246. */
  2247. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2248. /**
  2249. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2250. * @param id defines the id to search for
  2251. * @return the found skeleton or null if not found at all.
  2252. */
  2253. getSkeletonById(id: string): Nullable<Skeleton>;
  2254. /**
  2255. * Gets a skeleton using a given name
  2256. * @param name defines the name to search for
  2257. * @return the found skeleton or null if not found at all.
  2258. */
  2259. getSkeletonByName(name: string): Nullable<Skeleton>;
  2260. /**
  2261. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2262. * @param id defines the id to search for
  2263. * @return the found morph target manager or null if not found at all.
  2264. */
  2265. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2266. /**
  2267. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  2268. * @param id defines the id to search for
  2269. * @return the found morph target or null if not found at all.
  2270. */
  2271. getMorphTargetById(id: string): Nullable<MorphTarget>;
  2272. /**
  2273. * Gets a boolean indicating if the given mesh is active
  2274. * @param mesh defines the mesh to look for
  2275. * @returns true if the mesh is in the active list
  2276. */
  2277. isActiveMesh(mesh: AbstractMesh): boolean;
  2278. /**
  2279. * Return a unique id as a string which can serve as an identifier for the scene
  2280. */
  2281. readonly uid: string;
  2282. /**
  2283. * Add an externaly attached data from its key.
  2284. * This method call will fail and return false, if such key already exists.
  2285. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2286. * @param key the unique key that identifies the data
  2287. * @param data the data object to associate to the key for this Engine instance
  2288. * @return true if no such key were already present and the data was added successfully, false otherwise
  2289. */
  2290. addExternalData<T>(key: string, data: T): boolean;
  2291. /**
  2292. * Get an externaly attached data from its key
  2293. * @param key the unique key that identifies the data
  2294. * @return the associated data, if present (can be null), or undefined if not present
  2295. */
  2296. getExternalData<T>(key: string): Nullable<T>;
  2297. /**
  2298. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2299. * @param key the unique key that identifies the data
  2300. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2301. * @return the associated data, can be null if the factory returned null.
  2302. */
  2303. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2304. /**
  2305. * Remove an externaly attached data from the Engine instance
  2306. * @param key the unique key that identifies the data
  2307. * @return true if the data was successfully removed, false if it doesn't exist
  2308. */
  2309. removeExternalData(key: string): boolean;
  2310. private _evaluateSubMesh;
  2311. /**
  2312. * Clear the processed materials smart array preventing retention point in material dispose.
  2313. */
  2314. freeProcessedMaterials(): void;
  2315. private _preventFreeActiveMeshesAndRenderingGroups;
  2316. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  2317. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  2318. * when disposing several meshes in a row or a hierarchy of meshes.
  2319. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  2320. */
  2321. blockfreeActiveMeshesAndRenderingGroups: boolean;
  2322. /**
  2323. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2324. */
  2325. freeActiveMeshes(): void;
  2326. /**
  2327. * Clear the info related to rendering groups preventing retention points during dispose.
  2328. */
  2329. freeRenderingGroups(): void;
  2330. /** @hidden */
  2331. _isInIntermediateRendering(): boolean;
  2332. /**
  2333. * Lambda returning the list of potentially active meshes.
  2334. */
  2335. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2336. /**
  2337. * Lambda returning the list of potentially active sub meshes.
  2338. */
  2339. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2340. /**
  2341. * Lambda returning the list of potentially intersecting sub meshes.
  2342. */
  2343. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2344. /**
  2345. * Lambda returning the list of potentially colliding sub meshes.
  2346. */
  2347. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2348. private _activeMeshesFrozen;
  2349. /**
  2350. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2351. * @returns the current scene
  2352. */
  2353. freezeActiveMeshes(): Scene;
  2354. /**
  2355. * Use this function to restart evaluating active meshes on every frame
  2356. * @returns the current scene
  2357. */
  2358. unfreezeActiveMeshes(): Scene;
  2359. private _evaluateActiveMeshes;
  2360. private _activeMesh;
  2361. /**
  2362. * Update the transform matrix to update from the current active camera
  2363. * @param force defines a boolean used to force the update even if cache is up to date
  2364. */
  2365. updateTransformMatrix(force?: boolean): void;
  2366. /**
  2367. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  2368. * @param alternateCamera defines the camera to use
  2369. */
  2370. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2371. /** @hidden */
  2372. _allowPostProcessClearColor: boolean;
  2373. private _renderForCamera;
  2374. private _processSubCameras;
  2375. private _checkIntersections;
  2376. /** @hidden */
  2377. _advancePhysicsEngineStep(step: number): void;
  2378. /**
  2379. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2380. */
  2381. getDeterministicFrameTime: () => number;
  2382. /**
  2383. * Render the scene
  2384. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2385. */
  2386. render(updateCameras?: boolean): void;
  2387. /**
  2388. * Freeze all materials
  2389. * A frozen material will not be updatable but should be faster to render
  2390. */
  2391. freezeMaterials(): void;
  2392. /**
  2393. * Unfreeze all materials
  2394. * A frozen material will not be updatable but should be faster to render
  2395. */
  2396. unfreezeMaterials(): void;
  2397. /**
  2398. * Releases all held ressources
  2399. */
  2400. dispose(): void;
  2401. /**
  2402. * Gets if the scene is already disposed
  2403. */
  2404. readonly isDisposed: boolean;
  2405. /**
  2406. * Call this function to reduce memory footprint of the scene.
  2407. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2408. */
  2409. clearCachedVertexData(): void;
  2410. /**
  2411. * This function will remove the local cached buffer data from texture.
  2412. * It will save memory but will prevent the texture from being rebuilt
  2413. */
  2414. cleanCachedTextureBuffer(): void;
  2415. /**
  2416. * Get the world extend vectors with an optional filter
  2417. *
  2418. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2419. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2420. */
  2421. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2422. min: Vector3;
  2423. max: Vector3;
  2424. };
  2425. /**
  2426. * Creates a ray that can be used to pick in the scene
  2427. * @param x defines the x coordinate of the origin (on-screen)
  2428. * @param y defines the y coordinate of the origin (on-screen)
  2429. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2430. * @param camera defines the camera to use for the picking
  2431. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2432. * @returns a Ray
  2433. */
  2434. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2435. /**
  2436. * Creates a ray that can be used to pick in the scene
  2437. * @param x defines the x coordinate of the origin (on-screen)
  2438. * @param y defines the y coordinate of the origin (on-screen)
  2439. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2440. * @param result defines the ray where to store the picking ray
  2441. * @param camera defines the camera to use for the picking
  2442. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2443. * @returns the current scene
  2444. */
  2445. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2446. /**
  2447. * Creates a ray that can be used to pick in the scene
  2448. * @param x defines the x coordinate of the origin (on-screen)
  2449. * @param y defines the y coordinate of the origin (on-screen)
  2450. * @param camera defines the camera to use for the picking
  2451. * @returns a Ray
  2452. */
  2453. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2454. /**
  2455. * Creates a ray that can be used to pick in the scene
  2456. * @param x defines the x coordinate of the origin (on-screen)
  2457. * @param y defines the y coordinate of the origin (on-screen)
  2458. * @param result defines the ray where to store the picking ray
  2459. * @param camera defines the camera to use for the picking
  2460. * @returns the current scene
  2461. */
  2462. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2463. private _internalPick;
  2464. private _internalMultiPick;
  2465. private _tempPickingRay;
  2466. /** Launch a ray to try to pick a mesh in the scene
  2467. * @param x position on screen
  2468. * @param y position on screen
  2469. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2470. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2471. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2472. * @returns a PickingInfo
  2473. */
  2474. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2475. private _cachedRayForTransform;
  2476. /** Use the given ray to pick a mesh in the scene
  2477. * @param ray The ray to use to pick meshes
  2478. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  2479. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2480. * @returns a PickingInfo
  2481. */
  2482. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2483. /**
  2484. * Launch a ray to try to pick a mesh in the scene
  2485. * @param x X position on screen
  2486. * @param y Y position on screen
  2487. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2488. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2489. * @returns an array of PickingInfo
  2490. */
  2491. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2492. /**
  2493. * Launch a ray to try to pick a mesh in the scene
  2494. * @param ray Ray to use
  2495. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2496. * @returns an array of PickingInfo
  2497. */
  2498. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2499. /**
  2500. * Force the value of meshUnderPointer
  2501. * @param mesh defines the mesh to use
  2502. */
  2503. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2504. /**
  2505. * Gets the mesh under the pointer
  2506. * @returns a Mesh or null if no mesh is under the pointer
  2507. */
  2508. getPointerOverMesh(): Nullable<AbstractMesh>;
  2509. /** @hidden */
  2510. _rebuildGeometries(): void;
  2511. /** @hidden */
  2512. _rebuildTextures(): void;
  2513. private _getByTags;
  2514. /**
  2515. * Get a list of meshes by tags
  2516. * @param tagsQuery defines the tags query to use
  2517. * @param forEach defines a predicate used to filter results
  2518. * @returns an array of Mesh
  2519. */
  2520. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2521. /**
  2522. * Get a list of cameras by tags
  2523. * @param tagsQuery defines the tags query to use
  2524. * @param forEach defines a predicate used to filter results
  2525. * @returns an array of Camera
  2526. */
  2527. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2528. /**
  2529. * Get a list of lights by tags
  2530. * @param tagsQuery defines the tags query to use
  2531. * @param forEach defines a predicate used to filter results
  2532. * @returns an array of Light
  2533. */
  2534. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2535. /**
  2536. * Get a list of materials by tags
  2537. * @param tagsQuery defines the tags query to use
  2538. * @param forEach defines a predicate used to filter results
  2539. * @returns an array of Material
  2540. */
  2541. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2542. /**
  2543. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2544. * This allowed control for front to back rendering or reversly depending of the special needs.
  2545. *
  2546. * @param renderingGroupId The rendering group id corresponding to its index
  2547. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2548. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2549. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2550. */
  2551. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  2552. /**
  2553. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2554. *
  2555. * @param renderingGroupId The rendering group id corresponding to its index
  2556. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2557. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2558. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2559. */
  2560. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2561. /**
  2562. * Gets the current auto clear configuration for one rendering group of the rendering
  2563. * manager.
  2564. * @param index the rendering group index to get the information for
  2565. * @returns The auto clear setup for the requested rendering group
  2566. */
  2567. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2568. private _blockMaterialDirtyMechanism;
  2569. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2570. blockMaterialDirtyMechanism: boolean;
  2571. /**
  2572. * Will flag all materials as dirty to trigger new shader compilation
  2573. * @param flag defines the flag used to specify which material part must be marked as dirty
  2574. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2575. */
  2576. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2577. /** @hidden */
  2578. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  2579. /** @hidden */
  2580. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2581. }
  2582. }
  2583. declare module BABYLON {
  2584. /**
  2585. * Groups all the scene component constants in one place to ease maintenance.
  2586. * @hidden
  2587. */
  2588. class SceneComponentConstants {
  2589. static readonly NAME_EFFECTLAYER: string;
  2590. static readonly NAME_LAYER: string;
  2591. static readonly NAME_LENSFLARESYSTEM: string;
  2592. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2593. static readonly NAME_PARTICLESYSTEM: string;
  2594. static readonly NAME_GAMEPAD: string;
  2595. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2596. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2597. static readonly NAME_DEPTHRENDERER: string;
  2598. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2599. static readonly NAME_SPRITE: string;
  2600. static readonly NAME_OUTLINERENDERER: string;
  2601. static readonly NAME_PROCEDURALTEXTURE: string;
  2602. static readonly NAME_SHADOWGENERATOR: string;
  2603. static readonly NAME_OCTREE: string;
  2604. static readonly NAME_PHYSICSENGINE: string;
  2605. static readonly NAME_AUDIO: string;
  2606. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2607. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2608. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2609. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2610. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2611. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2612. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2613. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  2614. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2615. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2616. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2617. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2618. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2619. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2620. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2621. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  2622. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2623. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2624. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2625. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2626. static readonly STEP_AFTERRENDER_AUDIO: number;
  2627. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2628. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2629. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2630. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2631. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2632. static readonly STEP_POINTERMOVE_SPRITE: number;
  2633. static readonly STEP_POINTERDOWN_SPRITE: number;
  2634. static readonly STEP_POINTERUP_SPRITE: number;
  2635. }
  2636. /**
  2637. * This represents a scene component.
  2638. *
  2639. * This is used to decouple the dependency the scene is having on the different workloads like
  2640. * layers, post processes...
  2641. */
  2642. interface ISceneComponent {
  2643. /**
  2644. * The name of the component. Each component must have a unique name.
  2645. */
  2646. name: string;
  2647. /**
  2648. * The scene the component belongs to.
  2649. */
  2650. scene: Scene;
  2651. /**
  2652. * Register the component to one instance of a scene.
  2653. */
  2654. register(): void;
  2655. /**
  2656. * Rebuilds the elements related to this component in case of
  2657. * context lost for instance.
  2658. */
  2659. rebuild(): void;
  2660. /**
  2661. * Disposes the component and the associated ressources.
  2662. */
  2663. dispose(): void;
  2664. }
  2665. /**
  2666. * This represents a SERIALIZABLE scene component.
  2667. *
  2668. * This extends Scene Component to add Serialization methods on top.
  2669. */
  2670. interface ISceneSerializableComponent extends ISceneComponent {
  2671. /**
  2672. * Adds all the element from the container to the scene
  2673. * @param container the container holding the elements
  2674. */
  2675. addFromContainer(container: AbstractScene): void;
  2676. /**
  2677. * Removes all the elements in the container from the scene
  2678. * @param container contains the elements to remove
  2679. */
  2680. removeFromContainer(container: AbstractScene): void;
  2681. /**
  2682. * Serializes the component data to the specified json object
  2683. * @param serializationObject The object to serialize to
  2684. */
  2685. serialize(serializationObject: any): void;
  2686. }
  2687. /**
  2688. * Strong typing of a Mesh related stage step action
  2689. */
  2690. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2691. /**
  2692. * Strong typing of a Evaluate Sub Mesh related stage step action
  2693. */
  2694. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2695. /**
  2696. * Strong typing of a Active Mesh related stage step action
  2697. */
  2698. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2699. /**
  2700. * Strong typing of a Camera related stage step action
  2701. */
  2702. type CameraStageAction = (camera: Camera) => void;
  2703. /**
  2704. * Strong typing of a Render Target related stage step action
  2705. */
  2706. type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  2707. /**
  2708. * Strong typing of a RenderingGroup related stage step action
  2709. */
  2710. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2711. /**
  2712. * Strong typing of a Mesh Render related stage step action
  2713. */
  2714. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2715. /**
  2716. * Strong typing of a simple stage step action
  2717. */
  2718. type SimpleStageAction = () => void;
  2719. /**
  2720. * Strong typing of a render target action.
  2721. */
  2722. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2723. /**
  2724. * Strong typing of a pointer move action.
  2725. */
  2726. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2727. /**
  2728. * Strong typing of a pointer up/down action.
  2729. */
  2730. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2731. /**
  2732. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2733. * @hidden
  2734. */
  2735. class Stage<T extends Function> extends Array<{
  2736. index: number;
  2737. component: ISceneComponent;
  2738. action: T;
  2739. }> {
  2740. /**
  2741. * Hide ctor from the rest of the world.
  2742. * @param items The items to add.
  2743. */
  2744. private constructor();
  2745. /**
  2746. * Creates a new Stage.
  2747. * @returns A new instance of a Stage
  2748. */
  2749. static Create<T extends Function>(): Stage<T>;
  2750. /**
  2751. * Registers a step in an ordered way in the targeted stage.
  2752. * @param index Defines the position to register the step in
  2753. * @param component Defines the component attached to the step
  2754. * @param action Defines the action to launch during the step
  2755. */
  2756. registerStep(index: number, component: ISceneComponent, action: T): void;
  2757. /**
  2758. * Clears all the steps from the stage.
  2759. */
  2760. clear(): void;
  2761. }
  2762. }
  2763. declare module BABYLON {
  2764. /** Alias type for value that can be null */
  2765. type Nullable<T> = T | null;
  2766. /**
  2767. * Alias type for number that are floats
  2768. * @ignorenaming
  2769. */
  2770. type float = number;
  2771. /**
  2772. * Alias type for number that are doubles.
  2773. * @ignorenaming
  2774. */
  2775. type double = number;
  2776. /**
  2777. * Alias type for number that are integer
  2778. * @ignorenaming
  2779. */
  2780. type int = number;
  2781. /** Alias type for number array or Float32Array */
  2782. type FloatArray = number[] | Float32Array;
  2783. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2784. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2785. /**
  2786. * Alias for types that can be used by a Buffer or VertexBuffer.
  2787. */
  2788. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2789. /**
  2790. * Alias type for primitive types
  2791. * @ignorenaming
  2792. */
  2793. type Primitive = undefined | null | boolean | string | number | Function;
  2794. /**
  2795. * Type modifier to make all the properties of an object Readonly
  2796. */
  2797. type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  2798. /**
  2799. * Type modifier to make all the properties of an object Readonly recursively
  2800. */
  2801. type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  2802. /** @hidden */
  2803. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  2804. }
  2805. /** @hidden */
  2806. /** @hidden */
  2807. type DeepImmutableObject<T> = {
  2808. readonly [K in keyof T]: DeepImmutable<T[K]>;
  2809. };
  2810. }
  2811. declare module BABYLON {
  2812. /**
  2813. * The action to be carried out following a trigger
  2814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2815. */
  2816. class Action {
  2817. /** the trigger, with or without parameters, for the action */
  2818. triggerOptions: any;
  2819. /**
  2820. * Trigger for the action
  2821. */
  2822. trigger: number;
  2823. /**
  2824. * Internal only - manager for action
  2825. * @hidden
  2826. */
  2827. _actionManager: ActionManager;
  2828. private _nextActiveAction;
  2829. private _child;
  2830. private _condition?;
  2831. private _triggerParameter;
  2832. /**
  2833. * An event triggered prior to action being executed.
  2834. */
  2835. onBeforeExecuteObservable: Observable<Action>;
  2836. /**
  2837. * Creates a new Action
  2838. * @param triggerOptions the trigger, with or without parameters, for the action
  2839. * @param condition an optional determinant of action
  2840. */
  2841. constructor(
  2842. /** the trigger, with or without parameters, for the action */
  2843. triggerOptions: any, condition?: Condition);
  2844. /**
  2845. * Internal only
  2846. * @hidden
  2847. */
  2848. _prepare(): void;
  2849. /**
  2850. * Gets the trigger parameters
  2851. * @returns the trigger parameters
  2852. */
  2853. getTriggerParameter(): any;
  2854. /**
  2855. * Internal only - executes current action event
  2856. * @hidden
  2857. */
  2858. _executeCurrent(evt?: ActionEvent): void;
  2859. /**
  2860. * Execute placeholder for child classes
  2861. * @param evt optional action event
  2862. */
  2863. execute(evt?: ActionEvent): void;
  2864. /**
  2865. * Skips to next active action
  2866. */
  2867. skipToNextActiveAction(): void;
  2868. /**
  2869. * Adds action to chain of actions, may be a DoNothingAction
  2870. * @param action defines the next action to execute
  2871. * @returns The action passed in
  2872. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2873. */
  2874. then(action: Action): Action;
  2875. /**
  2876. * Internal only
  2877. * @hidden
  2878. */
  2879. _getProperty(propertyPath: string): string;
  2880. /**
  2881. * Internal only
  2882. * @hidden
  2883. */
  2884. _getEffectiveTarget(target: any, propertyPath: string): any;
  2885. /**
  2886. * Serialize placeholder for child classes
  2887. * @param parent of child
  2888. * @returns the serialized object
  2889. */
  2890. serialize(parent: any): any;
  2891. /**
  2892. * Internal only called by serialize
  2893. * @hidden
  2894. */
  2895. protected _serialize(serializedAction: any, parent?: any): any;
  2896. /**
  2897. * Internal only
  2898. * @hidden
  2899. */
  2900. static _SerializeValueAsString: (value: any) => string;
  2901. /**
  2902. * Internal only
  2903. * @hidden
  2904. */
  2905. static _GetTargetProperty: (target: Scene | Node) => {
  2906. name: string;
  2907. targetType: string;
  2908. value: string;
  2909. };
  2910. }
  2911. }
  2912. declare module BABYLON {
  2913. /**
  2914. * ActionEvent is the event being sent when an action is triggered.
  2915. */
  2916. class ActionEvent {
  2917. /** The mesh or sprite that triggered the action */
  2918. source: any;
  2919. /** The X mouse cursor position at the time of the event */
  2920. pointerX: number;
  2921. /** The Y mouse cursor position at the time of the event */
  2922. pointerY: number;
  2923. /** The mesh that is currently pointed at (can be null) */
  2924. meshUnderPointer: Nullable<AbstractMesh>;
  2925. /** the original (browser) event that triggered the ActionEvent */
  2926. sourceEvent?: any;
  2927. /** additional data for the event */
  2928. additionalData?: any;
  2929. /**
  2930. * Creates a new ActionEvent
  2931. * @param source The mesh or sprite that triggered the action
  2932. * @param pointerX The X mouse cursor position at the time of the event
  2933. * @param pointerY The Y mouse cursor position at the time of the event
  2934. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2935. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2936. * @param additionalData additional data for the event
  2937. */
  2938. constructor(
  2939. /** The mesh or sprite that triggered the action */
  2940. source: any,
  2941. /** The X mouse cursor position at the time of the event */
  2942. pointerX: number,
  2943. /** The Y mouse cursor position at the time of the event */
  2944. pointerY: number,
  2945. /** The mesh that is currently pointed at (can be null) */
  2946. meshUnderPointer: Nullable<AbstractMesh>,
  2947. /** the original (browser) event that triggered the ActionEvent */
  2948. sourceEvent?: any,
  2949. /** additional data for the event */
  2950. additionalData?: any);
  2951. /**
  2952. * Helper function to auto-create an ActionEvent from a source mesh.
  2953. * @param source The source mesh that triggered the event
  2954. * @param evt The original (browser) event
  2955. * @param additionalData additional data for the event
  2956. * @returns the new ActionEvent
  2957. */
  2958. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2959. /**
  2960. * Helper function to auto-create an ActionEvent from a source sprite
  2961. * @param source The source sprite that triggered the event
  2962. * @param scene Scene associated with the sprite
  2963. * @param evt The original (browser) event
  2964. * @param additionalData additional data for the event
  2965. * @returns the new ActionEvent
  2966. */
  2967. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2968. /**
  2969. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2970. * @param scene the scene where the event occurred
  2971. * @param evt The original (browser) event
  2972. * @returns the new ActionEvent
  2973. */
  2974. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2975. /**
  2976. * Helper function to auto-create an ActionEvent from a primitive
  2977. * @param prim defines the target primitive
  2978. * @param pointerPos defines the pointer position
  2979. * @param evt The original (browser) event
  2980. * @param additionalData additional data for the event
  2981. * @returns the new ActionEvent
  2982. */
  2983. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2984. }
  2985. /**
  2986. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2987. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2989. */
  2990. class ActionManager {
  2991. /**
  2992. * Nothing
  2993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2994. */
  2995. static readonly NothingTrigger: number;
  2996. /**
  2997. * On pick
  2998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2999. */
  3000. static readonly OnPickTrigger: number;
  3001. /**
  3002. * On left pick
  3003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3004. */
  3005. static readonly OnLeftPickTrigger: number;
  3006. /**
  3007. * On right pick
  3008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3009. */
  3010. static readonly OnRightPickTrigger: number;
  3011. /**
  3012. * On center pick
  3013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3014. */
  3015. static readonly OnCenterPickTrigger: number;
  3016. /**
  3017. * On pick down
  3018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3019. */
  3020. static readonly OnPickDownTrigger: number;
  3021. /**
  3022. * On double pick
  3023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3024. */
  3025. static readonly OnDoublePickTrigger: number;
  3026. /**
  3027. * On pick up
  3028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3029. */
  3030. static readonly OnPickUpTrigger: number;
  3031. /**
  3032. * On pick out.
  3033. * This trigger will only be raised if you also declared a OnPickDown
  3034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3035. */
  3036. static readonly OnPickOutTrigger: number;
  3037. /**
  3038. * On long press
  3039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3040. */
  3041. static readonly OnLongPressTrigger: number;
  3042. /**
  3043. * On pointer over
  3044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3045. */
  3046. static readonly OnPointerOverTrigger: number;
  3047. /**
  3048. * On pointer out
  3049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3050. */
  3051. static readonly OnPointerOutTrigger: number;
  3052. /**
  3053. * On every frame
  3054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3055. */
  3056. static readonly OnEveryFrameTrigger: number;
  3057. /**
  3058. * On intersection enter
  3059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3060. */
  3061. static readonly OnIntersectionEnterTrigger: number;
  3062. /**
  3063. * On intersection exit
  3064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3065. */
  3066. static readonly OnIntersectionExitTrigger: number;
  3067. /**
  3068. * On key down
  3069. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3070. */
  3071. static readonly OnKeyDownTrigger: number;
  3072. /**
  3073. * On key up
  3074. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3075. */
  3076. static readonly OnKeyUpTrigger: number;
  3077. /** Gets the list of active triggers */
  3078. static Triggers: {
  3079. [key: string]: number;
  3080. };
  3081. /** Gets the list of actions */
  3082. actions: Action[];
  3083. /** Gets the cursor to use when hovering items */
  3084. hoverCursor: string;
  3085. private _scene;
  3086. /**
  3087. * Creates a new action manager
  3088. * @param scene defines the hosting scene
  3089. */
  3090. constructor(scene: Scene);
  3091. /**
  3092. * Releases all associated resources
  3093. */
  3094. dispose(): void;
  3095. /**
  3096. * Gets hosting scene
  3097. * @returns the hosting scene
  3098. */
  3099. getScene(): Scene;
  3100. /**
  3101. * Does this action manager handles actions of any of the given triggers
  3102. * @param triggers defines the triggers to be tested
  3103. * @return a boolean indicating whether one (or more) of the triggers is handled
  3104. */
  3105. hasSpecificTriggers(triggers: number[]): boolean;
  3106. /**
  3107. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  3108. * speed.
  3109. * @param triggerA defines the trigger to be tested
  3110. * @param triggerB defines the trigger to be tested
  3111. * @return a boolean indicating whether one (or more) of the triggers is handled
  3112. */
  3113. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  3114. /**
  3115. * Does this action manager handles actions of a given trigger
  3116. * @param trigger defines the trigger to be tested
  3117. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3118. * @return whether the trigger is handled
  3119. */
  3120. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3121. /**
  3122. * Does this action manager has pointer triggers
  3123. */
  3124. readonly hasPointerTriggers: boolean;
  3125. /**
  3126. * Does this action manager has pick triggers
  3127. */
  3128. readonly hasPickTriggers: boolean;
  3129. /**
  3130. * Does exist one action manager with at least one trigger
  3131. **/
  3132. static readonly HasTriggers: boolean;
  3133. /**
  3134. * Does exist one action manager with at least one pick trigger
  3135. **/
  3136. static readonly HasPickTriggers: boolean;
  3137. /**
  3138. * Does exist one action manager that handles actions of a given trigger
  3139. * @param trigger defines the trigger to be tested
  3140. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3141. **/
  3142. static HasSpecificTrigger(trigger: number): boolean;
  3143. /**
  3144. * Registers an action to this action manager
  3145. * @param action defines the action to be registered
  3146. * @return the action amended (prepared) after registration
  3147. */
  3148. registerAction(action: Action): Nullable<Action>;
  3149. /**
  3150. * Unregisters an action to this action manager
  3151. * @param action defines the action to be unregistered
  3152. * @return a boolean indicating whether the action has been unregistered
  3153. */
  3154. unregisterAction(action: Action): Boolean;
  3155. /**
  3156. * Process a specific trigger
  3157. * @param trigger defines the trigger to process
  3158. * @param evt defines the event details to be processed
  3159. */
  3160. processTrigger(trigger: number, evt?: ActionEvent): void;
  3161. /** @hidden */
  3162. _getEffectiveTarget(target: any, propertyPath: string): any;
  3163. /** @hidden */
  3164. _getProperty(propertyPath: string): string;
  3165. /**
  3166. * Serialize this manager to a JSON object
  3167. * @param name defines the property name to store this manager
  3168. * @returns a JSON representation of this manager
  3169. */
  3170. serialize(name: string): any;
  3171. /**
  3172. * Creates a new ActionManager from a JSON data
  3173. * @param parsedActions defines the JSON data to read from
  3174. * @param object defines the hosting mesh
  3175. * @param scene defines the hosting scene
  3176. */
  3177. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3178. /**
  3179. * Get a trigger name by index
  3180. * @param trigger defines the trigger index
  3181. * @returns a trigger name
  3182. */
  3183. static GetTriggerName(trigger: number): string;
  3184. }
  3185. }
  3186. declare module BABYLON {
  3187. /**
  3188. * A Condition applied to an Action
  3189. */
  3190. class Condition {
  3191. /**
  3192. * Internal only - manager for action
  3193. * @hidden
  3194. */
  3195. _actionManager: ActionManager;
  3196. /**
  3197. * Internal only
  3198. * @hidden
  3199. */
  3200. _evaluationId: number;
  3201. /**
  3202. * Internal only
  3203. * @hidden
  3204. */
  3205. _currentResult: boolean;
  3206. /**
  3207. * Creates a new Condition
  3208. * @param actionManager the manager of the action the condition is applied to
  3209. */
  3210. constructor(actionManager: ActionManager);
  3211. /**
  3212. * Check if the current condition is valid
  3213. * @returns a boolean
  3214. */
  3215. isValid(): boolean;
  3216. /**
  3217. * Internal only
  3218. * @hidden
  3219. */
  3220. _getProperty(propertyPath: string): string;
  3221. /**
  3222. * Internal only
  3223. * @hidden
  3224. */
  3225. _getEffectiveTarget(target: any, propertyPath: string): any;
  3226. /**
  3227. * Serialize placeholder for child classes
  3228. * @returns the serialized object
  3229. */
  3230. serialize(): any;
  3231. /**
  3232. * Internal only
  3233. * @hidden
  3234. */
  3235. protected _serialize(serializedCondition: any): any;
  3236. }
  3237. /**
  3238. * Defines specific conditional operators as extensions of Condition
  3239. */
  3240. class ValueCondition extends Condition {
  3241. /** path to specify the property of the target the conditional operator uses */
  3242. propertyPath: string;
  3243. /** the value compared by the conditional operator against the current value of the property */
  3244. value: any;
  3245. /** the conditional operator, default ValueCondition.IsEqual */
  3246. operator: number;
  3247. /**
  3248. * Internal only
  3249. * @hidden
  3250. */
  3251. private static _IsEqual;
  3252. /**
  3253. * Internal only
  3254. * @hidden
  3255. */
  3256. private static _IsDifferent;
  3257. /**
  3258. * Internal only
  3259. * @hidden
  3260. */
  3261. private static _IsGreater;
  3262. /**
  3263. * Internal only
  3264. * @hidden
  3265. */
  3266. private static _IsLesser;
  3267. /**
  3268. * returns the number for IsEqual
  3269. */
  3270. static readonly IsEqual: number;
  3271. /**
  3272. * Returns the number for IsDifferent
  3273. */
  3274. static readonly IsDifferent: number;
  3275. /**
  3276. * Returns the number for IsGreater
  3277. */
  3278. static readonly IsGreater: number;
  3279. /**
  3280. * Returns the number for IsLesser
  3281. */
  3282. static readonly IsLesser: number;
  3283. /**
  3284. * Internal only The action manager for the condition
  3285. * @hidden
  3286. */
  3287. _actionManager: ActionManager;
  3288. /**
  3289. * Internal only
  3290. * @hidden
  3291. */
  3292. private _target;
  3293. /**
  3294. * Internal only
  3295. * @hidden
  3296. */
  3297. private _effectiveTarget;
  3298. /**
  3299. * Internal only
  3300. * @hidden
  3301. */
  3302. private _property;
  3303. /**
  3304. * Creates a new ValueCondition
  3305. * @param actionManager manager for the action the condition applies to
  3306. * @param target for the action
  3307. * @param propertyPath path to specify the property of the target the conditional operator uses
  3308. * @param value the value compared by the conditional operator against the current value of the property
  3309. * @param operator the conditional operator, default ValueCondition.IsEqual
  3310. */
  3311. constructor(actionManager: ActionManager, target: any,
  3312. /** path to specify the property of the target the conditional operator uses */
  3313. propertyPath: string,
  3314. /** the value compared by the conditional operator against the current value of the property */
  3315. value: any,
  3316. /** the conditional operator, default ValueCondition.IsEqual */
  3317. operator?: number);
  3318. /**
  3319. * Compares the given value with the property value for the specified conditional operator
  3320. * @returns the result of the comparison
  3321. */
  3322. isValid(): boolean;
  3323. /**
  3324. * Serialize the ValueCondition into a JSON compatible object
  3325. * @returns serialization object
  3326. */
  3327. serialize(): any;
  3328. /**
  3329. * Gets the name of the conditional operator for the ValueCondition
  3330. * @param operator the conditional operator
  3331. * @returns the name
  3332. */
  3333. static GetOperatorName(operator: number): string;
  3334. }
  3335. /**
  3336. * Defines a predicate condition as an extension of Condition
  3337. */
  3338. class PredicateCondition extends Condition {
  3339. /** defines the predicate function used to validate the condition */
  3340. predicate: () => boolean;
  3341. /**
  3342. * Internal only - manager for action
  3343. * @hidden
  3344. */
  3345. _actionManager: ActionManager;
  3346. /**
  3347. * Creates a new PredicateCondition
  3348. * @param actionManager manager for the action the condition applies to
  3349. * @param predicate defines the predicate function used to validate the condition
  3350. */
  3351. constructor(actionManager: ActionManager,
  3352. /** defines the predicate function used to validate the condition */
  3353. predicate: () => boolean);
  3354. /**
  3355. * @returns the validity of the predicate condition
  3356. */
  3357. isValid(): boolean;
  3358. }
  3359. /**
  3360. * Defines a state condition as an extension of Condition
  3361. */
  3362. class StateCondition extends Condition {
  3363. /** Value to compare with target state */
  3364. value: string;
  3365. /**
  3366. * Internal only - manager for action
  3367. * @hidden
  3368. */
  3369. _actionManager: ActionManager;
  3370. /**
  3371. * Internal only
  3372. * @hidden
  3373. */
  3374. private _target;
  3375. /**
  3376. * Creates a new StateCondition
  3377. * @param actionManager manager for the action the condition applies to
  3378. * @param target of the condition
  3379. * @param value to compare with target state
  3380. */
  3381. constructor(actionManager: ActionManager, target: any,
  3382. /** Value to compare with target state */
  3383. value: string);
  3384. /**
  3385. * Gets a boolean indicating if the current condition is met
  3386. * @returns the validity of the state
  3387. */
  3388. isValid(): boolean;
  3389. /**
  3390. * Serialize the StateCondition into a JSON compatible object
  3391. * @returns serialization object
  3392. */
  3393. serialize(): any;
  3394. }
  3395. }
  3396. declare module BABYLON {
  3397. /**
  3398. * This defines an action responsible to toggle a boolean once triggered.
  3399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3400. */
  3401. class SwitchBooleanAction extends Action {
  3402. /**
  3403. * The path to the boolean property in the target object
  3404. */
  3405. propertyPath: string;
  3406. private _target;
  3407. private _effectiveTarget;
  3408. private _property;
  3409. /**
  3410. * Instantiate the action
  3411. * @param triggerOptions defines the trigger options
  3412. * @param target defines the object containing the boolean
  3413. * @param propertyPath defines the path to the boolean property in the target object
  3414. * @param condition defines the trigger related conditions
  3415. */
  3416. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3417. /** @hidden */
  3418. _prepare(): void;
  3419. /**
  3420. * Execute the action toggle the boolean value.
  3421. */
  3422. execute(): void;
  3423. /**
  3424. * Serializes the actions and its related information.
  3425. * @param parent defines the object to serialize in
  3426. * @returns the serialized object
  3427. */
  3428. serialize(parent: any): any;
  3429. }
  3430. /**
  3431. * This defines an action responsible to set a the state field of the target
  3432. * to a desired value once triggered.
  3433. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3434. */
  3435. class SetStateAction extends Action {
  3436. /**
  3437. * The value to store in the state field.
  3438. */
  3439. value: string;
  3440. private _target;
  3441. /**
  3442. * Instantiate the action
  3443. * @param triggerOptions defines the trigger options
  3444. * @param target defines the object containing the state property
  3445. * @param value defines the value to store in the state field
  3446. * @param condition defines the trigger related conditions
  3447. */
  3448. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3449. /**
  3450. * Execute the action and store the value on the target state property.
  3451. */
  3452. execute(): void;
  3453. /**
  3454. * Serializes the actions and its related information.
  3455. * @param parent defines the object to serialize in
  3456. * @returns the serialized object
  3457. */
  3458. serialize(parent: any): any;
  3459. }
  3460. /**
  3461. * This defines an action responsible to set a property of the target
  3462. * to a desired value once triggered.
  3463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3464. */
  3465. class SetValueAction extends Action {
  3466. /**
  3467. * The path of the property to set in the target.
  3468. */
  3469. propertyPath: string;
  3470. /**
  3471. * The value to set in the property
  3472. */
  3473. value: any;
  3474. private _target;
  3475. private _effectiveTarget;
  3476. private _property;
  3477. /**
  3478. * Instantiate the action
  3479. * @param triggerOptions defines the trigger options
  3480. * @param target defines the object containing the property
  3481. * @param propertyPath defines the path of the property to set in the target
  3482. * @param value defines the value to set in the property
  3483. * @param condition defines the trigger related conditions
  3484. */
  3485. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3486. /** @hidden */
  3487. _prepare(): void;
  3488. /**
  3489. * Execute the action and set the targetted property to the desired value.
  3490. */
  3491. execute(): void;
  3492. /**
  3493. * Serializes the actions and its related information.
  3494. * @param parent defines the object to serialize in
  3495. * @returns the serialized object
  3496. */
  3497. serialize(parent: any): any;
  3498. }
  3499. /**
  3500. * This defines an action responsible to increment the target value
  3501. * to a desired value once triggered.
  3502. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3503. */
  3504. class IncrementValueAction extends Action {
  3505. /**
  3506. * The path of the property to increment in the target.
  3507. */
  3508. propertyPath: string;
  3509. /**
  3510. * The value we should increment the property by.
  3511. */
  3512. value: any;
  3513. private _target;
  3514. private _effectiveTarget;
  3515. private _property;
  3516. /**
  3517. * Instantiate the action
  3518. * @param triggerOptions defines the trigger options
  3519. * @param target defines the object containing the property
  3520. * @param propertyPath defines the path of the property to increment in the target
  3521. * @param value defines the value value we should increment the property by
  3522. * @param condition defines the trigger related conditions
  3523. */
  3524. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3525. /** @hidden */
  3526. _prepare(): void;
  3527. /**
  3528. * Execute the action and increment the target of the value amount.
  3529. */
  3530. execute(): void;
  3531. /**
  3532. * Serializes the actions and its related information.
  3533. * @param parent defines the object to serialize in
  3534. * @returns the serialized object
  3535. */
  3536. serialize(parent: any): any;
  3537. }
  3538. /**
  3539. * This defines an action responsible to start an animation once triggered.
  3540. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3541. */
  3542. class PlayAnimationAction extends Action {
  3543. /**
  3544. * Where the animation should start (animation frame)
  3545. */
  3546. from: number;
  3547. /**
  3548. * Where the animation should stop (animation frame)
  3549. */
  3550. to: number;
  3551. /**
  3552. * Define if the animation should loop or stop after the first play.
  3553. */
  3554. loop?: boolean;
  3555. private _target;
  3556. /**
  3557. * Instantiate the action
  3558. * @param triggerOptions defines the trigger options
  3559. * @param target defines the target animation or animation name
  3560. * @param from defines from where the animation should start (animation frame)
  3561. * @param end defines where the animation should stop (animation frame)
  3562. * @param loop defines if the animation should loop or stop after the first play
  3563. * @param condition defines the trigger related conditions
  3564. */
  3565. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3566. /** @hidden */
  3567. _prepare(): void;
  3568. /**
  3569. * Execute the action and play the animation.
  3570. */
  3571. execute(): void;
  3572. /**
  3573. * Serializes the actions and its related information.
  3574. * @param parent defines the object to serialize in
  3575. * @returns the serialized object
  3576. */
  3577. serialize(parent: any): any;
  3578. }
  3579. /**
  3580. * This defines an action responsible to stop an animation once triggered.
  3581. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3582. */
  3583. class StopAnimationAction extends Action {
  3584. private _target;
  3585. /**
  3586. * Instantiate the action
  3587. * @param triggerOptions defines the trigger options
  3588. * @param target defines the target animation or animation name
  3589. * @param condition defines the trigger related conditions
  3590. */
  3591. constructor(triggerOptions: any, target: any, condition?: Condition);
  3592. /** @hidden */
  3593. _prepare(): void;
  3594. /**
  3595. * Execute the action and stop the animation.
  3596. */
  3597. execute(): void;
  3598. /**
  3599. * Serializes the actions and its related information.
  3600. * @param parent defines the object to serialize in
  3601. * @returns the serialized object
  3602. */
  3603. serialize(parent: any): any;
  3604. }
  3605. /**
  3606. * This defines an action responsible that does nothing once triggered.
  3607. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3608. */
  3609. class DoNothingAction extends Action {
  3610. /**
  3611. * Instantiate the action
  3612. * @param triggerOptions defines the trigger options
  3613. * @param condition defines the trigger related conditions
  3614. */
  3615. constructor(triggerOptions?: any, condition?: Condition);
  3616. /**
  3617. * Execute the action and do nothing.
  3618. */
  3619. execute(): void;
  3620. /**
  3621. * Serializes the actions and its related information.
  3622. * @param parent defines the object to serialize in
  3623. * @returns the serialized object
  3624. */
  3625. serialize(parent: any): any;
  3626. }
  3627. /**
  3628. * This defines an action responsible to trigger several actions once triggered.
  3629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3630. */
  3631. class CombineAction extends Action {
  3632. /**
  3633. * The list of aggregated animations to run.
  3634. */
  3635. children: Action[];
  3636. /**
  3637. * Instantiate the action
  3638. * @param triggerOptions defines the trigger options
  3639. * @param children defines the list of aggregated animations to run
  3640. * @param condition defines the trigger related conditions
  3641. */
  3642. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3643. /** @hidden */
  3644. _prepare(): void;
  3645. /**
  3646. * Execute the action and executes all the aggregated actions.
  3647. */
  3648. execute(evt: ActionEvent): void;
  3649. /**
  3650. * Serializes the actions and its related information.
  3651. * @param parent defines the object to serialize in
  3652. * @returns the serialized object
  3653. */
  3654. serialize(parent: any): any;
  3655. }
  3656. /**
  3657. * This defines an action responsible to run code (external event) once triggered.
  3658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3659. */
  3660. class ExecuteCodeAction extends Action {
  3661. /**
  3662. * The callback function to run.
  3663. */
  3664. func: (evt: ActionEvent) => void;
  3665. /**
  3666. * Instantiate the action
  3667. * @param triggerOptions defines the trigger options
  3668. * @param func defines the callback function to run
  3669. * @param condition defines the trigger related conditions
  3670. */
  3671. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3672. /**
  3673. * Execute the action and run the attached code.
  3674. */
  3675. execute(evt: ActionEvent): void;
  3676. }
  3677. /**
  3678. * This defines an action responsible to set the parent property of the target once triggered.
  3679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3680. */
  3681. class SetParentAction extends Action {
  3682. private _parent;
  3683. private _target;
  3684. /**
  3685. * Instantiate the action
  3686. * @param triggerOptions defines the trigger options
  3687. * @param target defines the target containing the parent property
  3688. * @param parent defines from where the animation should start (animation frame)
  3689. * @param condition defines the trigger related conditions
  3690. */
  3691. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3692. /** @hidden */
  3693. _prepare(): void;
  3694. /**
  3695. * Execute the action and set the parent property.
  3696. */
  3697. execute(): void;
  3698. /**
  3699. * Serializes the actions and its related information.
  3700. * @param parent defines the object to serialize in
  3701. * @returns the serialized object
  3702. */
  3703. serialize(parent: any): any;
  3704. }
  3705. }
  3706. declare module BABYLON {
  3707. /**
  3708. * This defines an action helpful to play a defined sound on a triggered action.
  3709. */
  3710. class PlaySoundAction extends Action {
  3711. private _sound;
  3712. /**
  3713. * Instantiate the action
  3714. * @param triggerOptions defines the trigger options
  3715. * @param sound defines the sound to play
  3716. * @param condition defines the trigger related conditions
  3717. */
  3718. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3719. /** @hidden */
  3720. _prepare(): void;
  3721. /**
  3722. * Execute the action and play the sound.
  3723. */
  3724. execute(): void;
  3725. /**
  3726. * Serializes the actions and its related information.
  3727. * @param parent defines the object to serialize in
  3728. * @returns the serialized object
  3729. */
  3730. serialize(parent: any): any;
  3731. }
  3732. /**
  3733. * This defines an action helpful to stop a defined sound on a triggered action.
  3734. */
  3735. class StopSoundAction extends Action {
  3736. private _sound;
  3737. /**
  3738. * Instantiate the action
  3739. * @param triggerOptions defines the trigger options
  3740. * @param sound defines the sound to stop
  3741. * @param condition defines the trigger related conditions
  3742. */
  3743. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3744. /** @hidden */
  3745. _prepare(): void;
  3746. /**
  3747. * Execute the action and stop the sound.
  3748. */
  3749. execute(): void;
  3750. /**
  3751. * Serializes the actions and its related information.
  3752. * @param parent defines the object to serialize in
  3753. * @returns the serialized object
  3754. */
  3755. serialize(parent: any): any;
  3756. }
  3757. }
  3758. declare module BABYLON {
  3759. /**
  3760. * This defines an action responsible to change the value of a property
  3761. * by interpolating between its current value and the newly set one once triggered.
  3762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3763. */
  3764. class InterpolateValueAction extends Action {
  3765. /**
  3766. * Defines the path of the property where the value should be interpolated
  3767. */
  3768. propertyPath: string;
  3769. /**
  3770. * Defines the target value at the end of the interpolation.
  3771. */
  3772. value: any;
  3773. /**
  3774. * Defines the time it will take for the property to interpolate to the value.
  3775. */
  3776. duration: number;
  3777. /**
  3778. * Defines if the other scene animations should be stopped when the action has been triggered
  3779. */
  3780. stopOtherAnimations?: boolean;
  3781. /**
  3782. * Defines a callback raised once the interpolation animation has been done.
  3783. */
  3784. onInterpolationDone?: () => void;
  3785. /**
  3786. * Observable triggered once the interpolation animation has been done.
  3787. */
  3788. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3789. private _target;
  3790. private _effectiveTarget;
  3791. private _property;
  3792. /**
  3793. * Instantiate the action
  3794. * @param triggerOptions defines the trigger options
  3795. * @param target defines the object containing the value to interpolate
  3796. * @param propertyPath defines the path to the property in the target object
  3797. * @param value defines the target value at the end of the interpolation
  3798. * @param duration deines the time it will take for the property to interpolate to the value.
  3799. * @param condition defines the trigger related conditions
  3800. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3801. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3802. */
  3803. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3804. /** @hidden */
  3805. _prepare(): void;
  3806. /**
  3807. * Execute the action starts the value interpolation.
  3808. */
  3809. execute(): void;
  3810. /**
  3811. * Serializes the actions and its related information.
  3812. * @param parent defines the object to serialize in
  3813. * @returns the serialized object
  3814. */
  3815. serialize(parent: any): any;
  3816. }
  3817. }
  3818. declare module BABYLON {
  3819. /**
  3820. * Class used to store an actual running animation
  3821. */
  3822. class Animatable {
  3823. /** defines the target object */
  3824. target: any;
  3825. /** defines the starting frame number (default is 0) */
  3826. fromFrame: number;
  3827. /** defines the ending frame number (default is 100) */
  3828. toFrame: number;
  3829. /** defines if the animation must loop (default is false) */
  3830. loopAnimation: boolean;
  3831. /** defines a callback to call when animation ends if it is not looping */
  3832. onAnimationEnd?: (() => void) | null | undefined;
  3833. /** defines a callback to call when animation loops */
  3834. onAnimationLoop?: (() => void) | null | undefined;
  3835. private _localDelayOffset;
  3836. private _pausedDelay;
  3837. private _runtimeAnimations;
  3838. private _paused;
  3839. private _scene;
  3840. private _speedRatio;
  3841. private _weight;
  3842. private _syncRoot;
  3843. /**
  3844. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3845. * This will only apply for non looping animation (default is true)
  3846. */
  3847. disposeOnEnd: boolean;
  3848. /**
  3849. * Gets a boolean indicating if the animation has started
  3850. */
  3851. animationStarted: boolean;
  3852. /**
  3853. * Observer raised when the animation ends
  3854. */
  3855. onAnimationEndObservable: Observable<Animatable>;
  3856. /**
  3857. * Observer raised when the animation loops
  3858. */
  3859. onAnimationLoopObservable: Observable<Animatable>;
  3860. /**
  3861. * Gets the root Animatable used to synchronize and normalize animations
  3862. */
  3863. readonly syncRoot: Animatable;
  3864. /**
  3865. * Gets the current frame of the first RuntimeAnimation
  3866. * Used to synchronize Animatables
  3867. */
  3868. readonly masterFrame: number;
  3869. /**
  3870. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3871. */
  3872. weight: number;
  3873. /**
  3874. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3875. */
  3876. speedRatio: number;
  3877. /**
  3878. * Creates a new Animatable
  3879. * @param scene defines the hosting scene
  3880. * @param target defines the target object
  3881. * @param fromFrame defines the starting frame number (default is 0)
  3882. * @param toFrame defines the ending frame number (default is 100)
  3883. * @param loopAnimation defines if the animation must loop (default is false)
  3884. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3885. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3886. * @param animations defines a group of animation to add to the new Animatable
  3887. * @param onAnimationLoop defines a callback to call when animation loops
  3888. */
  3889. constructor(scene: Scene,
  3890. /** defines the target object */
  3891. target: any,
  3892. /** defines the starting frame number (default is 0) */
  3893. fromFrame?: number,
  3894. /** defines the ending frame number (default is 100) */
  3895. toFrame?: number,
  3896. /** defines if the animation must loop (default is false) */
  3897. loopAnimation?: boolean, speedRatio?: number,
  3898. /** defines a callback to call when animation ends if it is not looping */
  3899. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  3900. /** defines a callback to call when animation loops */
  3901. onAnimationLoop?: (() => void) | null | undefined);
  3902. /**
  3903. * Synchronize and normalize current Animatable with a source Animatable
  3904. * This is useful when using animation weights and when animations are not of the same length
  3905. * @param root defines the root Animatable to synchronize with
  3906. * @returns the current Animatable
  3907. */
  3908. syncWith(root: Animatable): Animatable;
  3909. /**
  3910. * Gets the list of runtime animations
  3911. * @returns an array of RuntimeAnimation
  3912. */
  3913. getAnimations(): RuntimeAnimation[];
  3914. /**
  3915. * Adds more animations to the current animatable
  3916. * @param target defines the target of the animations
  3917. * @param animations defines the new animations to add
  3918. */
  3919. appendAnimations(target: any, animations: Animation[]): void;
  3920. /**
  3921. * Gets the source animation for a specific property
  3922. * @param property defines the propertyu to look for
  3923. * @returns null or the source animation for the given property
  3924. */
  3925. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3926. /**
  3927. * Gets the runtime animation for a specific property
  3928. * @param property defines the propertyu to look for
  3929. * @returns null or the runtime animation for the given property
  3930. */
  3931. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3932. /**
  3933. * Resets the animatable to its original state
  3934. */
  3935. reset(): void;
  3936. /**
  3937. * Allows the animatable to blend with current running animations
  3938. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3939. * @param blendingSpeed defines the blending speed to use
  3940. */
  3941. enableBlending(blendingSpeed: number): void;
  3942. /**
  3943. * Disable animation blending
  3944. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3945. */
  3946. disableBlending(): void;
  3947. /**
  3948. * Jump directly to a given frame
  3949. * @param frame defines the frame to jump to
  3950. */
  3951. goToFrame(frame: number): void;
  3952. /**
  3953. * Pause the animation
  3954. */
  3955. pause(): void;
  3956. /**
  3957. * Restart the animation
  3958. */
  3959. restart(): void;
  3960. private _raiseOnAnimationEnd;
  3961. /**
  3962. * Stop and delete the current animation
  3963. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3964. * @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)
  3965. */
  3966. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3967. /**
  3968. * Wait asynchronously for the animation to end
  3969. * @returns a promise which will be fullfilled when the animation ends
  3970. */
  3971. waitAsync(): Promise<Animatable>;
  3972. /** @hidden */
  3973. _animate(delay: number): boolean;
  3974. }
  3975. }
  3976. declare module BABYLON {
  3977. /**
  3978. * Represents the range of an animation
  3979. */
  3980. class AnimationRange {
  3981. /**The name of the animation range**/
  3982. name: string;
  3983. /**The starting frame of the animation */
  3984. from: number;
  3985. /**The ending frame of the animation*/
  3986. to: number;
  3987. /**
  3988. * Initializes the range of an animation
  3989. * @param name The name of the animation range
  3990. * @param from The starting frame of the animation
  3991. * @param to The ending frame of the animation
  3992. */
  3993. constructor(
  3994. /**The name of the animation range**/
  3995. name: string,
  3996. /**The starting frame of the animation */
  3997. from: number,
  3998. /**The ending frame of the animation*/
  3999. to: number);
  4000. /**
  4001. * Makes a copy of the animation range
  4002. * @returns A copy of the animation range
  4003. */
  4004. clone(): AnimationRange;
  4005. }
  4006. /**
  4007. * Composed of a frame, and an action function
  4008. */
  4009. class AnimationEvent {
  4010. /** The frame for which the event is triggered **/
  4011. frame: number;
  4012. /** The event to perform when triggered **/
  4013. action: (currentFrame: number) => void;
  4014. /** Specifies if the event should be triggered only once**/
  4015. onlyOnce?: boolean | undefined;
  4016. /**
  4017. * Specifies if the animation event is done
  4018. */
  4019. isDone: boolean;
  4020. /**
  4021. * Initializes the animation event
  4022. * @param frame The frame for which the event is triggered
  4023. * @param action The event to perform when triggered
  4024. * @param onlyOnce Specifies if the event should be triggered only once
  4025. */
  4026. constructor(
  4027. /** The frame for which the event is triggered **/
  4028. frame: number,
  4029. /** The event to perform when triggered **/
  4030. action: (currentFrame: number) => void,
  4031. /** Specifies if the event should be triggered only once**/
  4032. onlyOnce?: boolean | undefined);
  4033. /** @hidden */
  4034. _clone(): AnimationEvent;
  4035. }
  4036. /**
  4037. * A cursor which tracks a point on a path
  4038. */
  4039. class PathCursor {
  4040. private path;
  4041. /**
  4042. * Stores path cursor callbacks for when an onchange event is triggered
  4043. */
  4044. private _onchange;
  4045. /**
  4046. * The value of the path cursor
  4047. */
  4048. value: number;
  4049. /**
  4050. * The animation array of the path cursor
  4051. */
  4052. animations: Animation[];
  4053. /**
  4054. * Initializes the path cursor
  4055. * @param path The path to track
  4056. */
  4057. constructor(path: Path2);
  4058. /**
  4059. * Gets the cursor point on the path
  4060. * @returns A point on the path cursor at the cursor location
  4061. */
  4062. getPoint(): Vector3;
  4063. /**
  4064. * Moves the cursor ahead by the step amount
  4065. * @param step The amount to move the cursor forward
  4066. * @returns This path cursor
  4067. */
  4068. moveAhead(step?: number): PathCursor;
  4069. /**
  4070. * Moves the cursor behind by the step amount
  4071. * @param step The amount to move the cursor back
  4072. * @returns This path cursor
  4073. */
  4074. moveBack(step?: number): PathCursor;
  4075. /**
  4076. * Moves the cursor by the step amount
  4077. * If the step amount is greater than one, an exception is thrown
  4078. * @param step The amount to move the cursor
  4079. * @returns This path cursor
  4080. */
  4081. move(step: number): PathCursor;
  4082. /**
  4083. * Ensures that the value is limited between zero and one
  4084. * @returns This path cursor
  4085. */
  4086. private ensureLimits;
  4087. /**
  4088. * Runs onchange callbacks on change (used by the animation engine)
  4089. * @returns This path cursor
  4090. */
  4091. private raiseOnChange;
  4092. /**
  4093. * Executes a function on change
  4094. * @param f A path cursor onchange callback
  4095. * @returns This path cursor
  4096. */
  4097. onchange(f: (cursor: PathCursor) => void): PathCursor;
  4098. }
  4099. /**
  4100. * Defines an interface which represents an animation key frame
  4101. */
  4102. interface IAnimationKey {
  4103. /**
  4104. * Frame of the key frame
  4105. */
  4106. frame: number;
  4107. /**
  4108. * Value at the specifies key frame
  4109. */
  4110. value: any;
  4111. /**
  4112. * The input tangent for the cubic hermite spline
  4113. */
  4114. inTangent?: any;
  4115. /**
  4116. * The output tangent for the cubic hermite spline
  4117. */
  4118. outTangent?: any;
  4119. /**
  4120. * The animation interpolation type
  4121. */
  4122. interpolation?: AnimationKeyInterpolation;
  4123. }
  4124. /**
  4125. * Enum for the animation key frame interpolation type
  4126. */
  4127. enum AnimationKeyInterpolation {
  4128. /**
  4129. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4130. */
  4131. STEP = 1
  4132. }
  4133. /**
  4134. * Class used to store any kind of animation
  4135. */
  4136. class Animation {
  4137. /**Name of the animation */
  4138. name: string;
  4139. /**Property to animate */
  4140. targetProperty: string;
  4141. /**The frames per second of the animation */
  4142. framePerSecond: number;
  4143. /**The data type of the animation */
  4144. dataType: number;
  4145. /**The loop mode of the animation */
  4146. loopMode?: number | undefined;
  4147. /**Specifies if blending should be enabled */
  4148. enableBlending?: boolean | undefined;
  4149. /**
  4150. * Use matrix interpolation instead of using direct key value when animating matrices
  4151. */
  4152. static AllowMatricesInterpolation: boolean;
  4153. /**
  4154. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  4155. */
  4156. static AllowMatrixDecomposeForInterpolation: boolean;
  4157. /**
  4158. * Stores the key frames of the animation
  4159. */
  4160. private _keys;
  4161. /**
  4162. * Stores the easing function of the animation
  4163. */
  4164. private _easingFunction;
  4165. /**
  4166. * @hidden Internal use only
  4167. */
  4168. _runtimeAnimations: RuntimeAnimation[];
  4169. /**
  4170. * The set of event that will be linked to this animation
  4171. */
  4172. private _events;
  4173. /**
  4174. * Stores an array of target property paths
  4175. */
  4176. targetPropertyPath: string[];
  4177. /**
  4178. * Stores the blending speed of the animation
  4179. */
  4180. blendingSpeed: number;
  4181. /**
  4182. * Stores the animation ranges for the animation
  4183. */
  4184. private _ranges;
  4185. /**
  4186. * @hidden Internal use
  4187. */
  4188. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4189. /**
  4190. * Sets up an animation
  4191. * @param property The property to animate
  4192. * @param animationType The animation type to apply
  4193. * @param framePerSecond The frames per second of the animation
  4194. * @param easingFunction The easing function used in the animation
  4195. * @returns The created animation
  4196. */
  4197. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4198. /**
  4199. * Create and start an animation on a node
  4200. * @param name defines the name of the global animation that will be run on all nodes
  4201. * @param node defines the root node where the animation will take place
  4202. * @param targetProperty defines property to animate
  4203. * @param framePerSecond defines the number of frame per second yo use
  4204. * @param totalFrame defines the number of frames in total
  4205. * @param from defines the initial value
  4206. * @param to defines the final value
  4207. * @param loopMode defines which loop mode you want to use (off by default)
  4208. * @param easingFunction defines the easing function to use (linear by default)
  4209. * @param onAnimationEnd defines the callback to call when animation end
  4210. * @returns the animatable created for this animation
  4211. */
  4212. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4213. /**
  4214. * Create and start an animation on a node and its descendants
  4215. * @param name defines the name of the global animation that will be run on all nodes
  4216. * @param node defines the root node where the animation will take place
  4217. * @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
  4218. * @param targetProperty defines property to animate
  4219. * @param framePerSecond defines the number of frame per second to use
  4220. * @param totalFrame defines the number of frames in total
  4221. * @param from defines the initial value
  4222. * @param to defines the final value
  4223. * @param loopMode defines which loop mode you want to use (off by default)
  4224. * @param easingFunction defines the easing function to use (linear by default)
  4225. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4226. * @returns the list of animatables created for all nodes
  4227. * @example https://www.babylonjs-playground.com/#MH0VLI
  4228. */
  4229. 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[]>;
  4230. /**
  4231. * Creates a new animation, merges it with the existing animations and starts it
  4232. * @param name Name of the animation
  4233. * @param node Node which contains the scene that begins the animations
  4234. * @param targetProperty Specifies which property to animate
  4235. * @param framePerSecond The frames per second of the animation
  4236. * @param totalFrame The total number of frames
  4237. * @param from The frame at the beginning of the animation
  4238. * @param to The frame at the end of the animation
  4239. * @param loopMode Specifies the loop mode of the animation
  4240. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4241. * @param onAnimationEnd Callback to run once the animation is complete
  4242. * @returns Nullable animation
  4243. */
  4244. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4245. /**
  4246. * Transition property of an host to the target Value
  4247. * @param property The property to transition
  4248. * @param targetValue The target Value of the property
  4249. * @param host The object where the property to animate belongs
  4250. * @param scene Scene used to run the animation
  4251. * @param frameRate Framerate (in frame/s) to use
  4252. * @param transition The transition type we want to use
  4253. * @param duration The duration of the animation, in milliseconds
  4254. * @param onAnimationEnd Callback trigger at the end of the animation
  4255. * @returns Nullable animation
  4256. */
  4257. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4258. /**
  4259. * Return the array of runtime animations currently using this animation
  4260. */
  4261. readonly runtimeAnimations: RuntimeAnimation[];
  4262. /**
  4263. * Specifies if any of the runtime animations are currently running
  4264. */
  4265. readonly hasRunningRuntimeAnimations: boolean;
  4266. /**
  4267. * Initializes the animation
  4268. * @param name Name of the animation
  4269. * @param targetProperty Property to animate
  4270. * @param framePerSecond The frames per second of the animation
  4271. * @param dataType The data type of the animation
  4272. * @param loopMode The loop mode of the animation
  4273. * @param enableBlendings Specifies if blending should be enabled
  4274. */
  4275. constructor(
  4276. /**Name of the animation */
  4277. name: string,
  4278. /**Property to animate */
  4279. targetProperty: string,
  4280. /**The frames per second of the animation */
  4281. framePerSecond: number,
  4282. /**The data type of the animation */
  4283. dataType: number,
  4284. /**The loop mode of the animation */
  4285. loopMode?: number | undefined,
  4286. /**Specifies if blending should be enabled */
  4287. enableBlending?: boolean | undefined);
  4288. /**
  4289. * Converts the animation to a string
  4290. * @param fullDetails support for multiple levels of logging within scene loading
  4291. * @returns String form of the animation
  4292. */
  4293. toString(fullDetails?: boolean): string;
  4294. /**
  4295. * Add an event to this animation
  4296. * @param event Event to add
  4297. */
  4298. addEvent(event: AnimationEvent): void;
  4299. /**
  4300. * Remove all events found at the given frame
  4301. * @param frame The frame to remove events from
  4302. */
  4303. removeEvents(frame: number): void;
  4304. /**
  4305. * Retrieves all the events from the animation
  4306. * @returns Events from the animation
  4307. */
  4308. getEvents(): AnimationEvent[];
  4309. /**
  4310. * Creates an animation range
  4311. * @param name Name of the animation range
  4312. * @param from Starting frame of the animation range
  4313. * @param to Ending frame of the animation
  4314. */
  4315. createRange(name: string, from: number, to: number): void;
  4316. /**
  4317. * Deletes an animation range by name
  4318. * @param name Name of the animation range to delete
  4319. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4320. */
  4321. deleteRange(name: string, deleteFrames?: boolean): void;
  4322. /**
  4323. * Gets the animation range by name, or null if not defined
  4324. * @param name Name of the animation range
  4325. * @returns Nullable animation range
  4326. */
  4327. getRange(name: string): Nullable<AnimationRange>;
  4328. /**
  4329. * Gets the key frames from the animation
  4330. * @returns The key frames of the animation
  4331. */
  4332. getKeys(): Array<IAnimationKey>;
  4333. /**
  4334. * Gets the highest frame rate of the animation
  4335. * @returns Highest frame rate of the animation
  4336. */
  4337. getHighestFrame(): number;
  4338. /**
  4339. * Gets the easing function of the animation
  4340. * @returns Easing function of the animation
  4341. */
  4342. getEasingFunction(): IEasingFunction;
  4343. /**
  4344. * Sets the easing function of the animation
  4345. * @param easingFunction A custom mathematical formula for animation
  4346. */
  4347. setEasingFunction(easingFunction: EasingFunction): void;
  4348. /**
  4349. * Interpolates a scalar linearly
  4350. * @param startValue Start value of the animation curve
  4351. * @param endValue End value of the animation curve
  4352. * @param gradient Scalar amount to interpolate
  4353. * @returns Interpolated scalar value
  4354. */
  4355. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4356. /**
  4357. * Interpolates a scalar cubically
  4358. * @param startValue Start value of the animation curve
  4359. * @param outTangent End tangent of the animation
  4360. * @param endValue End value of the animation curve
  4361. * @param inTangent Start tangent of the animation curve
  4362. * @param gradient Scalar amount to interpolate
  4363. * @returns Interpolated scalar value
  4364. */
  4365. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4366. /**
  4367. * Interpolates a quaternion using a spherical linear interpolation
  4368. * @param startValue Start value of the animation curve
  4369. * @param endValue End value of the animation curve
  4370. * @param gradient Scalar amount to interpolate
  4371. * @returns Interpolated quaternion value
  4372. */
  4373. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4374. /**
  4375. * Interpolates a quaternion cubically
  4376. * @param startValue Start value of the animation curve
  4377. * @param outTangent End tangent of the animation curve
  4378. * @param endValue End value of the animation curve
  4379. * @param inTangent Start tangent of the animation curve
  4380. * @param gradient Scalar amount to interpolate
  4381. * @returns Interpolated quaternion value
  4382. */
  4383. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4384. /**
  4385. * Interpolates a Vector3 linearl
  4386. * @param startValue Start value of the animation curve
  4387. * @param endValue End value of the animation curve
  4388. * @param gradient Scalar amount to interpolate
  4389. * @returns Interpolated scalar value
  4390. */
  4391. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4392. /**
  4393. * Interpolates a Vector3 cubically
  4394. * @param startValue Start value of the animation curve
  4395. * @param outTangent End tangent of the animation
  4396. * @param endValue End value of the animation curve
  4397. * @param inTangent Start tangent of the animation curve
  4398. * @param gradient Scalar amount to interpolate
  4399. * @returns InterpolatedVector3 value
  4400. */
  4401. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4402. /**
  4403. * Interpolates a Vector2 linearly
  4404. * @param startValue Start value of the animation curve
  4405. * @param endValue End value of the animation curve
  4406. * @param gradient Scalar amount to interpolate
  4407. * @returns Interpolated Vector2 value
  4408. */
  4409. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4410. /**
  4411. * Interpolates a Vector2 cubically
  4412. * @param startValue Start value of the animation curve
  4413. * @param outTangent End tangent of the animation
  4414. * @param endValue End value of the animation curve
  4415. * @param inTangent Start tangent of the animation curve
  4416. * @param gradient Scalar amount to interpolate
  4417. * @returns Interpolated Vector2 value
  4418. */
  4419. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4420. /**
  4421. * Interpolates a size linearly
  4422. * @param startValue Start value of the animation curve
  4423. * @param endValue End value of the animation curve
  4424. * @param gradient Scalar amount to interpolate
  4425. * @returns Interpolated Size value
  4426. */
  4427. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4428. /**
  4429. * Interpolates a Color3 linearly
  4430. * @param startValue Start value of the animation curve
  4431. * @param endValue End value of the animation curve
  4432. * @param gradient Scalar amount to interpolate
  4433. * @returns Interpolated Color3 value
  4434. */
  4435. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4436. /**
  4437. * @hidden Internal use only
  4438. */
  4439. _getKeyValue(value: any): any;
  4440. /**
  4441. * @hidden Internal use only
  4442. */
  4443. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4444. /**
  4445. * Defines the function to use to interpolate matrices
  4446. * @param startValue defines the start matrix
  4447. * @param endValue defines the end matrix
  4448. * @param gradient defines the gradient between both matrices
  4449. * @param result defines an optional target matrix where to store the interpolation
  4450. * @returns the interpolated matrix
  4451. */
  4452. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4453. /**
  4454. * Makes a copy of the animation
  4455. * @returns Cloned animation
  4456. */
  4457. clone(): Animation;
  4458. /**
  4459. * Sets the key frames of the animation
  4460. * @param values The animation key frames to set
  4461. */
  4462. setKeys(values: Array<IAnimationKey>): void;
  4463. /**
  4464. * Serializes the animation to an object
  4465. * @returns Serialized object
  4466. */
  4467. serialize(): any;
  4468. /**
  4469. * Float animation type
  4470. */
  4471. private static _ANIMATIONTYPE_FLOAT;
  4472. /**
  4473. * Vector3 animation type
  4474. */
  4475. private static _ANIMATIONTYPE_VECTOR3;
  4476. /**
  4477. * Quaternion animation type
  4478. */
  4479. private static _ANIMATIONTYPE_QUATERNION;
  4480. /**
  4481. * Matrix animation type
  4482. */
  4483. private static _ANIMATIONTYPE_MATRIX;
  4484. /**
  4485. * Color3 animation type
  4486. */
  4487. private static _ANIMATIONTYPE_COLOR3;
  4488. /**
  4489. * Vector2 animation type
  4490. */
  4491. private static _ANIMATIONTYPE_VECTOR2;
  4492. /**
  4493. * Size animation type
  4494. */
  4495. private static _ANIMATIONTYPE_SIZE;
  4496. /**
  4497. * Relative Loop Mode
  4498. */
  4499. private static _ANIMATIONLOOPMODE_RELATIVE;
  4500. /**
  4501. * Cycle Loop Mode
  4502. */
  4503. private static _ANIMATIONLOOPMODE_CYCLE;
  4504. /**
  4505. * Constant Loop Mode
  4506. */
  4507. private static _ANIMATIONLOOPMODE_CONSTANT;
  4508. /**
  4509. * Get the float animation type
  4510. */
  4511. static readonly ANIMATIONTYPE_FLOAT: number;
  4512. /**
  4513. * Get the Vector3 animation type
  4514. */
  4515. static readonly ANIMATIONTYPE_VECTOR3: number;
  4516. /**
  4517. * Get the Vector2 animation type
  4518. */
  4519. static readonly ANIMATIONTYPE_VECTOR2: number;
  4520. /**
  4521. * Get the Size animation type
  4522. */
  4523. static readonly ANIMATIONTYPE_SIZE: number;
  4524. /**
  4525. * Get the Quaternion animation type
  4526. */
  4527. static readonly ANIMATIONTYPE_QUATERNION: number;
  4528. /**
  4529. * Get the Matrix animation type
  4530. */
  4531. static readonly ANIMATIONTYPE_MATRIX: number;
  4532. /**
  4533. * Get the Color3 animation type
  4534. */
  4535. static readonly ANIMATIONTYPE_COLOR3: number;
  4536. /**
  4537. * Get the Relative Loop Mode
  4538. */
  4539. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4540. /**
  4541. * Get the Cycle Loop Mode
  4542. */
  4543. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4544. /**
  4545. * Get the Constant Loop Mode
  4546. */
  4547. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4548. /** @hidden */
  4549. static _UniversalLerp(left: any, right: any, amount: number): any;
  4550. /**
  4551. * Parses an animation object and creates an animation
  4552. * @param parsedAnimation Parsed animation object
  4553. * @returns Animation object
  4554. */
  4555. static Parse(parsedAnimation: any): Animation;
  4556. /**
  4557. * Appends the serialized animations from the source animations
  4558. * @param source Source containing the animations
  4559. * @param destination Target to store the animations
  4560. */
  4561. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4562. }
  4563. }
  4564. declare module BABYLON {
  4565. /**
  4566. * This class defines the direct association between an animation and a target
  4567. */
  4568. class TargetedAnimation {
  4569. /**
  4570. * Animation to perform
  4571. */
  4572. animation: Animation;
  4573. /**
  4574. * Target to animate
  4575. */
  4576. target: any;
  4577. }
  4578. /**
  4579. * Use this class to create coordinated animations on multiple targets
  4580. */
  4581. class AnimationGroup implements IDisposable {
  4582. /** The name of the animation group */
  4583. name: string;
  4584. private _scene;
  4585. private _targetedAnimations;
  4586. private _animatables;
  4587. private _from;
  4588. private _to;
  4589. private _isStarted;
  4590. private _isPaused;
  4591. private _speedRatio;
  4592. /**
  4593. * Gets or sets the unique id of the node
  4594. */
  4595. uniqueId: number;
  4596. /**
  4597. * This observable will notify when one animation have ended
  4598. */
  4599. onAnimationEndObservable: Observable<TargetedAnimation>;
  4600. /**
  4601. * Observer raised when one animation loops
  4602. */
  4603. onAnimationLoopObservable: Observable<TargetedAnimation>;
  4604. /**
  4605. * This observable will notify when all animations have ended.
  4606. */
  4607. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4608. /**
  4609. * This observable will notify when all animations have paused.
  4610. */
  4611. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4612. /**
  4613. * This observable will notify when all animations are playing.
  4614. */
  4615. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  4616. /**
  4617. * Gets the first frame
  4618. */
  4619. readonly from: number;
  4620. /**
  4621. * Gets the last frame
  4622. */
  4623. readonly to: number;
  4624. /**
  4625. * Define if the animations are started
  4626. */
  4627. readonly isStarted: boolean;
  4628. /**
  4629. * Gets a value indicating that the current group is playing
  4630. */
  4631. readonly isPlaying: boolean;
  4632. /**
  4633. * Gets or sets the speed ratio to use for all animations
  4634. */
  4635. /**
  4636. * Gets or sets the speed ratio to use for all animations
  4637. */
  4638. speedRatio: number;
  4639. /**
  4640. * Gets the targeted animations for this animation group
  4641. */
  4642. readonly targetedAnimations: Array<TargetedAnimation>;
  4643. /**
  4644. * returning the list of animatables controlled by this animation group.
  4645. */
  4646. readonly animatables: Array<Animatable>;
  4647. /**
  4648. * Instantiates a new Animation Group.
  4649. * This helps managing several animations at once.
  4650. * @see http://doc.babylonjs.com/how_to/group
  4651. * @param name Defines the name of the group
  4652. * @param scene Defines the scene the group belongs to
  4653. */
  4654. constructor(
  4655. /** The name of the animation group */
  4656. name: string, scene?: Nullable<Scene>);
  4657. /**
  4658. * Add an animation (with its target) in the group
  4659. * @param animation defines the animation we want to add
  4660. * @param target defines the target of the animation
  4661. * @returns the TargetedAnimation object
  4662. */
  4663. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4664. /**
  4665. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4666. * It can add constant keys at begin or end
  4667. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4668. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4669. * @returns the animation group
  4670. */
  4671. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4672. /**
  4673. * Start all animations on given targets
  4674. * @param loop defines if animations must loop
  4675. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4676. * @param from defines the from key (optional)
  4677. * @param to defines the to key (optional)
  4678. * @returns the current animation group
  4679. */
  4680. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4681. /**
  4682. * Pause all animations
  4683. * @returns the animation group
  4684. */
  4685. pause(): AnimationGroup;
  4686. /**
  4687. * Play all animations to initial state
  4688. * This function will start() the animations if they were not started or will restart() them if they were paused
  4689. * @param loop defines if animations must loop
  4690. * @returns the animation group
  4691. */
  4692. play(loop?: boolean): AnimationGroup;
  4693. /**
  4694. * Reset all animations to initial state
  4695. * @returns the animation group
  4696. */
  4697. reset(): AnimationGroup;
  4698. /**
  4699. * Restart animations from key 0
  4700. * @returns the animation group
  4701. */
  4702. restart(): AnimationGroup;
  4703. /**
  4704. * Stop all animations
  4705. * @returns the animation group
  4706. */
  4707. stop(): AnimationGroup;
  4708. /**
  4709. * Set animation weight for all animatables
  4710. * @param weight defines the weight to use
  4711. * @return the animationGroup
  4712. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4713. */
  4714. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4715. /**
  4716. * Synchronize and normalize all animatables with a source animatable
  4717. * @param root defines the root animatable to synchronize with
  4718. * @return the animationGroup
  4719. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4720. */
  4721. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4722. /**
  4723. * Goes to a specific frame in this animation group
  4724. * @param frame the frame number to go to
  4725. * @return the animationGroup
  4726. */
  4727. goToFrame(frame: number): AnimationGroup;
  4728. /**
  4729. * Dispose all associated resources
  4730. */
  4731. dispose(): void;
  4732. private _checkAnimationGroupEnded;
  4733. /**
  4734. * Returns a new AnimationGroup object parsed from the source provided.
  4735. * @param parsedAnimationGroup defines the source
  4736. * @param scene defines the scene that will receive the animationGroup
  4737. * @returns a new AnimationGroup
  4738. */
  4739. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  4740. /**
  4741. * Returns the string "AnimationGroup"
  4742. * @returns "AnimationGroup"
  4743. */
  4744. getClassName(): string;
  4745. /**
  4746. * Creates a detailled string about the object
  4747. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4748. * @returns a string representing the object
  4749. */
  4750. toString(fullDetails?: boolean): string;
  4751. }
  4752. }
  4753. declare module BABYLON {
  4754. /**
  4755. * Class used to override all child animations of a given target
  4756. */
  4757. class AnimationPropertiesOverride {
  4758. /**
  4759. * Gets or sets a value indicating if animation blending must be used
  4760. */
  4761. enableBlending: boolean;
  4762. /**
  4763. * Gets or sets the blending speed to use when enableBlending is true
  4764. */
  4765. blendingSpeed: number;
  4766. /**
  4767. * Gets or sets the default loop mode to use
  4768. */
  4769. loopMode: number;
  4770. }
  4771. }
  4772. declare module BABYLON {
  4773. /**
  4774. * This represents the main contract an easing function should follow.
  4775. * Easing functions are used throughout the animation system.
  4776. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4777. */
  4778. interface IEasingFunction {
  4779. /**
  4780. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4781. * of the easing function.
  4782. * The link below provides some of the most common examples of easing functions.
  4783. * @see https://easings.net/
  4784. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4785. * @returns the corresponding value on the curve defined by the easing function
  4786. */
  4787. ease(gradient: number): number;
  4788. }
  4789. /**
  4790. * Base class used for every default easing function.
  4791. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4792. */
  4793. class EasingFunction implements IEasingFunction {
  4794. /**
  4795. * Interpolation follows the mathematical formula associated with the easing function.
  4796. */
  4797. static readonly EASINGMODE_EASEIN: number;
  4798. /**
  4799. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4800. */
  4801. static readonly EASINGMODE_EASEOUT: number;
  4802. /**
  4803. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4804. */
  4805. static readonly EASINGMODE_EASEINOUT: number;
  4806. private _easingMode;
  4807. /**
  4808. * Sets the easing mode of the current function.
  4809. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4810. */
  4811. setEasingMode(easingMode: number): void;
  4812. /**
  4813. * Gets the current easing mode.
  4814. * @returns the easing mode
  4815. */
  4816. getEasingMode(): number;
  4817. /**
  4818. * @hidden
  4819. */
  4820. easeInCore(gradient: number): number;
  4821. /**
  4822. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4823. * of the easing function.
  4824. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4825. * @returns the corresponding value on the curve defined by the easing function
  4826. */
  4827. ease(gradient: number): number;
  4828. }
  4829. /**
  4830. * Easing function with a circle shape (see link below).
  4831. * @see https://easings.net/#easeInCirc
  4832. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4833. */
  4834. class CircleEase extends EasingFunction implements IEasingFunction {
  4835. /** @hidden */
  4836. easeInCore(gradient: number): number;
  4837. }
  4838. /**
  4839. * Easing function with a ease back shape (see link below).
  4840. * @see https://easings.net/#easeInBack
  4841. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4842. */
  4843. class BackEase extends EasingFunction implements IEasingFunction {
  4844. /** Defines the amplitude of the function */
  4845. amplitude: number;
  4846. /**
  4847. * Instantiates a back ease easing
  4848. * @see https://easings.net/#easeInBack
  4849. * @param amplitude Defines the amplitude of the function
  4850. */
  4851. constructor(
  4852. /** Defines the amplitude of the function */
  4853. amplitude?: number);
  4854. /** @hidden */
  4855. easeInCore(gradient: number): number;
  4856. }
  4857. /**
  4858. * Easing function with a bouncing shape (see link below).
  4859. * @see https://easings.net/#easeInBounce
  4860. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4861. */
  4862. class BounceEase extends EasingFunction implements IEasingFunction {
  4863. /** Defines the number of bounces */
  4864. bounces: number;
  4865. /** Defines the amplitude of the bounce */
  4866. bounciness: number;
  4867. /**
  4868. * Instantiates a bounce easing
  4869. * @see https://easings.net/#easeInBounce
  4870. * @param bounces Defines the number of bounces
  4871. * @param bounciness Defines the amplitude of the bounce
  4872. */
  4873. constructor(
  4874. /** Defines the number of bounces */
  4875. bounces?: number,
  4876. /** Defines the amplitude of the bounce */
  4877. bounciness?: number);
  4878. /** @hidden */
  4879. easeInCore(gradient: number): number;
  4880. }
  4881. /**
  4882. * Easing function with a power of 3 shape (see link below).
  4883. * @see https://easings.net/#easeInCubic
  4884. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4885. */
  4886. class CubicEase extends EasingFunction implements IEasingFunction {
  4887. /** @hidden */
  4888. easeInCore(gradient: number): number;
  4889. }
  4890. /**
  4891. * Easing function with an elastic shape (see link below).
  4892. * @see https://easings.net/#easeInElastic
  4893. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4894. */
  4895. class ElasticEase extends EasingFunction implements IEasingFunction {
  4896. /** Defines the number of oscillations*/
  4897. oscillations: number;
  4898. /** Defines the amplitude of the oscillations*/
  4899. springiness: number;
  4900. /**
  4901. * Instantiates an elastic easing function
  4902. * @see https://easings.net/#easeInElastic
  4903. * @param oscillations Defines the number of oscillations
  4904. * @param springiness Defines the amplitude of the oscillations
  4905. */
  4906. constructor(
  4907. /** Defines the number of oscillations*/
  4908. oscillations?: number,
  4909. /** Defines the amplitude of the oscillations*/
  4910. springiness?: number);
  4911. /** @hidden */
  4912. easeInCore(gradient: number): number;
  4913. }
  4914. /**
  4915. * Easing function with an exponential shape (see link below).
  4916. * @see https://easings.net/#easeInExpo
  4917. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4918. */
  4919. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4920. /** Defines the exponent of the function */
  4921. exponent: number;
  4922. /**
  4923. * Instantiates an exponential easing function
  4924. * @see https://easings.net/#easeInExpo
  4925. * @param exponent Defines the exponent of the function
  4926. */
  4927. constructor(
  4928. /** Defines the exponent of the function */
  4929. exponent?: number);
  4930. /** @hidden */
  4931. easeInCore(gradient: number): number;
  4932. }
  4933. /**
  4934. * Easing function with a power shape (see link below).
  4935. * @see https://easings.net/#easeInQuad
  4936. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4937. */
  4938. class PowerEase extends EasingFunction implements IEasingFunction {
  4939. /** Defines the power of the function */
  4940. power: number;
  4941. /**
  4942. * Instantiates an power base easing function
  4943. * @see https://easings.net/#easeInQuad
  4944. * @param power Defines the power of the function
  4945. */
  4946. constructor(
  4947. /** Defines the power of the function */
  4948. power?: number);
  4949. /** @hidden */
  4950. easeInCore(gradient: number): number;
  4951. }
  4952. /**
  4953. * Easing function with a power of 2 shape (see link below).
  4954. * @see https://easings.net/#easeInQuad
  4955. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4956. */
  4957. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4958. /** @hidden */
  4959. easeInCore(gradient: number): number;
  4960. }
  4961. /**
  4962. * Easing function with a power of 4 shape (see link below).
  4963. * @see https://easings.net/#easeInQuart
  4964. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4965. */
  4966. class QuarticEase extends EasingFunction implements IEasingFunction {
  4967. /** @hidden */
  4968. easeInCore(gradient: number): number;
  4969. }
  4970. /**
  4971. * Easing function with a power of 5 shape (see link below).
  4972. * @see https://easings.net/#easeInQuint
  4973. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4974. */
  4975. class QuinticEase extends EasingFunction implements IEasingFunction {
  4976. /** @hidden */
  4977. easeInCore(gradient: number): number;
  4978. }
  4979. /**
  4980. * Easing function with a sin shape (see link below).
  4981. * @see https://easings.net/#easeInSine
  4982. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4983. */
  4984. class SineEase extends EasingFunction implements IEasingFunction {
  4985. /** @hidden */
  4986. easeInCore(gradient: number): number;
  4987. }
  4988. /**
  4989. * Easing function with a bezier shape (see link below).
  4990. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4991. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4992. */
  4993. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4994. /** Defines the x component of the start tangent in the bezier curve */
  4995. x1: number;
  4996. /** Defines the y component of the start tangent in the bezier curve */
  4997. y1: number;
  4998. /** Defines the x component of the end tangent in the bezier curve */
  4999. x2: number;
  5000. /** Defines the y component of the end tangent in the bezier curve */
  5001. y2: number;
  5002. /**
  5003. * Instantiates a bezier function
  5004. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5005. * @param x1 Defines the x component of the start tangent in the bezier curve
  5006. * @param y1 Defines the y component of the start tangent in the bezier curve
  5007. * @param x2 Defines the x component of the end tangent in the bezier curve
  5008. * @param y2 Defines the y component of the end tangent in the bezier curve
  5009. */
  5010. constructor(
  5011. /** Defines the x component of the start tangent in the bezier curve */
  5012. x1?: number,
  5013. /** Defines the y component of the start tangent in the bezier curve */
  5014. y1?: number,
  5015. /** Defines the x component of the end tangent in the bezier curve */
  5016. x2?: number,
  5017. /** Defines the y component of the end tangent in the bezier curve */
  5018. y2?: number);
  5019. /** @hidden */
  5020. easeInCore(gradient: number): number;
  5021. }
  5022. }
  5023. declare module BABYLON {
  5024. /**
  5025. * Defines a runtime animation
  5026. */
  5027. class RuntimeAnimation {
  5028. private _events;
  5029. /**
  5030. * The current frame of the runtime animation
  5031. */
  5032. private _currentFrame;
  5033. /**
  5034. * The animation used by the runtime animation
  5035. */
  5036. private _animation;
  5037. /**
  5038. * The target of the runtime animation
  5039. */
  5040. private _target;
  5041. /**
  5042. * The initiating animatable
  5043. */
  5044. private _host;
  5045. /**
  5046. * The original value of the runtime animation
  5047. */
  5048. private _originalValue;
  5049. /**
  5050. * The original blend value of the runtime animation
  5051. */
  5052. private _originalBlendValue;
  5053. /**
  5054. * The offsets cache of the runtime animation
  5055. */
  5056. private _offsetsCache;
  5057. /**
  5058. * The high limits cache of the runtime animation
  5059. */
  5060. private _highLimitsCache;
  5061. /**
  5062. * Specifies if the runtime animation has been stopped
  5063. */
  5064. private _stopped;
  5065. /**
  5066. * The blending factor of the runtime animation
  5067. */
  5068. private _blendingFactor;
  5069. /**
  5070. * The BabylonJS scene
  5071. */
  5072. private _scene;
  5073. /**
  5074. * The current value of the runtime animation
  5075. */
  5076. private _currentValue;
  5077. /** @hidden */
  5078. _workValue: any;
  5079. /**
  5080. * The active target of the runtime animation
  5081. */
  5082. private _activeTarget;
  5083. /**
  5084. * The target path of the runtime animation
  5085. */
  5086. private _targetPath;
  5087. /**
  5088. * The weight of the runtime animation
  5089. */
  5090. private _weight;
  5091. /**
  5092. * The ratio offset of the runtime animation
  5093. */
  5094. private _ratioOffset;
  5095. /**
  5096. * The previous delay of the runtime animation
  5097. */
  5098. private _previousDelay;
  5099. /**
  5100. * The previous ratio of the runtime animation
  5101. */
  5102. private _previousRatio;
  5103. /**
  5104. * Gets the current frame of the runtime animation
  5105. */
  5106. readonly currentFrame: number;
  5107. /**
  5108. * Gets the weight of the runtime animation
  5109. */
  5110. readonly weight: number;
  5111. /**
  5112. * Gets the current value of the runtime animation
  5113. */
  5114. readonly currentValue: any;
  5115. /**
  5116. * Gets the target path of the runtime animation
  5117. */
  5118. readonly targetPath: string;
  5119. /**
  5120. * Gets the actual target of the runtime animation
  5121. */
  5122. readonly target: any;
  5123. /**
  5124. * Create a new RuntimeAnimation object
  5125. * @param target defines the target of the animation
  5126. * @param animation defines the source animation object
  5127. * @param scene defines the hosting scene
  5128. * @param host defines the initiating Animatable
  5129. */
  5130. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  5131. /**
  5132. * Gets the animation from the runtime animation
  5133. */
  5134. readonly animation: Animation;
  5135. /**
  5136. * Resets the runtime animation to the beginning
  5137. * @param restoreOriginal defines whether to restore the target property to the original value
  5138. */
  5139. reset(restoreOriginal?: boolean): void;
  5140. /**
  5141. * Specifies if the runtime animation is stopped
  5142. * @returns Boolean specifying if the runtime animation is stopped
  5143. */
  5144. isStopped(): boolean;
  5145. /**
  5146. * Disposes of the runtime animation
  5147. */
  5148. dispose(): void;
  5149. /**
  5150. * Interpolates the animation from the current frame
  5151. * @param currentFrame The frame to interpolate the animation to
  5152. * @param repeatCount The number of times that the animation should loop
  5153. * @param loopMode The type of looping mode to use
  5154. * @param offsetValue Animation offset value
  5155. * @param highLimitValue The high limit value
  5156. * @returns The interpolated value
  5157. */
  5158. private _interpolate;
  5159. /**
  5160. * Apply the interpolated value to the target
  5161. * @param currentValue defines the value computed by the animation
  5162. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5163. */
  5164. setValue(currentValue: any, weight?: number): void;
  5165. private _setValue;
  5166. /**
  5167. * Gets the loop pmode of the runtime animation
  5168. * @returns Loop Mode
  5169. */
  5170. private _getCorrectLoopMode;
  5171. /**
  5172. * Move the current animation to a given frame
  5173. * @param frame defines the frame to move to
  5174. */
  5175. goToFrame(frame: number): void;
  5176. /**
  5177. * @hidden Internal use only
  5178. */
  5179. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  5180. /**
  5181. * Execute the current animation
  5182. * @param delay defines the delay to add to the current frame
  5183. * @param from defines the lower bound of the animation range
  5184. * @param to defines the upper bound of the animation range
  5185. * @param loop defines if the current animation must loop
  5186. * @param speedRatio defines the current speed ratio
  5187. * @param weight defines the weight of the animation (default is -1 so no weight)
  5188. * @param onLoop optional callback called when animation loops
  5189. * @returns a boolean indicating if the animation is running
  5190. */
  5191. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  5192. }
  5193. }
  5194. declare module BABYLON {
  5195. /**
  5196. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5198. */
  5199. class Analyser {
  5200. /**
  5201. * Gets or sets the smoothing
  5202. * @ignorenaming
  5203. */
  5204. SMOOTHING: number;
  5205. /**
  5206. * Gets or sets the FFT table size
  5207. * @ignorenaming
  5208. */
  5209. FFT_SIZE: number;
  5210. /**
  5211. * Gets or sets the bar graph amplitude
  5212. * @ignorenaming
  5213. */
  5214. BARGRAPHAMPLITUDE: number;
  5215. /**
  5216. * Gets or sets the position of the debug canvas
  5217. * @ignorenaming
  5218. */
  5219. DEBUGCANVASPOS: {
  5220. x: number;
  5221. y: number;
  5222. };
  5223. /**
  5224. * Gets or sets the debug canvas size
  5225. * @ignorenaming
  5226. */
  5227. DEBUGCANVASSIZE: {
  5228. width: number;
  5229. height: number;
  5230. };
  5231. private _byteFreqs;
  5232. private _byteTime;
  5233. private _floatFreqs;
  5234. private _webAudioAnalyser;
  5235. private _debugCanvas;
  5236. private _debugCanvasContext;
  5237. private _scene;
  5238. private _registerFunc;
  5239. private _audioEngine;
  5240. /**
  5241. * Creates a new analyser
  5242. * @param scene defines hosting scene
  5243. */
  5244. constructor(scene: Scene);
  5245. /**
  5246. * Get the number of data values you will have to play with for the visualization
  5247. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5248. * @returns a number
  5249. */
  5250. getFrequencyBinCount(): number;
  5251. /**
  5252. * Gets the current frequency data as a byte array
  5253. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5254. * @returns a Uint8Array
  5255. */
  5256. getByteFrequencyData(): Uint8Array;
  5257. /**
  5258. * Gets the current waveform as a byte array
  5259. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5260. * @returns a Uint8Array
  5261. */
  5262. getByteTimeDomainData(): Uint8Array;
  5263. /**
  5264. * Gets the current frequency data as a float array
  5265. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5266. * @returns a Float32Array
  5267. */
  5268. getFloatFrequencyData(): Float32Array;
  5269. /**
  5270. * Renders the debug canvas
  5271. */
  5272. drawDebugCanvas(): void;
  5273. /**
  5274. * Stops rendering the debug canvas and removes it
  5275. */
  5276. stopDebugCanvas(): void;
  5277. /**
  5278. * Connects two audio nodes
  5279. * @param inputAudioNode defines first node to connect
  5280. * @param outputAudioNode defines second node to connect
  5281. */
  5282. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  5283. /**
  5284. * Releases all associated resources
  5285. */
  5286. dispose(): void;
  5287. }
  5288. }
  5289. declare module BABYLON {
  5290. /**
  5291. * This represents an audio engine and it is responsible
  5292. * to play, synchronize and analyse sounds throughout the application.
  5293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5294. */
  5295. interface IAudioEngine extends IDisposable {
  5296. /**
  5297. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5298. */
  5299. readonly canUseWebAudio: boolean;
  5300. /**
  5301. * Gets the current AudioContext if available.
  5302. */
  5303. readonly audioContext: Nullable<AudioContext>;
  5304. /**
  5305. * The master gain node defines the global audio volume of your audio engine.
  5306. */
  5307. readonly masterGain: GainNode;
  5308. /**
  5309. * Gets whether or not mp3 are supported by your browser.
  5310. */
  5311. readonly isMP3supported: boolean;
  5312. /**
  5313. * Gets whether or not ogg are supported by your browser.
  5314. */
  5315. readonly isOGGsupported: boolean;
  5316. /**
  5317. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5318. * @ignoreNaming
  5319. */
  5320. WarnedWebAudioUnsupported: boolean;
  5321. /**
  5322. * Defines if the audio engine relies on a custom unlocked button.
  5323. * In this case, the embedded button will not be displayed.
  5324. */
  5325. useCustomUnlockedButton: boolean;
  5326. /**
  5327. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  5328. */
  5329. readonly unlocked: boolean;
  5330. /**
  5331. * Event raised when audio has been unlocked on the browser.
  5332. */
  5333. onAudioUnlockedObservable: Observable<AudioEngine>;
  5334. /**
  5335. * Event raised when audio has been locked on the browser.
  5336. */
  5337. onAudioLockedObservable: Observable<AudioEngine>;
  5338. /**
  5339. * Flags the audio engine in Locked state.
  5340. * This happens due to new browser policies preventing audio to autoplay.
  5341. */
  5342. lock(): void;
  5343. /**
  5344. * Unlocks the audio engine once a user action has been done on the dom.
  5345. * This is helpful to resume play once browser policies have been satisfied.
  5346. */
  5347. unlock(): void;
  5348. }
  5349. /**
  5350. * This represents the default audio engine used in babylon.
  5351. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5352. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5353. */
  5354. class AudioEngine implements IAudioEngine {
  5355. private _audioContext;
  5356. private _audioContextInitialized;
  5357. private _muteButton;
  5358. private _hostElement;
  5359. /**
  5360. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5361. */
  5362. canUseWebAudio: boolean;
  5363. /**
  5364. * The master gain node defines the global audio volume of your audio engine.
  5365. */
  5366. masterGain: GainNode;
  5367. /**
  5368. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5369. * @ignoreNaming
  5370. */
  5371. WarnedWebAudioUnsupported: boolean;
  5372. /**
  5373. * Gets whether or not mp3 are supported by your browser.
  5374. */
  5375. isMP3supported: boolean;
  5376. /**
  5377. * Gets whether or not ogg are supported by your browser.
  5378. */
  5379. isOGGsupported: boolean;
  5380. /**
  5381. * Gets whether audio has been unlocked on the device.
  5382. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5383. * a user interaction has happened.
  5384. */
  5385. unlocked: boolean;
  5386. /**
  5387. * Defines if the audio engine relies on a custom unlocked button.
  5388. * In this case, the embedded button will not be displayed.
  5389. */
  5390. useCustomUnlockedButton: boolean;
  5391. /**
  5392. * Event raised when audio has been unlocked on the browser.
  5393. */
  5394. onAudioUnlockedObservable: Observable<AudioEngine>;
  5395. /**
  5396. * Event raised when audio has been locked on the browser.
  5397. */
  5398. onAudioLockedObservable: Observable<AudioEngine>;
  5399. /**
  5400. * Gets the current AudioContext if available.
  5401. */
  5402. readonly audioContext: Nullable<AudioContext>;
  5403. private _connectedAnalyser;
  5404. /**
  5405. * Instantiates a new audio engine.
  5406. *
  5407. * There should be only one per page as some browsers restrict the number
  5408. * of audio contexts you can create.
  5409. * @param hostElement defines the host element where to display the mute icon if necessary
  5410. */
  5411. constructor(hostElement?: Nullable<HTMLElement>);
  5412. /**
  5413. * Flags the audio engine in Locked state.
  5414. * This happens due to new browser policies preventing audio to autoplay.
  5415. */
  5416. lock(): void;
  5417. /**
  5418. * Unlocks the audio engine once a user action has been done on the dom.
  5419. * This is helpful to resume play once browser policies have been satisfied.
  5420. */
  5421. unlock(): void;
  5422. private _resumeAudioContext;
  5423. private _initializeAudioContext;
  5424. private _tryToRun;
  5425. private _triggerRunningState;
  5426. private _triggerSuspendedState;
  5427. private _displayMuteButton;
  5428. private _moveButtonToTopLeft;
  5429. private _onResize;
  5430. private _hideMuteButton;
  5431. /**
  5432. * Destroy and release the resources associated with the audio ccontext.
  5433. */
  5434. dispose(): void;
  5435. /**
  5436. * Gets the global volume sets on the master gain.
  5437. * @returns the global volume if set or -1 otherwise
  5438. */
  5439. getGlobalVolume(): number;
  5440. /**
  5441. * Sets the global volume of your experience (sets on the master gain).
  5442. * @param newVolume Defines the new global volume of the application
  5443. */
  5444. setGlobalVolume(newVolume: number): void;
  5445. /**
  5446. * Connect the audio engine to an audio analyser allowing some amazing
  5447. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5449. * @param analyser The analyser to connect to the engine
  5450. */
  5451. connectToAnalyser(analyser: Analyser): void;
  5452. }
  5453. }
  5454. declare module BABYLON {
  5455. interface AbstractScene {
  5456. /**
  5457. * The list of sounds used in the scene.
  5458. */
  5459. sounds: Nullable<Array<Sound>>;
  5460. }
  5461. interface Scene {
  5462. /**
  5463. * @hidden
  5464. * Backing field
  5465. */
  5466. _mainSoundTrack: SoundTrack;
  5467. /**
  5468. * The main sound track played by the scene.
  5469. * It cotains your primary collection of sounds.
  5470. */
  5471. mainSoundTrack: SoundTrack;
  5472. /**
  5473. * The list of sound tracks added to the scene
  5474. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5475. */
  5476. soundTracks: Nullable<Array<SoundTrack>>;
  5477. /**
  5478. * Gets a sound using a given name
  5479. * @param name defines the name to search for
  5480. * @return the found sound or null if not found at all.
  5481. */
  5482. getSoundByName(name: string): Nullable<Sound>;
  5483. /**
  5484. * Gets or sets if audio support is enabled
  5485. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5486. */
  5487. audioEnabled: boolean;
  5488. /**
  5489. * Gets or sets if audio will be output to headphones
  5490. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5491. */
  5492. headphone: boolean;
  5493. }
  5494. /**
  5495. * Defines the sound scene component responsible to manage any sounds
  5496. * in a given scene.
  5497. */
  5498. class AudioSceneComponent implements ISceneSerializableComponent {
  5499. /**
  5500. * The component name helpfull to identify the component in the list of scene components.
  5501. */
  5502. readonly name: string;
  5503. /**
  5504. * The scene the component belongs to.
  5505. */
  5506. scene: Scene;
  5507. private _audioEnabled;
  5508. /**
  5509. * Gets whether audio is enabled or not.
  5510. * Please use related enable/disable method to switch state.
  5511. */
  5512. readonly audioEnabled: boolean;
  5513. private _headphone;
  5514. /**
  5515. * Gets whether audio is outputing to headphone or not.
  5516. * Please use the according Switch methods to change output.
  5517. */
  5518. readonly headphone: boolean;
  5519. /**
  5520. * Creates a new instance of the component for the given scene
  5521. * @param scene Defines the scene to register the component in
  5522. */
  5523. constructor(scene: Scene);
  5524. /**
  5525. * Registers the component in a given scene
  5526. */
  5527. register(): void;
  5528. /**
  5529. * Rebuilds the elements related to this component in case of
  5530. * context lost for instance.
  5531. */
  5532. rebuild(): void;
  5533. /**
  5534. * Serializes the component data to the specified json object
  5535. * @param serializationObject The object to serialize to
  5536. */
  5537. serialize(serializationObject: any): void;
  5538. /**
  5539. * Adds all the element from the container to the scene
  5540. * @param container the container holding the elements
  5541. */
  5542. addFromContainer(container: AbstractScene): void;
  5543. /**
  5544. * Removes all the elements in the container from the scene
  5545. * @param container contains the elements to remove
  5546. */
  5547. removeFromContainer(container: AbstractScene): void;
  5548. /**
  5549. * Disposes the component and the associated ressources.
  5550. */
  5551. dispose(): void;
  5552. /**
  5553. * Disables audio in the associated scene.
  5554. */
  5555. disableAudio(): void;
  5556. /**
  5557. * Enables audio in the associated scene.
  5558. */
  5559. enableAudio(): void;
  5560. /**
  5561. * Switch audio to headphone output.
  5562. */
  5563. switchAudioModeForHeadphones(): void;
  5564. /**
  5565. * Switch audio to normal speakers.
  5566. */
  5567. switchAudioModeForNormalSpeakers(): void;
  5568. private _afterRender;
  5569. }
  5570. }
  5571. declare module BABYLON {
  5572. /**
  5573. * Defines a sound that can be played in the application.
  5574. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  5575. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5576. */
  5577. class Sound {
  5578. /**
  5579. * The name of the sound in the scene.
  5580. */
  5581. name: string;
  5582. /**
  5583. * Does the sound autoplay once loaded.
  5584. */
  5585. autoplay: boolean;
  5586. /**
  5587. * Does the sound loop after it finishes playing once.
  5588. */
  5589. loop: boolean;
  5590. /**
  5591. * Does the sound use a custom attenuation curve to simulate the falloff
  5592. * happening when the source gets further away from the camera.
  5593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5594. */
  5595. useCustomAttenuation: boolean;
  5596. /**
  5597. * The sound track id this sound belongs to.
  5598. */
  5599. soundTrackId: number;
  5600. /**
  5601. * Is this sound currently played.
  5602. */
  5603. isPlaying: boolean;
  5604. /**
  5605. * Is this sound currently paused.
  5606. */
  5607. isPaused: boolean;
  5608. /**
  5609. * Does this sound enables spatial sound.
  5610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5611. */
  5612. spatialSound: boolean;
  5613. /**
  5614. * Define the reference distance the sound should be heard perfectly.
  5615. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5616. */
  5617. refDistance: number;
  5618. /**
  5619. * Define the roll off factor of spatial sounds.
  5620. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5621. */
  5622. rolloffFactor: number;
  5623. /**
  5624. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  5625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5626. */
  5627. maxDistance: number;
  5628. /**
  5629. * Define the distance attenuation model the sound will follow.
  5630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5631. */
  5632. distanceModel: string;
  5633. /**
  5634. * @hidden
  5635. * Back Compat
  5636. **/
  5637. onended: () => any;
  5638. /**
  5639. * Observable event when the current playing sound finishes.
  5640. */
  5641. onEndedObservable: Observable<Sound>;
  5642. private _panningModel;
  5643. private _playbackRate;
  5644. private _streaming;
  5645. private _startTime;
  5646. private _startOffset;
  5647. private _position;
  5648. /** @hidden */
  5649. _positionInEmitterSpace: boolean;
  5650. private _localDirection;
  5651. private _volume;
  5652. private _isReadyToPlay;
  5653. private _isDirectional;
  5654. private _readyToPlayCallback;
  5655. private _audioBuffer;
  5656. private _soundSource;
  5657. private _streamingSource;
  5658. private _soundPanner;
  5659. private _soundGain;
  5660. private _inputAudioNode;
  5661. private _outputAudioNode;
  5662. private _coneInnerAngle;
  5663. private _coneOuterAngle;
  5664. private _coneOuterGain;
  5665. private _scene;
  5666. private _connectedTransformNode;
  5667. private _customAttenuationFunction;
  5668. private _registerFunc;
  5669. private _isOutputConnected;
  5670. private _htmlAudioElement;
  5671. private _urlType;
  5672. /**
  5673. * Create a sound and attach it to a scene
  5674. * @param name Name of your sound
  5675. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  5676. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  5677. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  5678. */
  5679. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  5680. /**
  5681. * Release the sound and its associated resources
  5682. */
  5683. dispose(): void;
  5684. /**
  5685. * Gets if the sounds is ready to be played or not.
  5686. * @returns true if ready, otherwise false
  5687. */
  5688. isReady(): boolean;
  5689. private _soundLoaded;
  5690. /**
  5691. * Sets the data of the sound from an audiobuffer
  5692. * @param audioBuffer The audioBuffer containing the data
  5693. */
  5694. setAudioBuffer(audioBuffer: AudioBuffer): void;
  5695. /**
  5696. * Updates the current sounds options such as maxdistance, loop...
  5697. * @param options A JSON object containing values named as the object properties
  5698. */
  5699. updateOptions(options: any): void;
  5700. private _createSpatialParameters;
  5701. private _updateSpatialParameters;
  5702. /**
  5703. * Switch the panning model to HRTF:
  5704. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5705. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5706. */
  5707. switchPanningModelToHRTF(): void;
  5708. /**
  5709. * Switch the panning model to Equal Power:
  5710. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5711. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5712. */
  5713. switchPanningModelToEqualPower(): void;
  5714. private _switchPanningModel;
  5715. /**
  5716. * Connect this sound to a sound track audio node like gain...
  5717. * @param soundTrackAudioNode the sound track audio node to connect to
  5718. */
  5719. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  5720. /**
  5721. * Transform this sound into a directional source
  5722. * @param coneInnerAngle Size of the inner cone in degree
  5723. * @param coneOuterAngle Size of the outer cone in degree
  5724. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  5725. */
  5726. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  5727. /**
  5728. * Gets or sets the inner angle for the directional cone.
  5729. */
  5730. /**
  5731. * Gets or sets the inner angle for the directional cone.
  5732. */
  5733. directionalConeInnerAngle: number;
  5734. /**
  5735. * Gets or sets the outer angle for the directional cone.
  5736. */
  5737. /**
  5738. * Gets or sets the outer angle for the directional cone.
  5739. */
  5740. directionalConeOuterAngle: number;
  5741. /**
  5742. * Sets the position of the emitter if spatial sound is enabled
  5743. * @param newPosition Defines the new posisiton
  5744. */
  5745. setPosition(newPosition: Vector3): void;
  5746. /**
  5747. * Sets the local direction of the emitter if spatial sound is enabled
  5748. * @param newLocalDirection Defines the new local direction
  5749. */
  5750. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  5751. private _updateDirection;
  5752. /** @hidden */
  5753. updateDistanceFromListener(): void;
  5754. /**
  5755. * Sets a new custom attenuation function for the sound.
  5756. * @param callback Defines the function used for the attenuation
  5757. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5758. */
  5759. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  5760. /**
  5761. * Play the sound
  5762. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  5763. * @param offset (optional) Start the sound setting it at a specific time
  5764. */
  5765. play(time?: number, offset?: number): void;
  5766. private _onended;
  5767. /**
  5768. * Stop the sound
  5769. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  5770. */
  5771. stop(time?: number): void;
  5772. /**
  5773. * Put the sound in pause
  5774. */
  5775. pause(): void;
  5776. /**
  5777. * Sets a dedicated volume for this sounds
  5778. * @param newVolume Define the new volume of the sound
  5779. * @param time Define in how long the sound should be at this value
  5780. */
  5781. setVolume(newVolume: number, time?: number): void;
  5782. /**
  5783. * Set the sound play back rate
  5784. * @param newPlaybackRate Define the playback rate the sound should be played at
  5785. */
  5786. setPlaybackRate(newPlaybackRate: number): void;
  5787. /**
  5788. * Gets the volume of the sound.
  5789. * @returns the volume of the sound
  5790. */
  5791. getVolume(): number;
  5792. /**
  5793. * Attach the sound to a dedicated mesh
  5794. * @param transformNode The transform node to connect the sound with
  5795. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5796. */
  5797. attachToMesh(transformNode: TransformNode): void;
  5798. /**
  5799. * Detach the sound from the previously attached mesh
  5800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5801. */
  5802. detachFromMesh(): void;
  5803. private _onRegisterAfterWorldMatrixUpdate;
  5804. /**
  5805. * Clone the current sound in the scene.
  5806. * @returns the new sound clone
  5807. */
  5808. clone(): Nullable<Sound>;
  5809. /**
  5810. * Gets the current underlying audio buffer containing the data
  5811. * @returns the audio buffer
  5812. */
  5813. getAudioBuffer(): Nullable<AudioBuffer>;
  5814. /**
  5815. * Serializes the Sound in a JSON representation
  5816. * @returns the JSON representation of the sound
  5817. */
  5818. serialize(): any;
  5819. /**
  5820. * Parse a JSON representation of a sound to innstantiate in a given scene
  5821. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  5822. * @param scene Define the scene the new parsed sound should be created in
  5823. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  5824. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  5825. * @returns the newly parsed sound
  5826. */
  5827. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  5828. }
  5829. }
  5830. declare module BABYLON {
  5831. /**
  5832. * Options allowed during the creation of a sound track.
  5833. */
  5834. interface ISoundTrackOptions {
  5835. /**
  5836. * The volume the sound track should take during creation
  5837. */
  5838. volume?: number;
  5839. /**
  5840. * Define if the sound track is the main sound track of the scene
  5841. */
  5842. mainTrack?: boolean;
  5843. }
  5844. /**
  5845. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  5846. * It will be also used in a future release to apply effects on a specific track.
  5847. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5848. */
  5849. class SoundTrack {
  5850. /**
  5851. * The unique identifier of the sound track in the scene.
  5852. */
  5853. id: number;
  5854. /**
  5855. * The list of sounds included in the sound track.
  5856. */
  5857. soundCollection: Array<Sound>;
  5858. private _outputAudioNode;
  5859. private _scene;
  5860. private _isMainTrack;
  5861. private _connectedAnalyser;
  5862. private _options;
  5863. private _isInitialized;
  5864. /**
  5865. * Creates a new sound track.
  5866. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5867. * @param scene Define the scene the sound track belongs to
  5868. * @param options
  5869. */
  5870. constructor(scene: Scene, options?: ISoundTrackOptions);
  5871. private _initializeSoundTrackAudioGraph;
  5872. /**
  5873. * Release the sound track and its associated resources
  5874. */
  5875. dispose(): void;
  5876. /**
  5877. * Adds a sound to this sound track
  5878. * @param sound define the cound to add
  5879. * @ignoreNaming
  5880. */
  5881. AddSound(sound: Sound): void;
  5882. /**
  5883. * Removes a sound to this sound track
  5884. * @param sound define the cound to remove
  5885. * @ignoreNaming
  5886. */
  5887. RemoveSound(sound: Sound): void;
  5888. /**
  5889. * Set a global volume for the full sound track.
  5890. * @param newVolume Define the new volume of the sound track
  5891. */
  5892. setVolume(newVolume: number): void;
  5893. /**
  5894. * Switch the panning model to HRTF:
  5895. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5896. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5897. */
  5898. switchPanningModelToHRTF(): void;
  5899. /**
  5900. * Switch the panning model to Equal Power:
  5901. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5903. */
  5904. switchPanningModelToEqualPower(): void;
  5905. /**
  5906. * Connect the sound track to an audio analyser allowing some amazing
  5907. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5908. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5909. * @param analyser The analyser to connect to the engine
  5910. */
  5911. connectToAnalyser(analyser: Analyser): void;
  5912. }
  5913. }
  5914. declare module BABYLON {
  5915. /**
  5916. * Wraps one or more Sound objects and selects one with random weight for playback.
  5917. */
  5918. class WeightedSound {
  5919. /** When true a Sound will be selected and played when the current playing Sound completes. */
  5920. loop: boolean;
  5921. private _coneInnerAngle;
  5922. private _coneOuterAngle;
  5923. private _volume;
  5924. /** A Sound is currently playing. */
  5925. isPlaying: boolean;
  5926. /** A Sound is currently paused. */
  5927. isPaused: boolean;
  5928. private _sounds;
  5929. private _weights;
  5930. private _currentIndex?;
  5931. /**
  5932. * Creates a new WeightedSound from the list of sounds given.
  5933. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  5934. * @param sounds Array of Sounds that will be selected from.
  5935. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  5936. */
  5937. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  5938. /**
  5939. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  5940. */
  5941. /**
  5942. * The size of cone in degress for a directional sound in which there will be no attenuation.
  5943. */
  5944. directionalConeInnerAngle: number;
  5945. /**
  5946. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5947. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5948. */
  5949. /**
  5950. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5951. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5952. */
  5953. directionalConeOuterAngle: number;
  5954. /**
  5955. * Playback volume.
  5956. */
  5957. /**
  5958. * Playback volume.
  5959. */
  5960. volume: number;
  5961. private _onended;
  5962. /**
  5963. * Suspend playback
  5964. */
  5965. pause(): void;
  5966. /**
  5967. * Stop playback
  5968. */
  5969. stop(): void;
  5970. /**
  5971. * Start playback.
  5972. * @param startOffset Position the clip head at a specific time in seconds.
  5973. */
  5974. play(startOffset?: number): void;
  5975. }
  5976. }
  5977. declare module BABYLON {
  5978. /**
  5979. * Interface used to define a behavior
  5980. */
  5981. interface Behavior<T> {
  5982. /** gets or sets behavior's name */
  5983. name: string;
  5984. /**
  5985. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5986. */
  5987. init(): void;
  5988. /**
  5989. * Called when the behavior is attached to a target
  5990. * @param target defines the target where the behavior is attached to
  5991. */
  5992. attach(target: T): void;
  5993. /**
  5994. * Called when the behavior is detached from its target
  5995. */
  5996. detach(): void;
  5997. }
  5998. /**
  5999. * Interface implemented by classes supporting behaviors
  6000. */
  6001. interface IBehaviorAware<T> {
  6002. /**
  6003. * Attach a behavior
  6004. * @param behavior defines the behavior to attach
  6005. * @returns the current host
  6006. */
  6007. addBehavior(behavior: Behavior<T>): T;
  6008. /**
  6009. * Remove a behavior from the current object
  6010. * @param behavior defines the behavior to detach
  6011. * @returns the current host
  6012. */
  6013. removeBehavior(behavior: Behavior<T>): T;
  6014. /**
  6015. * Gets a behavior using its name to search
  6016. * @param name defines the name to search
  6017. * @returns the behavior or null if not found
  6018. */
  6019. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6020. }
  6021. }
  6022. declare module BABYLON {
  6023. /**
  6024. * Class used to store bone information
  6025. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6026. */
  6027. class Bone extends Node {
  6028. /**
  6029. * defines the bone name
  6030. */
  6031. name: string;
  6032. private static _tmpVecs;
  6033. private static _tmpQuat;
  6034. private static _tmpMats;
  6035. /**
  6036. * Gets the list of child bones
  6037. */
  6038. children: Bone[];
  6039. /** Gets the animations associated with this bone */
  6040. animations: Animation[];
  6041. /**
  6042. * Gets or sets bone length
  6043. */
  6044. length: number;
  6045. /**
  6046. * @hidden Internal only
  6047. * Set this value to map this bone to a different index in the transform matrices
  6048. * Set this value to -1 to exclude the bone from the transform matrices
  6049. */
  6050. _index: Nullable<number>;
  6051. private _skeleton;
  6052. private _localMatrix;
  6053. private _restPose;
  6054. private _baseMatrix;
  6055. private _absoluteTransform;
  6056. private _invertedAbsoluteTransform;
  6057. private _parent;
  6058. private _scalingDeterminant;
  6059. private _worldTransform;
  6060. private _localScaling;
  6061. private _localRotation;
  6062. private _localPosition;
  6063. private _needToDecompose;
  6064. private _needToCompose;
  6065. /** @hidden */
  6066. _linkedTransformNode: Nullable<TransformNode>;
  6067. /** @hidden */
  6068. /** @hidden */
  6069. _matrix: Matrix;
  6070. /**
  6071. * Create a new bone
  6072. * @param name defines the bone name
  6073. * @param skeleton defines the parent skeleton
  6074. * @param parentBone defines the parent (can be null if the bone is the root)
  6075. * @param localMatrix defines the local matrix
  6076. * @param restPose defines the rest pose matrix
  6077. * @param baseMatrix defines the base matrix
  6078. * @param index defines index of the bone in the hiearchy
  6079. */
  6080. constructor(
  6081. /**
  6082. * defines the bone name
  6083. */
  6084. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  6085. /**
  6086. * Gets the parent skeleton
  6087. * @returns a skeleton
  6088. */
  6089. getSkeleton(): Skeleton;
  6090. /**
  6091. * Gets parent bone
  6092. * @returns a bone or null if the bone is the root of the bone hierarchy
  6093. */
  6094. getParent(): Nullable<Bone>;
  6095. /**
  6096. * Sets the parent bone
  6097. * @param parent defines the parent (can be null if the bone is the root)
  6098. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6099. */
  6100. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  6101. /**
  6102. * Gets the local matrix
  6103. * @returns a matrix
  6104. */
  6105. getLocalMatrix(): Matrix;
  6106. /**
  6107. * Gets the base matrix (initial matrix which remains unchanged)
  6108. * @returns a matrix
  6109. */
  6110. getBaseMatrix(): Matrix;
  6111. /**
  6112. * Gets the rest pose matrix
  6113. * @returns a matrix
  6114. */
  6115. getRestPose(): Matrix;
  6116. /**
  6117. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  6118. */
  6119. getWorldMatrix(): Matrix;
  6120. /**
  6121. * Sets the local matrix to rest pose matrix
  6122. */
  6123. returnToRest(): void;
  6124. /**
  6125. * Gets the inverse of the absolute transform matrix.
  6126. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  6127. * @returns a matrix
  6128. */
  6129. getInvertedAbsoluteTransform(): Matrix;
  6130. /**
  6131. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  6132. * @returns a matrix
  6133. */
  6134. getAbsoluteTransform(): Matrix;
  6135. /**
  6136. * Links with the given transform node.
  6137. * The local matrix of this bone is copied from the transform node every frame.
  6138. * @param transformNode defines the transform node to link to
  6139. */
  6140. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  6141. /** Gets or sets current position (in local space) */
  6142. position: Vector3;
  6143. /** Gets or sets current rotation (in local space) */
  6144. rotation: Vector3;
  6145. /** Gets or sets current rotation quaternion (in local space) */
  6146. rotationQuaternion: Quaternion;
  6147. /** Gets or sets current scaling (in local space) */
  6148. scaling: Vector3;
  6149. /**
  6150. * Gets the animation properties override
  6151. */
  6152. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6153. private _decompose;
  6154. private _compose;
  6155. /**
  6156. * Update the base and local matrices
  6157. * @param matrix defines the new base or local matrix
  6158. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6159. * @param updateLocalMatrix defines if the local matrix should be updated
  6160. */
  6161. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  6162. /** @hidden */
  6163. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  6164. /**
  6165. * Flag the bone as dirty (Forcing it to update everything)
  6166. */
  6167. markAsDirty(): void;
  6168. private _markAsDirtyAndCompose;
  6169. private _markAsDirtyAndDecompose;
  6170. /**
  6171. * Copy an animation range from another bone
  6172. * @param source defines the source bone
  6173. * @param rangeName defines the range name to copy
  6174. * @param frameOffset defines the frame offset
  6175. * @param rescaleAsRequired defines if rescaling must be applied if required
  6176. * @param skelDimensionsRatio defines the scaling ratio
  6177. * @returns true if operation was successful
  6178. */
  6179. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  6180. /**
  6181. * Translate the bone in local or world space
  6182. * @param vec The amount to translate the bone
  6183. * @param space The space that the translation is in
  6184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6185. */
  6186. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6187. /**
  6188. * Set the postion of the bone in local or world space
  6189. * @param position The position to set the bone
  6190. * @param space The space that the position is in
  6191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6192. */
  6193. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6194. /**
  6195. * Set the absolute position of the bone (world space)
  6196. * @param position The position to set the bone
  6197. * @param mesh The mesh that this bone is attached to
  6198. */
  6199. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6200. /**
  6201. * Scale the bone on the x, y and z axes (in local space)
  6202. * @param x The amount to scale the bone on the x axis
  6203. * @param y The amount to scale the bone on the y axis
  6204. * @param z The amount to scale the bone on the z axis
  6205. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6206. */
  6207. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6208. /**
  6209. * Set the bone scaling in local space
  6210. * @param scale defines the scaling vector
  6211. */
  6212. setScale(scale: Vector3): void;
  6213. /**
  6214. * Gets the current scaling in local space
  6215. * @returns the current scaling vector
  6216. */
  6217. getScale(): Vector3;
  6218. /**
  6219. * Gets the current scaling in local space and stores it in a target vector
  6220. * @param result defines the target vector
  6221. */
  6222. getScaleToRef(result: Vector3): void;
  6223. /**
  6224. * Set the yaw, pitch, and roll of the bone in local or world space
  6225. * @param yaw The rotation of the bone on the y axis
  6226. * @param pitch The rotation of the bone on the x axis
  6227. * @param roll The rotation of the bone on the z axis
  6228. * @param space The space that the axes of rotation are in
  6229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6230. */
  6231. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6232. /**
  6233. * Add a rotation to the bone on an axis in local or world space
  6234. * @param axis The axis to rotate the bone on
  6235. * @param amount The amount to rotate the bone
  6236. * @param space The space that the axis is in
  6237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6238. */
  6239. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6240. /**
  6241. * Set the rotation of the bone to a particular axis angle in local or world space
  6242. * @param axis The axis to rotate the bone on
  6243. * @param angle The angle that the bone should be rotated to
  6244. * @param space The space that the axis is in
  6245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6246. */
  6247. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6248. /**
  6249. * Set the euler rotation of the bone in local of world space
  6250. * @param rotation The euler rotation that the bone should be set to
  6251. * @param space The space that the rotation is in
  6252. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6253. */
  6254. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6255. /**
  6256. * Set the quaternion rotation of the bone in local of world space
  6257. * @param quat The quaternion rotation that the bone should be set to
  6258. * @param space The space that the rotation is in
  6259. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6260. */
  6261. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6262. /**
  6263. * Set the rotation matrix of the bone in local of world space
  6264. * @param rotMat The rotation matrix that the bone should be set to
  6265. * @param space The space that the rotation is in
  6266. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6267. */
  6268. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6269. private _rotateWithMatrix;
  6270. private _getNegativeRotationToRef;
  6271. /**
  6272. * Get the position of the bone in local or world space
  6273. * @param space The space that the returned position is in
  6274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6275. * @returns The position of the bone
  6276. */
  6277. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6278. /**
  6279. * Copy the position of the bone to a vector3 in local or world space
  6280. * @param space The space that the returned position is in
  6281. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6282. * @param result The vector3 to copy the position to
  6283. */
  6284. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6285. /**
  6286. * Get the absolute position of the bone (world space)
  6287. * @param mesh The mesh that this bone is attached to
  6288. * @returns The absolute position of the bone
  6289. */
  6290. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6291. /**
  6292. * Copy the absolute position of the bone (world space) to the result param
  6293. * @param mesh The mesh that this bone is attached to
  6294. * @param result The vector3 to copy the absolute position to
  6295. */
  6296. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6297. /**
  6298. * Compute the absolute transforms of this bone and its children
  6299. */
  6300. computeAbsoluteTransforms(): void;
  6301. /**
  6302. * Get the world direction from an axis that is in the local space of the bone
  6303. * @param localAxis The local direction that is used to compute the world direction
  6304. * @param mesh The mesh that this bone is attached to
  6305. * @returns The world direction
  6306. */
  6307. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6308. /**
  6309. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6310. * @param localAxis The local direction that is used to compute the world direction
  6311. * @param mesh The mesh that this bone is attached to
  6312. * @param result The vector3 that the world direction will be copied to
  6313. */
  6314. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6315. /**
  6316. * Get the euler rotation of the bone in local or world space
  6317. * @param space The space that the rotation should be in
  6318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6319. * @returns The euler rotation
  6320. */
  6321. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6322. /**
  6323. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6324. * @param space The space that the rotation should be in
  6325. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6326. * @param result The vector3 that the rotation should be copied to
  6327. */
  6328. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6329. /**
  6330. * Get the quaternion rotation of the bone in either local or world space
  6331. * @param space The space that the rotation should be in
  6332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6333. * @returns The quaternion rotation
  6334. */
  6335. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6336. /**
  6337. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6338. * @param space The space that the rotation should be in
  6339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6340. * @param result The quaternion that the rotation should be copied to
  6341. */
  6342. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6343. /**
  6344. * Get the rotation matrix of the bone in local or world space
  6345. * @param space The space that the rotation should be in
  6346. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6347. * @returns The rotation matrix
  6348. */
  6349. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6350. /**
  6351. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6352. * @param space The space that the rotation should be in
  6353. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6354. * @param result The quaternion that the rotation should be copied to
  6355. */
  6356. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6357. /**
  6358. * Get the world position of a point that is in the local space of the bone
  6359. * @param position The local position
  6360. * @param mesh The mesh that this bone is attached to
  6361. * @returns The world position
  6362. */
  6363. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6364. /**
  6365. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6366. * @param position The local position
  6367. * @param mesh The mesh that this bone is attached to
  6368. * @param result The vector3 that the world position should be copied to
  6369. */
  6370. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6371. /**
  6372. * Get the local position of a point that is in world space
  6373. * @param position The world position
  6374. * @param mesh The mesh that this bone is attached to
  6375. * @returns The local position
  6376. */
  6377. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6378. /**
  6379. * Get the local position of a point that is in world space and copy it to the result param
  6380. * @param position The world position
  6381. * @param mesh The mesh that this bone is attached to
  6382. * @param result The vector3 that the local position should be copied to
  6383. */
  6384. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6385. }
  6386. }
  6387. declare module BABYLON {
  6388. /**
  6389. * Class used to apply inverse kinematics to bones
  6390. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6391. */
  6392. class BoneIKController {
  6393. private static _tmpVecs;
  6394. private static _tmpQuat;
  6395. private static _tmpMats;
  6396. /**
  6397. * Gets or sets the target mesh
  6398. */
  6399. targetMesh: AbstractMesh;
  6400. /** Gets or sets the mesh used as pole */
  6401. poleTargetMesh: AbstractMesh;
  6402. /**
  6403. * Gets or sets the bone used as pole
  6404. */
  6405. poleTargetBone: Nullable<Bone>;
  6406. /**
  6407. * Gets or sets the target position
  6408. */
  6409. targetPosition: Vector3;
  6410. /**
  6411. * Gets or sets the pole target position
  6412. */
  6413. poleTargetPosition: Vector3;
  6414. /**
  6415. * Gets or sets the pole target local offset
  6416. */
  6417. poleTargetLocalOffset: Vector3;
  6418. /**
  6419. * Gets or sets the pole angle
  6420. */
  6421. poleAngle: number;
  6422. /**
  6423. * Gets or sets the mesh associated with the controller
  6424. */
  6425. mesh: AbstractMesh;
  6426. /**
  6427. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  6428. */
  6429. slerpAmount: number;
  6430. private _bone1Quat;
  6431. private _bone1Mat;
  6432. private _bone2Ang;
  6433. private _bone1;
  6434. private _bone2;
  6435. private _bone1Length;
  6436. private _bone2Length;
  6437. private _maxAngle;
  6438. private _maxReach;
  6439. private _rightHandedSystem;
  6440. private _bendAxis;
  6441. private _slerping;
  6442. private _adjustRoll;
  6443. /**
  6444. * Gets or sets maximum allowed angle
  6445. */
  6446. maxAngle: number;
  6447. /**
  6448. * Creates a new BoneIKController
  6449. * @param mesh defines the mesh to control
  6450. * @param bone defines the bone to control
  6451. * @param options defines options to set up the controller
  6452. */
  6453. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6454. targetMesh?: AbstractMesh;
  6455. poleTargetMesh?: AbstractMesh;
  6456. poleTargetBone?: Bone;
  6457. poleTargetLocalOffset?: Vector3;
  6458. poleAngle?: number;
  6459. bendAxis?: Vector3;
  6460. maxAngle?: number;
  6461. slerpAmount?: number;
  6462. });
  6463. private _setMaxAngle;
  6464. /**
  6465. * Force the controller to update the bones
  6466. */
  6467. update(): void;
  6468. }
  6469. }
  6470. declare module BABYLON {
  6471. /**
  6472. * Class used to make a bone look toward a point in space
  6473. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6474. */
  6475. class BoneLookController {
  6476. private static _tmpVecs;
  6477. private static _tmpQuat;
  6478. private static _tmpMats;
  6479. /**
  6480. * The target Vector3 that the bone will look at
  6481. */
  6482. target: Vector3;
  6483. /**
  6484. * The mesh that the bone is attached to
  6485. */
  6486. mesh: AbstractMesh;
  6487. /**
  6488. * The bone that will be looking to the target
  6489. */
  6490. bone: Bone;
  6491. /**
  6492. * The up axis of the coordinate system that is used when the bone is rotated
  6493. */
  6494. upAxis: Vector3;
  6495. /**
  6496. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6497. */
  6498. upAxisSpace: Space;
  6499. /**
  6500. * Used to make an adjustment to the yaw of the bone
  6501. */
  6502. adjustYaw: number;
  6503. /**
  6504. * Used to make an adjustment to the pitch of the bone
  6505. */
  6506. adjustPitch: number;
  6507. /**
  6508. * Used to make an adjustment to the roll of the bone
  6509. */
  6510. adjustRoll: number;
  6511. /**
  6512. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  6513. */
  6514. slerpAmount: number;
  6515. private _minYaw;
  6516. private _maxYaw;
  6517. private _minPitch;
  6518. private _maxPitch;
  6519. private _minYawSin;
  6520. private _minYawCos;
  6521. private _maxYawSin;
  6522. private _maxYawCos;
  6523. private _midYawConstraint;
  6524. private _minPitchTan;
  6525. private _maxPitchTan;
  6526. private _boneQuat;
  6527. private _slerping;
  6528. private _transformYawPitch;
  6529. private _transformYawPitchInv;
  6530. private _firstFrameSkipped;
  6531. private _yawRange;
  6532. private _fowardAxis;
  6533. /**
  6534. * Gets or sets the minimum yaw angle that the bone can look to
  6535. */
  6536. minYaw: number;
  6537. /**
  6538. * Gets or sets the maximum yaw angle that the bone can look to
  6539. */
  6540. maxYaw: number;
  6541. /**
  6542. * Gets or sets the minimum pitch angle that the bone can look to
  6543. */
  6544. minPitch: number;
  6545. /**
  6546. * Gets or sets the maximum pitch angle that the bone can look to
  6547. */
  6548. maxPitch: number;
  6549. /**
  6550. * Create a BoneLookController
  6551. * @param mesh the mesh that the bone belongs to
  6552. * @param bone the bone that will be looking to the target
  6553. * @param target the target Vector3 to look at
  6554. * @param settings optional settings:
  6555. * * maxYaw: the maximum angle the bone will yaw to
  6556. * * minYaw: the minimum angle the bone will yaw to
  6557. * * maxPitch: the maximum angle the bone will pitch to
  6558. * * minPitch: the minimum angle the bone will yaw to
  6559. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6560. * * upAxis: the up axis of the coordinate system
  6561. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6562. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6563. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6564. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6565. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6566. * * adjustRoll: used to make an adjustment to the roll of the bone
  6567. **/
  6568. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6569. maxYaw?: number;
  6570. minYaw?: number;
  6571. maxPitch?: number;
  6572. minPitch?: number;
  6573. slerpAmount?: number;
  6574. upAxis?: Vector3;
  6575. upAxisSpace?: Space;
  6576. yawAxis?: Vector3;
  6577. pitchAxis?: Vector3;
  6578. adjustYaw?: number;
  6579. adjustPitch?: number;
  6580. adjustRoll?: number;
  6581. });
  6582. /**
  6583. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6584. */
  6585. update(): void;
  6586. private _getAngleDiff;
  6587. private _getAngleBetween;
  6588. private _isAngleBetween;
  6589. }
  6590. }
  6591. declare module BABYLON {
  6592. /**
  6593. * Class used to handle skinning animations
  6594. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6595. */
  6596. class Skeleton implements IAnimatable {
  6597. /** defines the skeleton name */
  6598. name: string;
  6599. /** defines the skeleton Id */
  6600. id: string;
  6601. /**
  6602. * Defines the list of child bones
  6603. */
  6604. bones: Bone[];
  6605. /**
  6606. * Defines an estimate of the dimension of the skeleton at rest
  6607. */
  6608. dimensionsAtRest: Vector3;
  6609. /**
  6610. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6611. */
  6612. needInitialSkinMatrix: boolean;
  6613. /**
  6614. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  6615. */
  6616. overrideMesh: Nullable<AbstractMesh>;
  6617. /**
  6618. * Gets the list of animations attached to this skeleton
  6619. */
  6620. animations: Array<Animation>;
  6621. private _scene;
  6622. private _isDirty;
  6623. private _transformMatrices;
  6624. private _transformMatrixTexture;
  6625. private _meshesWithPoseMatrix;
  6626. private _animatables;
  6627. private _identity;
  6628. private _synchronizedWithMesh;
  6629. private _ranges;
  6630. private _lastAbsoluteTransformsUpdateId;
  6631. private _canUseTextureForBones;
  6632. /** @hidden */
  6633. _numBonesWithLinkedTransformNode: number;
  6634. /**
  6635. * Specifies if the skeleton should be serialized
  6636. */
  6637. doNotSerialize: boolean;
  6638. /**
  6639. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  6640. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  6641. */
  6642. useTextureToStoreBoneMatrices: boolean;
  6643. private _animationPropertiesOverride;
  6644. /**
  6645. * Gets or sets the animation properties override
  6646. */
  6647. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6648. /**
  6649. * An observable triggered before computing the skeleton's matrices
  6650. */
  6651. onBeforeComputeObservable: Observable<Skeleton>;
  6652. /**
  6653. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  6654. */
  6655. readonly isUsingTextureForMatrices: boolean;
  6656. /**
  6657. * Creates a new skeleton
  6658. * @param name defines the skeleton name
  6659. * @param id defines the skeleton Id
  6660. * @param scene defines the hosting scene
  6661. */
  6662. constructor(
  6663. /** defines the skeleton name */
  6664. name: string,
  6665. /** defines the skeleton Id */
  6666. id: string, scene: Scene);
  6667. /**
  6668. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6669. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6670. * @returns a Float32Array containing matrices data
  6671. */
  6672. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6673. /**
  6674. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  6675. * @returns a raw texture containing the data
  6676. */
  6677. getTransformMatrixTexture(): Nullable<RawTexture>;
  6678. /**
  6679. * Gets the current hosting scene
  6680. * @returns a scene object
  6681. */
  6682. getScene(): Scene;
  6683. /**
  6684. * Gets a string representing the current skeleton data
  6685. * @param fullDetails defines a boolean indicating if we want a verbose version
  6686. * @returns a string representing the current skeleton data
  6687. */
  6688. toString(fullDetails?: boolean): string;
  6689. /**
  6690. * Get bone's index searching by name
  6691. * @param name defines bone's name to search for
  6692. * @return the indice of the bone. Returns -1 if not found
  6693. */
  6694. getBoneIndexByName(name: string): number;
  6695. /**
  6696. * Creater a new animation range
  6697. * @param name defines the name of the range
  6698. * @param from defines the start key
  6699. * @param to defines the end key
  6700. */
  6701. createAnimationRange(name: string, from: number, to: number): void;
  6702. /**
  6703. * Delete a specific animation range
  6704. * @param name defines the name of the range
  6705. * @param deleteFrames defines if frames must be removed as well
  6706. */
  6707. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6708. /**
  6709. * Gets a specific animation range
  6710. * @param name defines the name of the range to look for
  6711. * @returns the requested animation range or null if not found
  6712. */
  6713. getAnimationRange(name: string): Nullable<AnimationRange>;
  6714. /**
  6715. * Gets the list of all animation ranges defined on this skeleton
  6716. * @returns an array
  6717. */
  6718. getAnimationRanges(): Nullable<AnimationRange>[];
  6719. /**
  6720. * Copy animation range from a source skeleton.
  6721. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6722. * @param source defines the source skeleton
  6723. * @param name defines the name of the range to copy
  6724. * @param rescaleAsRequired defines if rescaling must be applied if required
  6725. * @returns true if operation was successful
  6726. */
  6727. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6728. /**
  6729. * Forces the skeleton to go to rest pose
  6730. */
  6731. returnToRest(): void;
  6732. private _getHighestAnimationFrame;
  6733. /**
  6734. * Begin a specific animation range
  6735. * @param name defines the name of the range to start
  6736. * @param loop defines if looping must be turned on (false by default)
  6737. * @param speedRatio defines the speed ratio to apply (1 by default)
  6738. * @param onAnimationEnd defines a callback which will be called when animation will end
  6739. * @returns a new animatable
  6740. */
  6741. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6742. /** @hidden */
  6743. _markAsDirty(): void;
  6744. /** @hidden */
  6745. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6746. /** @hidden */
  6747. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6748. private _computeTransformMatrices;
  6749. /**
  6750. * Build all resources required to render a skeleton
  6751. */
  6752. prepare(): void;
  6753. /**
  6754. * Gets the list of animatables currently running for this skeleton
  6755. * @returns an array of animatables
  6756. */
  6757. getAnimatables(): IAnimatable[];
  6758. /**
  6759. * Clone the current skeleton
  6760. * @param name defines the name of the new skeleton
  6761. * @param id defines the id of the enw skeleton
  6762. * @returns the new skeleton
  6763. */
  6764. clone(name: string, id: string): Skeleton;
  6765. /**
  6766. * Enable animation blending for this skeleton
  6767. * @param blendingSpeed defines the blending speed to apply
  6768. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6769. */
  6770. enableBlending(blendingSpeed?: number): void;
  6771. /**
  6772. * Releases all resources associated with the current skeleton
  6773. */
  6774. dispose(): void;
  6775. /**
  6776. * Serialize the skeleton in a JSON object
  6777. * @returns a JSON object
  6778. */
  6779. serialize(): any;
  6780. /**
  6781. * Creates a new skeleton from serialized data
  6782. * @param parsedSkeleton defines the serialized data
  6783. * @param scene defines the hosting scene
  6784. * @returns a new skeleton
  6785. */
  6786. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6787. /**
  6788. * Compute all node absolute transforms
  6789. * @param forceUpdate defines if computation must be done even if cache is up to date
  6790. */
  6791. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6792. /**
  6793. * Gets the root pose matrix
  6794. * @returns a matrix
  6795. */
  6796. getPoseMatrix(): Nullable<Matrix>;
  6797. /**
  6798. * Sorts bones per internal index
  6799. */
  6800. sortBones(): void;
  6801. private _sortBones;
  6802. }
  6803. }
  6804. declare module BABYLON {
  6805. /** @hidden */
  6806. class Collider {
  6807. /** Define if a collision was found */
  6808. collisionFound: boolean;
  6809. /**
  6810. * Define last intersection point in local space
  6811. */
  6812. intersectionPoint: Vector3;
  6813. /**
  6814. * Define last collided mesh
  6815. */
  6816. collidedMesh: Nullable<AbstractMesh>;
  6817. private _collisionPoint;
  6818. private _planeIntersectionPoint;
  6819. private _tempVector;
  6820. private _tempVector2;
  6821. private _tempVector3;
  6822. private _tempVector4;
  6823. private _edge;
  6824. private _baseToVertex;
  6825. private _destinationPoint;
  6826. private _slidePlaneNormal;
  6827. private _displacementVector;
  6828. /** @hidden */
  6829. _radius: Vector3;
  6830. /** @hidden */
  6831. _retry: number;
  6832. private _velocity;
  6833. private _basePoint;
  6834. private _epsilon;
  6835. /** @hidden */
  6836. _velocityWorldLength: number;
  6837. /** @hidden */
  6838. _basePointWorld: Vector3;
  6839. private _velocityWorld;
  6840. private _normalizedVelocity;
  6841. /** @hidden */
  6842. _initialVelocity: Vector3;
  6843. /** @hidden */
  6844. _initialPosition: Vector3;
  6845. private _nearestDistance;
  6846. private _collisionMask;
  6847. collisionMask: number;
  6848. /**
  6849. * Gets the plane normal used to compute the sliding response (in local space)
  6850. */
  6851. readonly slidePlaneNormal: Vector3;
  6852. /** @hidden */
  6853. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6854. /** @hidden */
  6855. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6856. /** @hidden */
  6857. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6858. /** @hidden */
  6859. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  6860. /** @hidden */
  6861. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  6862. /** @hidden */
  6863. _getResponse(pos: Vector3, vel: Vector3): void;
  6864. }
  6865. }
  6866. declare module BABYLON {
  6867. /** @hidden */
  6868. var CollisionWorker: string;
  6869. /** @hidden */
  6870. interface ICollisionCoordinator {
  6871. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6872. init(scene: Scene): void;
  6873. destroy(): void;
  6874. onMeshAdded(mesh: AbstractMesh): void;
  6875. onMeshUpdated(mesh: AbstractMesh): void;
  6876. onMeshRemoved(mesh: AbstractMesh): void;
  6877. onGeometryAdded(geometry: Geometry): void;
  6878. onGeometryUpdated(geometry: Geometry): void;
  6879. onGeometryDeleted(geometry: Geometry): void;
  6880. }
  6881. /** @hidden */
  6882. interface SerializedMesh {
  6883. id: string;
  6884. name: string;
  6885. uniqueId: number;
  6886. geometryId: Nullable<string>;
  6887. sphereCenter: Array<number>;
  6888. sphereRadius: number;
  6889. boxMinimum: Array<number>;
  6890. boxMaximum: Array<number>;
  6891. worldMatrixFromCache: any;
  6892. subMeshes: Array<SerializedSubMesh>;
  6893. checkCollisions: boolean;
  6894. }
  6895. /** @hidden */
  6896. interface SerializedSubMesh {
  6897. position: number;
  6898. verticesStart: number;
  6899. verticesCount: number;
  6900. indexStart: number;
  6901. indexCount: number;
  6902. hasMaterial: boolean;
  6903. sphereCenter: Array<number>;
  6904. sphereRadius: number;
  6905. boxMinimum: Array<number>;
  6906. boxMaximum: Array<number>;
  6907. }
  6908. /**
  6909. * Interface describing the value associated with a geometry.
  6910. * @hidden
  6911. */
  6912. interface SerializedGeometry {
  6913. /**
  6914. * Defines the unique ID of the geometry
  6915. */
  6916. id: string;
  6917. /**
  6918. * Defines the array containing the positions
  6919. */
  6920. positions: Float32Array;
  6921. /**
  6922. * Defines the array containing the indices
  6923. */
  6924. indices: Uint32Array;
  6925. /**
  6926. * Defines the array containing the normals
  6927. */
  6928. normals: Float32Array;
  6929. }
  6930. /** @hidden */
  6931. interface BabylonMessage {
  6932. taskType: WorkerTaskType;
  6933. payload: InitPayload | CollidePayload | UpdatePayload;
  6934. }
  6935. /** @hidden */
  6936. interface SerializedColliderToWorker {
  6937. position: Array<number>;
  6938. velocity: Array<number>;
  6939. radius: Array<number>;
  6940. }
  6941. /** Defines supported task for worker process */
  6942. enum WorkerTaskType {
  6943. /** Initialization */
  6944. INIT = 0,
  6945. /** Update of geometry */
  6946. UPDATE = 1,
  6947. /** Evaluate collision */
  6948. COLLIDE = 2
  6949. }
  6950. /** @hidden */
  6951. interface WorkerReply {
  6952. error: WorkerReplyType;
  6953. taskType: WorkerTaskType;
  6954. payload?: any;
  6955. }
  6956. /** @hidden */
  6957. interface CollisionReplyPayload {
  6958. newPosition: Array<number>;
  6959. collisionId: number;
  6960. collidedMeshUniqueId: number;
  6961. }
  6962. /** @hidden */
  6963. interface InitPayload {
  6964. }
  6965. /** @hidden */
  6966. interface CollidePayload {
  6967. collisionId: number;
  6968. collider: SerializedColliderToWorker;
  6969. maximumRetry: number;
  6970. excludedMeshUniqueId: Nullable<number>;
  6971. }
  6972. /** @hidden */
  6973. interface UpdatePayload {
  6974. updatedMeshes: {
  6975. [n: number]: SerializedMesh;
  6976. };
  6977. updatedGeometries: {
  6978. [s: string]: SerializedGeometry;
  6979. };
  6980. removedMeshes: Array<number>;
  6981. removedGeometries: Array<string>;
  6982. }
  6983. /** Defines kind of replies returned by worker */
  6984. enum WorkerReplyType {
  6985. /** Success */
  6986. SUCCESS = 0,
  6987. /** Unkown error */
  6988. UNKNOWN_ERROR = 1
  6989. }
  6990. /** @hidden */
  6991. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  6992. private _scene;
  6993. private _scaledPosition;
  6994. private _scaledVelocity;
  6995. private _collisionsCallbackArray;
  6996. private _init;
  6997. private _runningUpdated;
  6998. private _worker;
  6999. private _addUpdateMeshesList;
  7000. private _addUpdateGeometriesList;
  7001. private _toRemoveMeshesArray;
  7002. private _toRemoveGeometryArray;
  7003. constructor();
  7004. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  7005. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  7006. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  7007. init(scene: Scene): void;
  7008. destroy(): void;
  7009. onMeshAdded(mesh: AbstractMesh): void;
  7010. onMeshUpdated: (transformNode: TransformNode) => void;
  7011. onMeshRemoved(mesh: AbstractMesh): void;
  7012. onGeometryAdded(geometry: Geometry): void;
  7013. onGeometryUpdated: (geometry: Geometry) => void;
  7014. onGeometryDeleted(geometry: Geometry): void;
  7015. private _afterRender;
  7016. private _onMessageFromWorker;
  7017. }
  7018. /** @hidden */
  7019. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  7020. private _scene;
  7021. private _scaledPosition;
  7022. private _scaledVelocity;
  7023. private _finalPosition;
  7024. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  7025. init(scene: Scene): void;
  7026. destroy(): void;
  7027. onMeshAdded(mesh: AbstractMesh): void;
  7028. onMeshUpdated(mesh: AbstractMesh): void;
  7029. onMeshRemoved(mesh: AbstractMesh): void;
  7030. onGeometryAdded(geometry: Geometry): void;
  7031. onGeometryUpdated(geometry: Geometry): void;
  7032. onGeometryDeleted(geometry: Geometry): void;
  7033. private _collideWithWorld;
  7034. }
  7035. }
  7036. declare function importScripts(...urls: string[]): void;
  7037. declare const safePostMessage: any;
  7038. declare module BABYLON {
  7039. /** @hidden */
  7040. var WorkerIncluded: boolean;
  7041. /** @hidden */
  7042. class CollisionCache {
  7043. private _meshes;
  7044. private _geometries;
  7045. getMeshes(): {
  7046. [n: number]: SerializedMesh;
  7047. };
  7048. getGeometries(): {
  7049. [s: number]: SerializedGeometry;
  7050. };
  7051. getMesh(id: any): SerializedMesh;
  7052. addMesh(mesh: SerializedMesh): void;
  7053. removeMesh(uniqueId: number): void;
  7054. getGeometry(id: string): SerializedGeometry;
  7055. addGeometry(geometry: SerializedGeometry): void;
  7056. removeGeometry(id: string): void;
  7057. }
  7058. /** @hidden */
  7059. class CollideWorker {
  7060. collider: Collider;
  7061. private _collisionCache;
  7062. private finalPosition;
  7063. private collisionsScalingMatrix;
  7064. private collisionTranformationMatrix;
  7065. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  7066. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  7067. private checkCollision;
  7068. private processCollisionsForSubMeshes;
  7069. private collideForSubMesh;
  7070. private checkSubmeshCollision;
  7071. }
  7072. /** @hidden */
  7073. interface ICollisionDetector {
  7074. onInit(payload: InitPayload): void;
  7075. onUpdate(payload: UpdatePayload): void;
  7076. onCollision(payload: CollidePayload): void;
  7077. }
  7078. /** @hidden */
  7079. class CollisionDetectorTransferable implements ICollisionDetector {
  7080. private _collisionCache;
  7081. onInit(payload: InitPayload): void;
  7082. onUpdate(payload: UpdatePayload): void;
  7083. onCollision(payload: CollidePayload): void;
  7084. }
  7085. }
  7086. declare module BABYLON {
  7087. /**
  7088. * @hidden
  7089. */
  7090. class IntersectionInfo {
  7091. bu: Nullable<number>;
  7092. bv: Nullable<number>;
  7093. distance: number;
  7094. faceId: number;
  7095. subMeshId: number;
  7096. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7097. }
  7098. /**
  7099. * Information about the result of picking within a scene
  7100. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  7101. */
  7102. class PickingInfo {
  7103. /**
  7104. * If the pick collided with an object
  7105. */
  7106. hit: boolean;
  7107. /**
  7108. * Distance away where the pick collided
  7109. */
  7110. distance: number;
  7111. /**
  7112. * The location of pick collision
  7113. */
  7114. pickedPoint: Nullable<Vector3>;
  7115. /**
  7116. * The mesh corresponding the the pick collision
  7117. */
  7118. pickedMesh: Nullable<AbstractMesh>;
  7119. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  7120. bu: number;
  7121. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  7122. bv: number;
  7123. /** The id of the face on the mesh that was picked */
  7124. faceId: number;
  7125. /** Id of the the submesh that was picked */
  7126. subMeshId: number;
  7127. /** If a sprite was picked, this will be the sprite the pick collided with */
  7128. pickedSprite: Nullable<Sprite>;
  7129. /**
  7130. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  7131. */
  7132. originMesh: Nullable<AbstractMesh>;
  7133. /**
  7134. * The ray that was used to perform the picking.
  7135. */
  7136. ray: Nullable<Ray>;
  7137. /**
  7138. * Gets the normal correspodning to the face the pick collided with
  7139. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  7140. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  7141. * @returns The normal correspodning to the face the pick collided with
  7142. */
  7143. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  7144. /**
  7145. * Gets the texture coordinates of where the pick occured
  7146. * @returns the vector containing the coordnates of the texture
  7147. */
  7148. getTextureCoordinates(): Nullable<Vector2>;
  7149. }
  7150. }
  7151. declare module BABYLON {
  7152. /**
  7153. * This represents an orbital type of camera.
  7154. *
  7155. * 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.
  7156. * 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.
  7157. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  7158. */
  7159. class ArcRotateCamera extends TargetCamera {
  7160. /**
  7161. * Defines the rotation angle of the camera along the longitudinal axis.
  7162. */
  7163. alpha: number;
  7164. /**
  7165. * Defines the rotation angle of the camera along the latitudinal axis.
  7166. */
  7167. beta: number;
  7168. /**
  7169. * Defines the radius of the camera from it s target point.
  7170. */
  7171. radius: number;
  7172. protected _target: Vector3;
  7173. protected _targetHost: Nullable<AbstractMesh>;
  7174. /**
  7175. * Defines the target point of the camera.
  7176. * The camera looks towards it form the radius distance.
  7177. */
  7178. target: Vector3;
  7179. /**
  7180. * Current inertia value on the longitudinal axis.
  7181. * The bigger this number the longer it will take for the camera to stop.
  7182. */
  7183. inertialAlphaOffset: number;
  7184. /**
  7185. * Current inertia value on the latitudinal axis.
  7186. * The bigger this number the longer it will take for the camera to stop.
  7187. */
  7188. inertialBetaOffset: number;
  7189. /**
  7190. * Current inertia value on the radius axis.
  7191. * The bigger this number the longer it will take for the camera to stop.
  7192. */
  7193. inertialRadiusOffset: number;
  7194. /**
  7195. * Minimum allowed angle on the longitudinal axis.
  7196. * This can help limiting how the Camera is able to move in the scene.
  7197. */
  7198. lowerAlphaLimit: Nullable<number>;
  7199. /**
  7200. * Maximum allowed angle on the longitudinal axis.
  7201. * This can help limiting how the Camera is able to move in the scene.
  7202. */
  7203. upperAlphaLimit: Nullable<number>;
  7204. /**
  7205. * Minimum allowed angle on the latitudinal axis.
  7206. * This can help limiting how the Camera is able to move in the scene.
  7207. */
  7208. lowerBetaLimit: number;
  7209. /**
  7210. * Maximum allowed angle on the latitudinal axis.
  7211. * This can help limiting how the Camera is able to move in the scene.
  7212. */
  7213. upperBetaLimit: number;
  7214. /**
  7215. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  7216. * This can help limiting how the Camera is able to move in the scene.
  7217. */
  7218. lowerRadiusLimit: Nullable<number>;
  7219. /**
  7220. * Maximum allowed distance of the camera to the target (The camera can not get further).
  7221. * This can help limiting how the Camera is able to move in the scene.
  7222. */
  7223. upperRadiusLimit: Nullable<number>;
  7224. /**
  7225. * Defines the current inertia value used during panning of the camera along the X axis.
  7226. */
  7227. inertialPanningX: number;
  7228. /**
  7229. * Defines the current inertia value used during panning of the camera along the Y axis.
  7230. */
  7231. inertialPanningY: number;
  7232. /**
  7233. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  7234. * Basically if your fingers moves away from more than this distance you will be considered
  7235. * in pinch mode.
  7236. */
  7237. pinchToPanMaxDistance: number;
  7238. /**
  7239. * Defines the maximum distance the camera can pan.
  7240. * This could help keeping the cammera always in your scene.
  7241. */
  7242. panningDistanceLimit: Nullable<number>;
  7243. /**
  7244. * Defines the target of the camera before paning.
  7245. */
  7246. panningOriginTarget: Vector3;
  7247. /**
  7248. * Defines the value of the inertia used during panning.
  7249. * 0 would mean stop inertia and one would mean no decelleration at all.
  7250. */
  7251. panningInertia: number;
  7252. /**
  7253. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  7254. */
  7255. angularSensibilityX: number;
  7256. /**
  7257. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  7258. */
  7259. angularSensibilityY: number;
  7260. /**
  7261. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  7262. */
  7263. pinchPrecision: number;
  7264. /**
  7265. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  7266. * It will be used instead of pinchDeltaPrecision if different from 0.
  7267. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7268. */
  7269. pinchDeltaPercentage: number;
  7270. /**
  7271. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  7272. */
  7273. panningSensibility: number;
  7274. /**
  7275. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  7276. */
  7277. keysUp: number[];
  7278. /**
  7279. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  7280. */
  7281. keysDown: number[];
  7282. /**
  7283. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  7284. */
  7285. keysLeft: number[];
  7286. /**
  7287. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  7288. */
  7289. keysRight: number[];
  7290. /**
  7291. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  7292. */
  7293. wheelPrecision: number;
  7294. /**
  7295. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  7296. * It will be used instead of pinchDeltaPrecision if different from 0.
  7297. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7298. */
  7299. wheelDeltaPercentage: number;
  7300. /**
  7301. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  7302. */
  7303. zoomOnFactor: number;
  7304. /**
  7305. * Defines a screen offset for the camera position.
  7306. */
  7307. targetScreenOffset: Vector2;
  7308. /**
  7309. * Allows the camera to be completely reversed.
  7310. * If false the camera can not arrive upside down.
  7311. */
  7312. allowUpsideDown: boolean;
  7313. /**
  7314. * Define if double tap/click is used to restore the previously saved state of the camera.
  7315. */
  7316. useInputToRestoreState: boolean;
  7317. /** @hidden */
  7318. _viewMatrix: Matrix;
  7319. /** @hidden */
  7320. _useCtrlForPanning: boolean;
  7321. /** @hidden */
  7322. _panningMouseButton: number;
  7323. /**
  7324. * Defines the inpute associated to the camera.
  7325. */
  7326. inputs: ArcRotateCameraInputsManager;
  7327. /** @hidden */
  7328. _reset: () => void;
  7329. /**
  7330. * Defines the allowed panning axis.
  7331. */
  7332. panningAxis: Vector3;
  7333. protected _localDirection: Vector3;
  7334. protected _transformedDirection: Vector3;
  7335. private _bouncingBehavior;
  7336. /**
  7337. * Gets the bouncing behavior of the camera if it has been enabled.
  7338. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7339. */
  7340. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  7341. /**
  7342. * Defines if the bouncing behavior of the camera is enabled on the camera.
  7343. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7344. */
  7345. useBouncingBehavior: boolean;
  7346. private _framingBehavior;
  7347. /**
  7348. * Gets the framing behavior of the camera if it has been enabled.
  7349. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7350. */
  7351. readonly framingBehavior: Nullable<FramingBehavior>;
  7352. /**
  7353. * Defines if the framing behavior of the camera is enabled on the camera.
  7354. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7355. */
  7356. useFramingBehavior: boolean;
  7357. private _autoRotationBehavior;
  7358. /**
  7359. * Gets the auto rotation behavior of the camera if it has been enabled.
  7360. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7361. */
  7362. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  7363. /**
  7364. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  7365. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7366. */
  7367. useAutoRotationBehavior: boolean;
  7368. /**
  7369. * Observable triggered when the mesh target has been changed on the camera.
  7370. */
  7371. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  7372. /**
  7373. * Event raised when the camera is colliding with a mesh.
  7374. */
  7375. onCollide: (collidedMesh: AbstractMesh) => void;
  7376. /**
  7377. * Defines whether the camera should check collision with the objects oh the scene.
  7378. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  7379. */
  7380. checkCollisions: boolean;
  7381. /**
  7382. * Defines the collision radius of the camera.
  7383. * This simulates a sphere around the camera.
  7384. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7385. */
  7386. collisionRadius: Vector3;
  7387. protected _collider: Collider;
  7388. protected _previousPosition: Vector3;
  7389. protected _collisionVelocity: Vector3;
  7390. protected _newPosition: Vector3;
  7391. protected _previousAlpha: number;
  7392. protected _previousBeta: number;
  7393. protected _previousRadius: number;
  7394. protected _collisionTriggered: boolean;
  7395. protected _targetBoundingCenter: Nullable<Vector3>;
  7396. private _computationVector;
  7397. private _tempAxisVector;
  7398. private _tempAxisRotationMatrix;
  7399. /**
  7400. * Instantiates a new ArcRotateCamera in a given scene
  7401. * @param name Defines the name of the camera
  7402. * @param alpha Defines the camera rotation along the logitudinal axis
  7403. * @param beta Defines the camera rotation along the latitudinal axis
  7404. * @param radius Defines the camera distance from its target
  7405. * @param target Defines the camera target
  7406. * @param scene Defines the scene the camera belongs to
  7407. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7408. */
  7409. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7410. /** @hidden */
  7411. _initCache(): void;
  7412. /** @hidden */
  7413. _updateCache(ignoreParentClass?: boolean): void;
  7414. protected _getTargetPosition(): Vector3;
  7415. private _storedAlpha;
  7416. private _storedBeta;
  7417. private _storedRadius;
  7418. private _storedTarget;
  7419. /**
  7420. * Stores the current state of the camera (alpha, beta, radius and target)
  7421. * @returns the camera itself
  7422. */
  7423. storeState(): Camera;
  7424. /**
  7425. * @hidden
  7426. * Restored camera state. You must call storeState() first
  7427. */
  7428. _restoreStateValues(): boolean;
  7429. /** @hidden */
  7430. _isSynchronizedViewMatrix(): boolean;
  7431. /**
  7432. * Attached controls to the current camera.
  7433. * @param element Defines the element the controls should be listened from
  7434. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7435. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  7436. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  7437. */
  7438. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  7439. /**
  7440. * Detach the current controls from the camera.
  7441. * The camera will stop reacting to inputs.
  7442. * @param element Defines the element to stop listening the inputs from
  7443. */
  7444. detachControl(element: HTMLElement): void;
  7445. /** @hidden */
  7446. _checkInputs(): void;
  7447. protected _checkLimits(): void;
  7448. /**
  7449. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  7450. */
  7451. rebuildAnglesAndRadius(): void;
  7452. /**
  7453. * Use a position to define the current camera related information like aplha, beta and radius
  7454. * @param position Defines the position to set the camera at
  7455. */
  7456. setPosition(position: Vector3): void;
  7457. /**
  7458. * Defines the target the camera should look at.
  7459. * This will automatically adapt alpha beta and radius to fit within the new target.
  7460. * @param target Defines the new target as a Vector or a mesh
  7461. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  7462. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  7463. */
  7464. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  7465. /** @hidden */
  7466. _getViewMatrix(): Matrix;
  7467. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  7468. /**
  7469. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  7470. * @param meshes Defines the mesh to zoom on
  7471. * @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)
  7472. */
  7473. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  7474. /**
  7475. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  7476. * The target will be changed but the radius
  7477. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  7478. * @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)
  7479. */
  7480. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  7481. min: Vector3;
  7482. max: Vector3;
  7483. distance: number;
  7484. }, doNotUpdateMaxZ?: boolean): void;
  7485. /**
  7486. * @override
  7487. * Override Camera.createRigCamera
  7488. */
  7489. createRigCamera(name: string, cameraIndex: number): Camera;
  7490. /**
  7491. * @hidden
  7492. * @override
  7493. * Override Camera._updateRigCameras
  7494. */
  7495. _updateRigCameras(): void;
  7496. /**
  7497. * Destroy the camera and release the current resources hold by it.
  7498. */
  7499. dispose(): void;
  7500. /**
  7501. * Gets the current object class name.
  7502. * @return the class name
  7503. */
  7504. getClassName(): string;
  7505. }
  7506. }
  7507. declare module BABYLON {
  7508. /**
  7509. * Default Inputs manager for the ArcRotateCamera.
  7510. * It groups all the default supported inputs for ease of use.
  7511. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7512. */
  7513. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  7514. /**
  7515. * Instantiates a new ArcRotateCameraInputsManager.
  7516. * @param camera Defines the camera the inputs belong to
  7517. */
  7518. constructor(camera: ArcRotateCamera);
  7519. /**
  7520. * Add mouse wheel input support to the input manager.
  7521. * @returns the current input manager
  7522. */
  7523. addMouseWheel(): ArcRotateCameraInputsManager;
  7524. /**
  7525. * Add pointers input support to the input manager.
  7526. * @returns the current input manager
  7527. */
  7528. addPointers(): ArcRotateCameraInputsManager;
  7529. /**
  7530. * Add keyboard input support to the input manager.
  7531. * @returns the current input manager
  7532. */
  7533. addKeyboard(): ArcRotateCameraInputsManager;
  7534. /**
  7535. * Add orientation input support to the input manager.
  7536. * @returns the current input manager
  7537. */
  7538. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7539. }
  7540. }
  7541. declare module BABYLON {
  7542. /**
  7543. * This is the base class of all the camera used in the application.
  7544. * @see http://doc.babylonjs.com/features/cameras
  7545. */
  7546. class Camera extends Node {
  7547. /**
  7548. * This is the default projection mode used by the cameras.
  7549. * It helps recreating a feeling of perspective and better appreciate depth.
  7550. * This is the best way to simulate real life cameras.
  7551. */
  7552. static readonly PERSPECTIVE_CAMERA: number;
  7553. /**
  7554. * This helps creating camera with an orthographic mode.
  7555. * 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.
  7556. */
  7557. static readonly ORTHOGRAPHIC_CAMERA: number;
  7558. /**
  7559. * This is the default FOV mode for perspective cameras.
  7560. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  7561. */
  7562. static readonly FOVMODE_VERTICAL_FIXED: number;
  7563. /**
  7564. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  7565. */
  7566. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  7567. /**
  7568. * This specifies ther is no need for a camera rig.
  7569. * Basically only one eye is rendered corresponding to the camera.
  7570. */
  7571. static readonly RIG_MODE_NONE: number;
  7572. /**
  7573. * Simulates a camera Rig with one blue eye and one red eye.
  7574. * This can be use with 3d blue and red glasses.
  7575. */
  7576. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  7577. /**
  7578. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  7579. */
  7580. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  7581. /**
  7582. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  7583. */
  7584. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  7585. /**
  7586. * Defines that both eyes of the camera will be rendered over under each other.
  7587. */
  7588. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  7589. /**
  7590. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  7591. */
  7592. static readonly RIG_MODE_VR: number;
  7593. /**
  7594. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  7595. */
  7596. static readonly RIG_MODE_WEBVR: number;
  7597. /**
  7598. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  7599. */
  7600. static readonly RIG_MODE_CUSTOM: number;
  7601. /**
  7602. * Defines if by default attaching controls should prevent the default javascript event to continue.
  7603. */
  7604. static ForceAttachControlToAlwaysPreventDefault: boolean;
  7605. /**
  7606. * @hidden
  7607. * Might be removed once multiview will be a thing
  7608. */
  7609. static UseAlternateWebVRRendering: boolean;
  7610. /**
  7611. * Define the input manager associated with the camera.
  7612. */
  7613. inputs: CameraInputsManager<Camera>;
  7614. /**
  7615. * Define the current local position of the camera in the scene
  7616. */
  7617. position: Vector3;
  7618. /**
  7619. * The vector the camera should consider as up.
  7620. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  7621. */
  7622. upVector: Vector3;
  7623. /**
  7624. * Define the current limit on the left side for an orthographic camera
  7625. * In scene unit
  7626. */
  7627. orthoLeft: Nullable<number>;
  7628. /**
  7629. * Define the current limit on the right side for an orthographic camera
  7630. * In scene unit
  7631. */
  7632. orthoRight: Nullable<number>;
  7633. /**
  7634. * Define the current limit on the bottom side for an orthographic camera
  7635. * In scene unit
  7636. */
  7637. orthoBottom: Nullable<number>;
  7638. /**
  7639. * Define the current limit on the top side for an orthographic camera
  7640. * In scene unit
  7641. */
  7642. orthoTop: Nullable<number>;
  7643. /**
  7644. * Field Of View is set in Radians. (default is 0.8)
  7645. */
  7646. fov: number;
  7647. /**
  7648. * Define the minimum distance the camera can see from.
  7649. * This is important to note that the depth buffer are not infinite and the closer it starts
  7650. * the more your scene might encounter depth fighting issue.
  7651. */
  7652. minZ: number;
  7653. /**
  7654. * Define the maximum distance the camera can see to.
  7655. * This is important to note that the depth buffer are not infinite and the further it end
  7656. * the more your scene might encounter depth fighting issue.
  7657. */
  7658. maxZ: number;
  7659. /**
  7660. * Define the default inertia of the camera.
  7661. * This helps giving a smooth feeling to the camera movement.
  7662. */
  7663. inertia: number;
  7664. /**
  7665. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  7666. */
  7667. mode: number;
  7668. /**
  7669. * Define wether the camera is intermediate.
  7670. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  7671. */
  7672. isIntermediate: boolean;
  7673. /**
  7674. * Define the viewport of the camera.
  7675. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  7676. */
  7677. viewport: Viewport;
  7678. /**
  7679. * Restricts the camera to viewing objects with the same layerMask.
  7680. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  7681. */
  7682. layerMask: number;
  7683. /**
  7684. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  7685. */
  7686. fovMode: number;
  7687. /**
  7688. * Rig mode of the camera.
  7689. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  7690. * This is normally controlled byt the camera themselves as internal use.
  7691. */
  7692. cameraRigMode: number;
  7693. /**
  7694. * Defines the distance between both "eyes" in case of a RIG
  7695. */
  7696. interaxialDistance: number;
  7697. /**
  7698. * Defines if stereoscopic rendering is done side by side or over under.
  7699. */
  7700. isStereoscopicSideBySide: boolean;
  7701. /**
  7702. * 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
  7703. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  7704. * else in the scene.
  7705. */
  7706. customRenderTargets: RenderTargetTexture[];
  7707. /**
  7708. * When set, the camera will render to this render target instead of the default canvas
  7709. */
  7710. outputRenderTarget: Nullable<RenderTargetTexture>;
  7711. /**
  7712. * Observable triggered when the camera view matrix has changed.
  7713. */
  7714. onViewMatrixChangedObservable: Observable<Camera>;
  7715. /**
  7716. * Observable triggered when the camera Projection matrix has changed.
  7717. */
  7718. onProjectionMatrixChangedObservable: Observable<Camera>;
  7719. /**
  7720. * Observable triggered when the inputs have been processed.
  7721. */
  7722. onAfterCheckInputsObservable: Observable<Camera>;
  7723. /**
  7724. * Observable triggered when reset has been called and applied to the camera.
  7725. */
  7726. onRestoreStateObservable: Observable<Camera>;
  7727. /** @hidden */
  7728. _cameraRigParams: any;
  7729. /** @hidden */
  7730. _rigCameras: Camera[];
  7731. /** @hidden */
  7732. _rigPostProcess: Nullable<PostProcess>;
  7733. protected _webvrViewMatrix: Matrix;
  7734. /** @hidden */
  7735. _skipRendering: boolean;
  7736. /** @hidden */
  7737. _alternateCamera: Camera;
  7738. /** @hidden */
  7739. _projectionMatrix: Matrix;
  7740. /** @hidden */
  7741. _postProcesses: Nullable<PostProcess>[];
  7742. /** @hidden */
  7743. _activeMeshes: SmartArray<AbstractMesh>;
  7744. protected _globalPosition: Vector3;
  7745. /** hidden */
  7746. _computedViewMatrix: Matrix;
  7747. private _doNotComputeProjectionMatrix;
  7748. private _transformMatrix;
  7749. private _frustumPlanes;
  7750. private _refreshFrustumPlanes;
  7751. private _storedFov;
  7752. private _stateStored;
  7753. /**
  7754. * Instantiates a new camera object.
  7755. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  7756. * @see http://doc.babylonjs.com/features/cameras
  7757. * @param name Defines the name of the camera in the scene
  7758. * @param position Defines the position of the camera
  7759. * @param scene Defines the scene the camera belongs too
  7760. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  7761. */
  7762. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7763. /**
  7764. * Store current camera state (fov, position, etc..)
  7765. * @returns the camera
  7766. */
  7767. storeState(): Camera;
  7768. /**
  7769. * Restores the camera state values if it has been stored. You must call storeState() first
  7770. */
  7771. protected _restoreStateValues(): boolean;
  7772. /**
  7773. * Restored camera state. You must call storeState() first.
  7774. * @returns true if restored and false otherwise
  7775. */
  7776. restoreState(): boolean;
  7777. /**
  7778. * Gets the class name of the camera.
  7779. * @returns the class name
  7780. */
  7781. getClassName(): string;
  7782. /**
  7783. * Gets a string representation of the camera useful for debug purpose.
  7784. * @param fullDetails Defines that a more verboe level of logging is required
  7785. * @returns the string representation
  7786. */
  7787. toString(fullDetails?: boolean): string;
  7788. /**
  7789. * Gets the current world space position of the camera.
  7790. */
  7791. readonly globalPosition: Vector3;
  7792. /**
  7793. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  7794. * @returns the active meshe list
  7795. */
  7796. getActiveMeshes(): SmartArray<AbstractMesh>;
  7797. /**
  7798. * Check wether a mesh is part of the current active mesh list of the camera
  7799. * @param mesh Defines the mesh to check
  7800. * @returns true if active, false otherwise
  7801. */
  7802. isActiveMesh(mesh: Mesh): boolean;
  7803. /**
  7804. * Is this camera ready to be used/rendered
  7805. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  7806. * @return true if the camera is ready
  7807. */
  7808. isReady(completeCheck?: boolean): boolean;
  7809. /** @hidden */
  7810. _initCache(): void;
  7811. /** @hidden */
  7812. _updateCache(ignoreParentClass?: boolean): void;
  7813. /** @hidden */
  7814. _isSynchronized(): boolean;
  7815. /** @hidden */
  7816. _isSynchronizedViewMatrix(): boolean;
  7817. /** @hidden */
  7818. _isSynchronizedProjectionMatrix(): boolean;
  7819. /**
  7820. * Attach the input controls to a specific dom element to get the input from.
  7821. * @param element Defines the element the controls should be listened from
  7822. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7823. */
  7824. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7825. /**
  7826. * Detach the current controls from the specified dom element.
  7827. * @param element Defines the element to stop listening the inputs from
  7828. */
  7829. detachControl(element: HTMLElement): void;
  7830. /**
  7831. * Update the camera state according to the different inputs gathered during the frame.
  7832. */
  7833. update(): void;
  7834. /** @hidden */
  7835. _checkInputs(): void;
  7836. /** @hidden */
  7837. readonly rigCameras: Camera[];
  7838. /**
  7839. * Gets the post process used by the rig cameras
  7840. */
  7841. readonly rigPostProcess: Nullable<PostProcess>;
  7842. /**
  7843. * Internal, gets the first post proces.
  7844. * @returns the first post process to be run on this camera.
  7845. */
  7846. _getFirstPostProcess(): Nullable<PostProcess>;
  7847. private _cascadePostProcessesToRigCams;
  7848. /**
  7849. * Attach a post process to the camera.
  7850. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7851. * @param postProcess The post process to attach to the camera
  7852. * @param insertAt The position of the post process in case several of them are in use in the scene
  7853. * @returns the position the post process has been inserted at
  7854. */
  7855. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  7856. /**
  7857. * Detach a post process to the camera.
  7858. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  7859. * @param postProcess The post process to detach from the camera
  7860. */
  7861. detachPostProcess(postProcess: PostProcess): void;
  7862. /**
  7863. * Gets the current world matrix of the camera
  7864. */
  7865. getWorldMatrix(): Matrix;
  7866. /** @hidden */
  7867. protected _getViewMatrix(): Matrix;
  7868. /**
  7869. * Gets the current view matrix of the camera.
  7870. * @param force forces the camera to recompute the matrix without looking at the cached state
  7871. * @returns the view matrix
  7872. */
  7873. getViewMatrix(force?: boolean): Matrix;
  7874. /**
  7875. * Freeze the projection matrix.
  7876. * It will prevent the cache check of the camera projection compute and can speed up perf
  7877. * if no parameter of the camera are meant to change
  7878. * @param projection Defines manually a projection if necessary
  7879. */
  7880. freezeProjectionMatrix(projection?: Matrix): void;
  7881. /**
  7882. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  7883. */
  7884. unfreezeProjectionMatrix(): void;
  7885. /**
  7886. * Gets the current projection matrix of the camera.
  7887. * @param force forces the camera to recompute the matrix without looking at the cached state
  7888. * @returns the projection matrix
  7889. */
  7890. getProjectionMatrix(force?: boolean): Matrix;
  7891. /**
  7892. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  7893. * @returns a Matrix
  7894. */
  7895. getTransformationMatrix(): Matrix;
  7896. private _updateFrustumPlanes;
  7897. /**
  7898. * Checks if a cullable object (mesh...) is in the camera frustum
  7899. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  7900. * @param target The object to check
  7901. * @returns true if the object is in frustum otherwise false
  7902. */
  7903. isInFrustum(target: ICullable): boolean;
  7904. /**
  7905. * Checks if a cullable object (mesh...) is in the camera frustum
  7906. * Unlike isInFrustum this cheks the full bounding box
  7907. * @param target The object to check
  7908. * @returns true if the object is in frustum otherwise false
  7909. */
  7910. isCompletelyInFrustum(target: ICullable): boolean;
  7911. /**
  7912. * Gets a ray in the forward direction from the camera.
  7913. * @param length Defines the length of the ray to create
  7914. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  7915. * @param origin Defines the start point of the ray which defaults to the camera position
  7916. * @returns the forward ray
  7917. */
  7918. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  7919. /**
  7920. * Releases resources associated with this node.
  7921. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7922. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7923. */
  7924. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7925. /**
  7926. * Gets the left camera of a rig setup in case of Rigged Camera
  7927. */
  7928. readonly leftCamera: Nullable<FreeCamera>;
  7929. /**
  7930. * Gets the right camera of a rig setup in case of Rigged Camera
  7931. */
  7932. readonly rightCamera: Nullable<FreeCamera>;
  7933. /**
  7934. * Gets the left camera target of a rig setup in case of Rigged Camera
  7935. * @returns the target position
  7936. */
  7937. getLeftTarget(): Nullable<Vector3>;
  7938. /**
  7939. * Gets the right camera target of a rig setup in case of Rigged Camera
  7940. * @returns the target position
  7941. */
  7942. getRightTarget(): Nullable<Vector3>;
  7943. /**
  7944. * @hidden
  7945. */
  7946. setCameraRigMode(mode: number, rigParams: any): void;
  7947. private _getVRProjectionMatrix;
  7948. protected _updateCameraRotationMatrix(): void;
  7949. protected _updateWebVRCameraRotationMatrix(): void;
  7950. /**
  7951. * This function MUST be overwritten by the different WebVR cameras available.
  7952. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7953. */
  7954. protected _getWebVRProjectionMatrix(): Matrix;
  7955. /**
  7956. * This function MUST be overwritten by the different WebVR cameras available.
  7957. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  7958. */
  7959. protected _getWebVRViewMatrix(): Matrix;
  7960. /** @hidden */
  7961. setCameraRigParameter(name: string, value: any): void;
  7962. /**
  7963. * needs to be overridden by children so sub has required properties to be copied
  7964. * @hidden
  7965. */
  7966. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7967. /**
  7968. * May need to be overridden by children
  7969. * @hidden
  7970. */
  7971. _updateRigCameras(): void;
  7972. /** @hidden */
  7973. _setupInputs(): void;
  7974. /**
  7975. * Serialiaze the camera setup to a json represention
  7976. * @returns the JSON representation
  7977. */
  7978. serialize(): any;
  7979. /**
  7980. * Clones the current camera.
  7981. * @param name The cloned camera name
  7982. * @returns the cloned camera
  7983. */
  7984. clone(name: string): Camera;
  7985. /**
  7986. * Gets the direction of the camera relative to a given local axis.
  7987. * @param localAxis Defines the reference axis to provide a relative direction.
  7988. * @return the direction
  7989. */
  7990. getDirection(localAxis: Vector3): Vector3;
  7991. /**
  7992. * Gets the direction of the camera relative to a given local axis into a passed vector.
  7993. * @param localAxis Defines the reference axis to provide a relative direction.
  7994. * @param result Defines the vector to store the result in
  7995. */
  7996. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  7997. /**
  7998. * Gets a camera constructor for a given camera type
  7999. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  8000. * @param name The name of the camera the result will be able to instantiate
  8001. * @param scene The scene the result will construct the camera in
  8002. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  8003. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  8004. * @returns a factory method to construc the camera
  8005. */
  8006. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  8007. /**
  8008. * Compute the world matrix of the camera.
  8009. * @returns the camera workd matrix
  8010. */
  8011. computeWorldMatrix(): Matrix;
  8012. /**
  8013. * Parse a JSON and creates the camera from the parsed information
  8014. * @param parsedCamera The JSON to parse
  8015. * @param scene The scene to instantiate the camera in
  8016. * @returns the newly constructed camera
  8017. */
  8018. static Parse(parsedCamera: any, scene: Scene): Camera;
  8019. }
  8020. }
  8021. declare module BABYLON {
  8022. /**
  8023. * @ignore
  8024. * This is a list of all the different input types that are available in the application.
  8025. * Fo instance: ArcRotateCameraGamepadInput...
  8026. */
  8027. var CameraInputTypes: {};
  8028. /**
  8029. * This is the contract to implement in order to create a new input class.
  8030. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8031. */
  8032. interface ICameraInput<TCamera extends Camera> {
  8033. /**
  8034. * Defines the camera the input is attached to.
  8035. */
  8036. camera: Nullable<TCamera>;
  8037. /**
  8038. * Gets the class name of the current intput.
  8039. * @returns the class name
  8040. */
  8041. getClassName(): string;
  8042. /**
  8043. * Get the friendly name associated with the input class.
  8044. * @returns the input friendly name
  8045. */
  8046. getSimpleName(): string;
  8047. /**
  8048. * Attach the input controls to a specific dom element to get the input from.
  8049. * @param element Defines the element the controls should be listened from
  8050. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8051. */
  8052. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8053. /**
  8054. * Detach the current controls from the specified dom element.
  8055. * @param element Defines the element to stop listening the inputs from
  8056. */
  8057. detachControl(element: Nullable<HTMLElement>): void;
  8058. /**
  8059. * Update the current camera state depending on the inputs that have been used this frame.
  8060. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8061. */
  8062. checkInputs?: () => void;
  8063. }
  8064. /**
  8065. * Represents a map of input types to input instance or input index to input instance.
  8066. */
  8067. interface CameraInputsMap<TCamera extends Camera> {
  8068. /**
  8069. * Accessor to the input by input type.
  8070. */
  8071. [name: string]: ICameraInput<TCamera>;
  8072. /**
  8073. * Accessor to the input by input index.
  8074. */
  8075. [idx: number]: ICameraInput<TCamera>;
  8076. }
  8077. /**
  8078. * This represents the input manager used within a camera.
  8079. * It helps dealing with all the different kind of input attached to a camera.
  8080. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8081. */
  8082. class CameraInputsManager<TCamera extends Camera> {
  8083. /**
  8084. * Defines the list of inputs attahed to the camera.
  8085. */
  8086. attached: CameraInputsMap<TCamera>;
  8087. /**
  8088. * Defines the dom element the camera is collecting inputs from.
  8089. * This is null if the controls have not been attached.
  8090. */
  8091. attachedElement: Nullable<HTMLElement>;
  8092. /**
  8093. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8094. */
  8095. noPreventDefault: boolean;
  8096. /**
  8097. * Defined the camera the input manager belongs to.
  8098. */
  8099. camera: TCamera;
  8100. /**
  8101. * Update the current camera state depending on the inputs that have been used this frame.
  8102. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8103. */
  8104. checkInputs: () => void;
  8105. /**
  8106. * Instantiate a new Camera Input Manager.
  8107. * @param camera Defines the camera the input manager blongs to
  8108. */
  8109. constructor(camera: TCamera);
  8110. /**
  8111. * Add an input method to a camera
  8112. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8113. * @param input camera input method
  8114. */
  8115. add(input: ICameraInput<TCamera>): void;
  8116. /**
  8117. * Remove a specific input method from a camera
  8118. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8119. * @param inputToRemove camera input method
  8120. */
  8121. remove(inputToRemove: ICameraInput<TCamera>): void;
  8122. /**
  8123. * Remove a specific input type from a camera
  8124. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8125. * @param inputType the type of the input to remove
  8126. */
  8127. removeByType(inputType: string): void;
  8128. private _addCheckInputs;
  8129. /**
  8130. * Attach the input controls to the currently attached dom element to listen the events from.
  8131. * @param input Defines the input to attach
  8132. */
  8133. attachInput(input: ICameraInput<TCamera>): void;
  8134. /**
  8135. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8136. * @param element Defines the dom element to collect the events from
  8137. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8138. */
  8139. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8140. /**
  8141. * Detach the current manager inputs controls from a specific dom element.
  8142. * @param element Defines the dom element to collect the events from
  8143. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8144. */
  8145. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8146. /**
  8147. * Rebuild the dynamic inputCheck function from the current list of
  8148. * defined inputs in the manager.
  8149. */
  8150. rebuildInputCheck(): void;
  8151. /**
  8152. * Remove all attached input methods from a camera
  8153. */
  8154. clear(): void;
  8155. /**
  8156. * Serialize the current input manager attached to a camera.
  8157. * This ensures than once parsed,
  8158. * the input associated to the camera will be identical to the current ones
  8159. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8160. */
  8161. serialize(serializedCamera: any): void;
  8162. /**
  8163. * Parses an input manager serialized JSON to restore the previous list of inputs
  8164. * and states associated to a camera.
  8165. * @param parsedCamera Defines the JSON to parse
  8166. */
  8167. parse(parsedCamera: any): void;
  8168. }
  8169. }
  8170. declare module BABYLON {
  8171. /**
  8172. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  8173. * being tilted forward or back and left or right.
  8174. */
  8175. class DeviceOrientationCamera extends FreeCamera {
  8176. private _initialQuaternion;
  8177. private _quaternionCache;
  8178. /**
  8179. * Creates a new device orientation camera
  8180. * @param name The name of the camera
  8181. * @param position The start position camera
  8182. * @param scene The scene the camera belongs to
  8183. */
  8184. constructor(name: string, position: Vector3, scene: Scene);
  8185. /**
  8186. * Gets the current instance class name ("DeviceOrientationCamera").
  8187. * This helps avoiding instanceof at run time.
  8188. * @returns the class name
  8189. */
  8190. getClassName(): string;
  8191. /**
  8192. * @hidden
  8193. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  8194. */
  8195. _checkInputs(): void;
  8196. /**
  8197. * Reset the camera to its default orientation on the specified axis only.
  8198. * @param axis The axis to reset
  8199. */
  8200. resetToCurrentRotation(axis?: Axis): void;
  8201. }
  8202. }
  8203. declare module BABYLON {
  8204. /**
  8205. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8206. * such as in a 3D Space Shooter or a Flight Simulator.
  8207. */
  8208. class FlyCamera extends TargetCamera {
  8209. /**
  8210. * Define the collision ellipsoid of the camera.
  8211. * This is helpful for simulating a camera body, like a player's body.
  8212. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8213. */
  8214. ellipsoid: Vector3;
  8215. /**
  8216. * Define an offset for the position of the ellipsoid around the camera.
  8217. * This can be helpful if the camera is attached away from the player's body center,
  8218. * such as at its head.
  8219. */
  8220. ellipsoidOffset: Vector3;
  8221. /**
  8222. * Enable or disable collisions of the camera with the rest of the scene objects.
  8223. */
  8224. checkCollisions: boolean;
  8225. /**
  8226. * Enable or disable gravity on the camera.
  8227. */
  8228. applyGravity: boolean;
  8229. /**
  8230. * Define the current direction the camera is moving to.
  8231. */
  8232. cameraDirection: Vector3;
  8233. /**
  8234. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  8235. * This overrides and empties cameraRotation.
  8236. */
  8237. rotationQuaternion: BABYLON.Quaternion;
  8238. /**
  8239. * Track Roll to maintain the wanted Rolling when looking around.
  8240. */
  8241. _trackRoll: number;
  8242. /**
  8243. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  8244. */
  8245. rollCorrect: number;
  8246. /**
  8247. * Mimic a banked turn, Rolling the camera when Yawing.
  8248. * It's recommended to use rollCorrect = 10 for faster banking correction.
  8249. */
  8250. bankedTurn: boolean;
  8251. /**
  8252. * Limit in radians for how much Roll banking will add. (Default: 90°)
  8253. */
  8254. bankedTurnLimit: number;
  8255. /**
  8256. * Value of 0 disables the banked Roll.
  8257. * Value of 1 is equal to the Yaw angle in radians.
  8258. */
  8259. bankedTurnMultiplier: number;
  8260. /**
  8261. * The inputs manager loads all the input sources, such as keyboard and mouse.
  8262. */
  8263. inputs: FlyCameraInputsManager;
  8264. /**
  8265. * Gets the input sensibility for mouse input.
  8266. * Higher values reduce sensitivity.
  8267. */
  8268. /**
  8269. * Sets the input sensibility for a mouse input.
  8270. * Higher values reduce sensitivity.
  8271. */
  8272. angularSensibility: number;
  8273. /**
  8274. * Get the keys for camera movement forward.
  8275. */
  8276. /**
  8277. * Set the keys for camera movement forward.
  8278. */
  8279. keysForward: number[];
  8280. /**
  8281. * Get the keys for camera movement backward.
  8282. */
  8283. keysBackward: number[];
  8284. /**
  8285. * Get the keys for camera movement up.
  8286. */
  8287. /**
  8288. * Set the keys for camera movement up.
  8289. */
  8290. keysUp: number[];
  8291. /**
  8292. * Get the keys for camera movement down.
  8293. */
  8294. /**
  8295. * Set the keys for camera movement down.
  8296. */
  8297. keysDown: number[];
  8298. /**
  8299. * Get the keys for camera movement left.
  8300. */
  8301. /**
  8302. * Set the keys for camera movement left.
  8303. */
  8304. keysLeft: number[];
  8305. /**
  8306. * Set the keys for camera movement right.
  8307. */
  8308. /**
  8309. * Set the keys for camera movement right.
  8310. */
  8311. keysRight: number[];
  8312. /**
  8313. * Event raised when the camera collides with a mesh in the scene.
  8314. */
  8315. onCollide: (collidedMesh: AbstractMesh) => void;
  8316. private _collider;
  8317. private _needMoveForGravity;
  8318. private _oldPosition;
  8319. private _diffPosition;
  8320. private _newPosition;
  8321. /** @hidden */
  8322. _localDirection: Vector3;
  8323. /** @hidden */
  8324. _transformedDirection: Vector3;
  8325. /**
  8326. * Instantiates a FlyCamera.
  8327. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8328. * such as in a 3D Space Shooter or a Flight Simulator.
  8329. * @param name Define the name of the camera in the scene.
  8330. * @param position Define the starting position of the camera in the scene.
  8331. * @param scene Define the scene the camera belongs to.
  8332. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  8333. */
  8334. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8335. /**
  8336. * Attach a control to the HTML DOM element.
  8337. * @param element Defines the element that listens to the input events.
  8338. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  8339. */
  8340. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8341. /**
  8342. * Detach a control from the HTML DOM element.
  8343. * The camera will stop reacting to that input.
  8344. * @param element Defines the element that listens to the input events.
  8345. */
  8346. detachControl(element: HTMLElement): void;
  8347. private _collisionMask;
  8348. /**
  8349. * Get the mask that the camera ignores in collision events.
  8350. */
  8351. /**
  8352. * Set the mask that the camera ignores in collision events.
  8353. */
  8354. collisionMask: number;
  8355. /** @hidden */
  8356. _collideWithWorld(displacement: Vector3): void;
  8357. /** @hidden */
  8358. private _onCollisionPositionChange;
  8359. /** @hidden */
  8360. _checkInputs(): void;
  8361. /** @hidden */
  8362. _decideIfNeedsToMove(): boolean;
  8363. /** @hidden */
  8364. _updatePosition(): void;
  8365. /**
  8366. * Restore the Roll to its target value at the rate specified.
  8367. * @param rate - Higher means slower restoring.
  8368. * @hidden
  8369. */
  8370. restoreRoll(rate: number): void;
  8371. /**
  8372. * Destroy the camera and release the current resources held by it.
  8373. */
  8374. dispose(): void;
  8375. /**
  8376. * Get the current object class name.
  8377. * @returns the class name.
  8378. */
  8379. getClassName(): string;
  8380. }
  8381. }
  8382. declare module BABYLON {
  8383. /**
  8384. * Default Inputs manager for the FlyCamera.
  8385. * It groups all the default supported inputs for ease of use.
  8386. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8387. */
  8388. class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  8389. /**
  8390. * Instantiates a new FlyCameraInputsManager.
  8391. * @param camera Defines the camera the inputs belong to.
  8392. */
  8393. constructor(camera: FlyCamera);
  8394. /**
  8395. * Add keyboard input support to the input manager.
  8396. * @returns the new FlyCameraKeyboardMoveInput().
  8397. */
  8398. addKeyboard(): FlyCameraInputsManager;
  8399. /**
  8400. * Add mouse input support to the input manager.
  8401. * @param touchEnabled Enable touch screen support.
  8402. * @returns the new FlyCameraMouseInput().
  8403. */
  8404. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  8405. }
  8406. }
  8407. declare module BABYLON {
  8408. /**
  8409. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  8410. * an arc rotate version arcFollowCamera are available.
  8411. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8412. */
  8413. class FollowCamera extends TargetCamera {
  8414. /**
  8415. * Distance the follow camera should follow an object at
  8416. */
  8417. radius: number;
  8418. /**
  8419. * Define a rotation offset between the camera and the object it follows
  8420. */
  8421. rotationOffset: number;
  8422. /**
  8423. * Define a height offset between the camera and the object it follows.
  8424. * It can help following an object from the top (like a car chaing a plane)
  8425. */
  8426. heightOffset: number;
  8427. /**
  8428. * Define how fast the camera can accelerate to follow it s target.
  8429. */
  8430. cameraAcceleration: number;
  8431. /**
  8432. * Define the speed limit of the camera following an object.
  8433. */
  8434. maxCameraSpeed: number;
  8435. /**
  8436. * Define the target of the camera.
  8437. */
  8438. lockedTarget: Nullable<AbstractMesh>;
  8439. /**
  8440. * Instantiates the follow camera.
  8441. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8442. * @param name Define the name of the camera in the scene
  8443. * @param position Define the position of the camera
  8444. * @param scene Define the scene the camera belong to
  8445. * @param lockedTarget Define the target of the camera
  8446. */
  8447. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  8448. private _follow;
  8449. /** @hidden */
  8450. _checkInputs(): void;
  8451. /**
  8452. * Gets the camera class name.
  8453. * @returns the class name
  8454. */
  8455. getClassName(): string;
  8456. }
  8457. /**
  8458. * Arc Rotate version of the follow camera.
  8459. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  8460. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8461. */
  8462. class ArcFollowCamera extends TargetCamera {
  8463. /** The longitudinal angle of the camera */
  8464. alpha: number;
  8465. /** The latitudinal angle of the camera */
  8466. beta: number;
  8467. /** The radius of the camera from its target */
  8468. radius: number;
  8469. /** Define the camera target (the messh it should follow) */
  8470. target: Nullable<AbstractMesh>;
  8471. private _cartesianCoordinates;
  8472. /**
  8473. * Instantiates a new ArcFollowCamera
  8474. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8475. * @param name Define the name of the camera
  8476. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  8477. * @param beta Define the rotation angle of the camera around the elevation axis
  8478. * @param radius Define the radius of the camera from its target point
  8479. * @param target Define the target of the camera
  8480. * @param scene Define the scene the camera belongs to
  8481. */
  8482. constructor(name: string,
  8483. /** The longitudinal angle of the camera */
  8484. alpha: number,
  8485. /** The latitudinal angle of the camera */
  8486. beta: number,
  8487. /** The radius of the camera from its target */
  8488. radius: number,
  8489. /** Define the camera target (the messh it should follow) */
  8490. target: Nullable<AbstractMesh>, scene: Scene);
  8491. private _follow;
  8492. /** @hidden */
  8493. _checkInputs(): void;
  8494. /**
  8495. * Returns the class name of the object.
  8496. * It is mostly used internally for serialization purposes.
  8497. */
  8498. getClassName(): string;
  8499. }
  8500. }
  8501. declare module BABYLON {
  8502. /**
  8503. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8504. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8505. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8506. */
  8507. class FreeCamera extends TargetCamera {
  8508. /**
  8509. * Define the collision ellipsoid of the camera.
  8510. * This is helpful to simulate a camera body like the player body around the camera
  8511. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8512. */
  8513. ellipsoid: Vector3;
  8514. /**
  8515. * Define an offset for the position of the ellipsoid around the camera.
  8516. * This can be helpful to determine the center of the body near the gravity center of the body
  8517. * instead of its head.
  8518. */
  8519. ellipsoidOffset: Vector3;
  8520. /**
  8521. * Enable or disable collisions of the camera with the rest of the scene objects.
  8522. */
  8523. checkCollisions: boolean;
  8524. /**
  8525. * Enable or disable gravity on the camera.
  8526. */
  8527. applyGravity: boolean;
  8528. /**
  8529. * Define the input manager associated to the camera.
  8530. */
  8531. inputs: FreeCameraInputsManager;
  8532. /**
  8533. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8534. * Higher values reduce sensitivity.
  8535. */
  8536. /**
  8537. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8538. * Higher values reduce sensitivity.
  8539. */
  8540. angularSensibility: number;
  8541. /**
  8542. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8543. */
  8544. keysUp: number[];
  8545. /**
  8546. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8547. */
  8548. keysDown: number[];
  8549. /**
  8550. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8551. */
  8552. keysLeft: number[];
  8553. /**
  8554. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8555. */
  8556. keysRight: number[];
  8557. /**
  8558. * Event raised when the camera collide with a mesh in the scene.
  8559. */
  8560. onCollide: (collidedMesh: AbstractMesh) => void;
  8561. private _collider;
  8562. private _needMoveForGravity;
  8563. private _oldPosition;
  8564. private _diffPosition;
  8565. private _newPosition;
  8566. /** @hidden */
  8567. _localDirection: Vector3;
  8568. /** @hidden */
  8569. _transformedDirection: Vector3;
  8570. /**
  8571. * Instantiates a Free Camera.
  8572. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8573. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8574. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8575. * @param name Define the name of the camera in the scene
  8576. * @param position Define the start position of the camera in the scene
  8577. * @param scene Define the scene the camera belongs to
  8578. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8579. */
  8580. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8581. /**
  8582. * Attached controls to the current camera.
  8583. * @param element Defines the element the controls should be listened from
  8584. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8585. */
  8586. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8587. /**
  8588. * Detach the current controls from the camera.
  8589. * The camera will stop reacting to inputs.
  8590. * @param element Defines the element to stop listening the inputs from
  8591. */
  8592. detachControl(element: HTMLElement): void;
  8593. private _collisionMask;
  8594. /**
  8595. * Define a collision mask to limit the list of object the camera can collide with
  8596. */
  8597. collisionMask: number;
  8598. /** @hidden */
  8599. _collideWithWorld(displacement: Vector3): void;
  8600. private _onCollisionPositionChange;
  8601. /** @hidden */
  8602. _checkInputs(): void;
  8603. /** @hidden */
  8604. _decideIfNeedsToMove(): boolean;
  8605. /** @hidden */
  8606. _updatePosition(): void;
  8607. /**
  8608. * Destroy the camera and release the current resources hold by it.
  8609. */
  8610. dispose(): void;
  8611. /**
  8612. * Gets the current object class name.
  8613. * @return the class name
  8614. */
  8615. getClassName(): string;
  8616. }
  8617. }
  8618. declare module BABYLON {
  8619. /**
  8620. * Default Inputs manager for the FreeCamera.
  8621. * It groups all the default supported inputs for ease of use.
  8622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8623. */
  8624. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8625. /**
  8626. * Instantiates a new FreeCameraInputsManager.
  8627. * @param camera Defines the camera the inputs belong to
  8628. */
  8629. constructor(camera: FreeCamera);
  8630. /**
  8631. * Add keyboard input support to the input manager.
  8632. * @returns the current input manager
  8633. */
  8634. addKeyboard(): FreeCameraInputsManager;
  8635. /**
  8636. * Add mouse input support to the input manager.
  8637. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8638. * @returns the current input manager
  8639. */
  8640. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8641. /**
  8642. * Add orientation input support to the input manager.
  8643. * @returns the current input manager
  8644. */
  8645. addDeviceOrientation(): FreeCameraInputsManager;
  8646. /**
  8647. * Add touch input support to the input manager.
  8648. * @returns the current input manager
  8649. */
  8650. addTouch(): FreeCameraInputsManager;
  8651. /**
  8652. * Add virtual joystick input support to the input manager.
  8653. * @returns the current input manager
  8654. */
  8655. addVirtualJoystick(): FreeCameraInputsManager;
  8656. }
  8657. }
  8658. declare module BABYLON {
  8659. /**
  8660. * This represents a FPS type of camera. This is only here for back compat purpose.
  8661. * Please use the UniversalCamera instead as both are identical.
  8662. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8663. */
  8664. class GamepadCamera extends UniversalCamera {
  8665. /**
  8666. * Instantiates a new Gamepad Camera
  8667. * This represents a FPS type of camera. This is only here for back compat purpose.
  8668. * Please use the UniversalCamera instead as both are identical.
  8669. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8670. * @param name Define the name of the camera in the scene
  8671. * @param position Define the start position of the camera in the scene
  8672. * @param scene Define the scene the camera belongs to
  8673. */
  8674. constructor(name: string, position: Vector3, scene: Scene);
  8675. /**
  8676. * Gets the current object class name.
  8677. * @return the class name
  8678. */
  8679. getClassName(): string;
  8680. }
  8681. }
  8682. declare module BABYLON {
  8683. /**
  8684. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8685. * This is the base of the follow, arc rotate cameras and Free camera
  8686. * @see http://doc.babylonjs.com/features/cameras
  8687. */
  8688. class TargetCamera extends Camera {
  8689. private static _RigCamTransformMatrix;
  8690. private static _TargetTransformMatrix;
  8691. private static _TargetFocalPoint;
  8692. /**
  8693. * Define the current direction the camera is moving to
  8694. */
  8695. cameraDirection: Vector3;
  8696. /**
  8697. * Define the current rotation the camera is rotating to
  8698. */
  8699. cameraRotation: Vector2;
  8700. /**
  8701. * When set, the up vector of the camera will be updated by the rotation of the camera
  8702. */
  8703. updateUpVectorFromRotation: boolean;
  8704. private _tmpQuaternion;
  8705. /**
  8706. * Define the current rotation of the camera
  8707. */
  8708. rotation: Vector3;
  8709. /**
  8710. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8711. */
  8712. rotationQuaternion: Quaternion;
  8713. /**
  8714. * Define the current speed of the camera
  8715. */
  8716. speed: number;
  8717. /**
  8718. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8719. * around all axis.
  8720. */
  8721. noRotationConstraint: boolean;
  8722. /**
  8723. * Define the current target of the camera as an object or a position.
  8724. */
  8725. lockedTarget: any;
  8726. /** @hidden */
  8727. _currentTarget: Vector3;
  8728. /** @hidden */
  8729. _initialFocalDistance: number;
  8730. /** @hidden */
  8731. _viewMatrix: Matrix;
  8732. /** @hidden */
  8733. _camMatrix: Matrix;
  8734. /** @hidden */
  8735. _cameraTransformMatrix: Matrix;
  8736. /** @hidden */
  8737. _cameraRotationMatrix: Matrix;
  8738. /** @hidden */
  8739. _referencePoint: Vector3;
  8740. /** @hidden */
  8741. _transformedReferencePoint: Vector3;
  8742. protected _globalCurrentTarget: Vector3;
  8743. protected _globalCurrentUpVector: Vector3;
  8744. /** @hidden */
  8745. _reset: () => void;
  8746. private _defaultUp;
  8747. /**
  8748. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8749. * This is the base of the follow, arc rotate cameras and Free camera
  8750. * @see http://doc.babylonjs.com/features/cameras
  8751. * @param name Defines the name of the camera in the scene
  8752. * @param position Defines the start position of the camera in the scene
  8753. * @param scene Defines the scene the camera belongs to
  8754. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8755. */
  8756. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8757. /**
  8758. * Gets the position in front of the camera at a given distance.
  8759. * @param distance The distance from the camera we want the position to be
  8760. * @returns the position
  8761. */
  8762. getFrontPosition(distance: number): Vector3;
  8763. /** @hidden */
  8764. _getLockedTargetPosition(): Nullable<Vector3>;
  8765. private _storedPosition;
  8766. private _storedRotation;
  8767. private _storedRotationQuaternion;
  8768. /**
  8769. * Store current camera state of the camera (fov, position, rotation, etc..)
  8770. * @returns the camera
  8771. */
  8772. storeState(): Camera;
  8773. /**
  8774. * Restored camera state. You must call storeState() first
  8775. * @returns whether it was successful or not
  8776. * @hidden
  8777. */
  8778. _restoreStateValues(): boolean;
  8779. /** @hidden */
  8780. _initCache(): void;
  8781. /** @hidden */
  8782. _updateCache(ignoreParentClass?: boolean): void;
  8783. /** @hidden */
  8784. _isSynchronizedViewMatrix(): boolean;
  8785. /** @hidden */
  8786. _computeLocalCameraSpeed(): number;
  8787. /** @hidden */
  8788. setTarget(target: Vector3): void;
  8789. /**
  8790. * Return the current target position of the camera. This value is expressed in local space.
  8791. * @returns the target position
  8792. */
  8793. getTarget(): Vector3;
  8794. /** @hidden */
  8795. _decideIfNeedsToMove(): boolean;
  8796. /** @hidden */
  8797. _updatePosition(): void;
  8798. /** @hidden */
  8799. _checkInputs(): void;
  8800. protected _updateCameraRotationMatrix(): void;
  8801. /**
  8802. * 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)
  8803. * @returns the current camera
  8804. */
  8805. private _rotateUpVectorWithCameraRotationMatrix;
  8806. private _cachedRotationZ;
  8807. private _cachedQuaternionRotationZ;
  8808. /** @hidden */
  8809. _getViewMatrix(): Matrix;
  8810. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8811. /**
  8812. * @hidden
  8813. */
  8814. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8815. /**
  8816. * @hidden
  8817. */
  8818. _updateRigCameras(): void;
  8819. private _getRigCamPositionAndTarget;
  8820. /**
  8821. * Gets the current object class name.
  8822. * @return the class name
  8823. */
  8824. getClassName(): string;
  8825. }
  8826. }
  8827. declare module BABYLON {
  8828. /**
  8829. * This represents a FPS type of camera controlled by touch.
  8830. * This is like a universal camera minus the Gamepad controls.
  8831. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8832. */
  8833. class TouchCamera extends FreeCamera {
  8834. /**
  8835. * Defines the touch sensibility for rotation.
  8836. * The higher the faster.
  8837. */
  8838. touchAngularSensibility: number;
  8839. /**
  8840. * Defines the touch sensibility for move.
  8841. * The higher the faster.
  8842. */
  8843. touchMoveSensibility: number;
  8844. /**
  8845. * Instantiates a new touch camera.
  8846. * This represents a FPS type of camera controlled by touch.
  8847. * This is like a universal camera minus the Gamepad controls.
  8848. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8849. * @param name Define the name of the camera in the scene
  8850. * @param position Define the start position of the camera in the scene
  8851. * @param scene Define the scene the camera belongs to
  8852. */
  8853. constructor(name: string, position: Vector3, scene: Scene);
  8854. /**
  8855. * Gets the current object class name.
  8856. * @return the class name
  8857. */
  8858. getClassName(): string;
  8859. /** @hidden */
  8860. _setupInputs(): void;
  8861. }
  8862. }
  8863. declare module BABYLON {
  8864. /**
  8865. * 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,
  8866. * which still works and will still be found in many Playgrounds.
  8867. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8868. */
  8869. class UniversalCamera extends TouchCamera {
  8870. /**
  8871. * Defines the gamepad rotation sensiblity.
  8872. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  8873. */
  8874. gamepadAngularSensibility: number;
  8875. /**
  8876. * Defines the gamepad move sensiblity.
  8877. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  8878. */
  8879. gamepadMoveSensibility: number;
  8880. /**
  8881. * 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,
  8882. * which still works and will still be found in many Playgrounds.
  8883. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8884. * @param name Define the name of the camera in the scene
  8885. * @param position Define the start position of the camera in the scene
  8886. * @param scene Define the scene the camera belongs to
  8887. */
  8888. constructor(name: string, position: Vector3, scene: Scene);
  8889. /**
  8890. * Gets the current object class name.
  8891. * @return the class name
  8892. */
  8893. getClassName(): string;
  8894. }
  8895. }
  8896. declare module BABYLON {
  8897. /**
  8898. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8899. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8900. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8901. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8902. */
  8903. class VirtualJoysticksCamera extends FreeCamera {
  8904. /**
  8905. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  8906. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  8907. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  8908. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  8909. * @param name Define the name of the camera in the scene
  8910. * @param position Define the start position of the camera in the scene
  8911. * @param scene Define the scene the camera belongs to
  8912. */
  8913. constructor(name: string, position: Vector3, scene: Scene);
  8914. /**
  8915. * Gets the current object class name.
  8916. * @return the class name
  8917. */
  8918. getClassName(): string;
  8919. }
  8920. }
  8921. interface VRDisplay extends EventTarget {
  8922. /**
  8923. * Dictionary of capabilities describing the VRDisplay.
  8924. */
  8925. readonly capabilities: VRDisplayCapabilities;
  8926. /**
  8927. * z-depth defining the far plane of the eye view frustum
  8928. * enables mapping of values in the render target depth
  8929. * attachment to scene coordinates. Initially set to 10000.0.
  8930. */
  8931. depthFar: number;
  8932. /**
  8933. * z-depth defining the near plane of the eye view frustum
  8934. * enables mapping of values in the render target depth
  8935. * attachment to scene coordinates. Initially set to 0.01.
  8936. */
  8937. depthNear: number;
  8938. /**
  8939. * An identifier for this distinct VRDisplay. Used as an
  8940. * association point in the Gamepad API.
  8941. */
  8942. readonly displayId: number;
  8943. /**
  8944. * A display name, a user-readable name identifying it.
  8945. */
  8946. readonly displayName: string;
  8947. readonly isConnected: boolean;
  8948. readonly isPresenting: boolean;
  8949. /**
  8950. * If this VRDisplay supports room-scale experiences, the optional
  8951. * stage attribute contains details on the room-scale parameters.
  8952. */
  8953. readonly stageParameters: VRStageParameters | null;
  8954. /**
  8955. * Passing the value returned by `requestAnimationFrame` to
  8956. * `cancelAnimationFrame` will unregister the callback.
  8957. * @param handle Define the hanle of the request to cancel
  8958. */
  8959. cancelAnimationFrame(handle: number): void;
  8960. /**
  8961. * Stops presenting to the VRDisplay.
  8962. * @returns a promise to know when it stopped
  8963. */
  8964. exitPresent(): Promise<void>;
  8965. /**
  8966. * Return the current VREyeParameters for the given eye.
  8967. * @param whichEye Define the eye we want the parameter for
  8968. * @returns the eye parameters
  8969. */
  8970. getEyeParameters(whichEye: string): VREyeParameters;
  8971. /**
  8972. * Populates the passed VRFrameData with the information required to render
  8973. * the current frame.
  8974. * @param frameData Define the data structure to populate
  8975. * @returns true if ok otherwise false
  8976. */
  8977. getFrameData(frameData: VRFrameData): boolean;
  8978. /**
  8979. * Get the layers currently being presented.
  8980. * @returns the list of VR layers
  8981. */
  8982. getLayers(): VRLayer[];
  8983. /**
  8984. * Return a VRPose containing the future predicted pose of the VRDisplay
  8985. * when the current frame will be presented. The value returned will not
  8986. * change until JavaScript has returned control to the browser.
  8987. *
  8988. * The VRPose will contain the position, orientation, velocity,
  8989. * and acceleration of each of these properties.
  8990. * @returns the pose object
  8991. */
  8992. getPose(): VRPose;
  8993. /**
  8994. * Return the current instantaneous pose of the VRDisplay, with no
  8995. * prediction applied.
  8996. * @returns the current instantaneous pose
  8997. */
  8998. getImmediatePose(): VRPose;
  8999. /**
  9000. * The callback passed to `requestAnimationFrame` will be called
  9001. * any time a new frame should be rendered. When the VRDisplay is
  9002. * presenting the callback will be called at the native refresh
  9003. * rate of the HMD. When not presenting this function acts
  9004. * identically to how window.requestAnimationFrame acts. Content should
  9005. * make no assumptions of frame rate or vsync behavior as the HMD runs
  9006. * asynchronously from other displays and at differing refresh rates.
  9007. * @param callback Define the eaction to run next frame
  9008. * @returns the request handle it
  9009. */
  9010. requestAnimationFrame(callback: FrameRequestCallback): number;
  9011. /**
  9012. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  9013. * Repeat calls while already presenting will update the VRLayers being displayed.
  9014. * @param layers Define the list of layer to present
  9015. * @returns a promise to know when the request has been fulfilled
  9016. */
  9017. requestPresent(layers: VRLayer[]): Promise<void>;
  9018. /**
  9019. * Reset the pose for this display, treating its current position and
  9020. * orientation as the "origin/zero" values. VRPose.position,
  9021. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  9022. * updated when calling resetPose(). This should be called in only
  9023. * sitting-space experiences.
  9024. */
  9025. resetPose(): void;
  9026. /**
  9027. * The VRLayer provided to the VRDisplay will be captured and presented
  9028. * in the HMD. Calling this function has the same effect on the source
  9029. * canvas as any other operation that uses its source image, and canvases
  9030. * created without preserveDrawingBuffer set to true will be cleared.
  9031. * @param pose Define the pose to submit
  9032. */
  9033. submitFrame(pose?: VRPose): void;
  9034. }
  9035. declare var VRDisplay: {
  9036. prototype: VRDisplay;
  9037. new (): VRDisplay;
  9038. };
  9039. interface VRLayer {
  9040. leftBounds?: number[] | Float32Array | null;
  9041. rightBounds?: number[] | Float32Array | null;
  9042. source?: HTMLCanvasElement | null;
  9043. }
  9044. interface VRDisplayCapabilities {
  9045. readonly canPresent: boolean;
  9046. readonly hasExternalDisplay: boolean;
  9047. readonly hasOrientation: boolean;
  9048. readonly hasPosition: boolean;
  9049. readonly maxLayers: number;
  9050. }
  9051. interface VREyeParameters {
  9052. /** @deprecated */
  9053. readonly fieldOfView: VRFieldOfView;
  9054. readonly offset: Float32Array;
  9055. readonly renderHeight: number;
  9056. readonly renderWidth: number;
  9057. }
  9058. interface VRFieldOfView {
  9059. readonly downDegrees: number;
  9060. readonly leftDegrees: number;
  9061. readonly rightDegrees: number;
  9062. readonly upDegrees: number;
  9063. }
  9064. interface VRFrameData {
  9065. readonly leftProjectionMatrix: Float32Array;
  9066. readonly leftViewMatrix: Float32Array;
  9067. readonly pose: VRPose;
  9068. readonly rightProjectionMatrix: Float32Array;
  9069. readonly rightViewMatrix: Float32Array;
  9070. readonly timestamp: number;
  9071. }
  9072. interface VRPose {
  9073. readonly angularAcceleration: Float32Array | null;
  9074. readonly angularVelocity: Float32Array | null;
  9075. readonly linearAcceleration: Float32Array | null;
  9076. readonly linearVelocity: Float32Array | null;
  9077. readonly orientation: Float32Array | null;
  9078. readonly position: Float32Array | null;
  9079. readonly timestamp: number;
  9080. }
  9081. interface VRStageParameters {
  9082. sittingToStandingTransform?: Float32Array;
  9083. sizeX?: number;
  9084. sizeY?: number;
  9085. }
  9086. interface Navigator {
  9087. getVRDisplays(): Promise<VRDisplay[]>;
  9088. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  9089. }
  9090. interface Window {
  9091. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  9092. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  9093. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  9094. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9095. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9096. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  9097. }
  9098. interface Gamepad {
  9099. readonly displayId: number;
  9100. }
  9101. declare module BABYLON {
  9102. /**
  9103. * Class used to store bounding box information
  9104. */
  9105. class BoundingBox implements ICullable {
  9106. /**
  9107. * Gets the 8 vectors representing the bounding box in local space
  9108. */
  9109. readonly vectors: Vector3[];
  9110. /**
  9111. * Gets the center of the bounding box in local space
  9112. */
  9113. readonly center: Vector3;
  9114. /**
  9115. * Gets the center of the bounding box in world space
  9116. */
  9117. readonly centerWorld: Vector3;
  9118. /**
  9119. * Gets the extend size in local space
  9120. */
  9121. readonly extendSize: Vector3;
  9122. /**
  9123. * Gets the extend size in world space
  9124. */
  9125. readonly extendSizeWorld: Vector3;
  9126. /**
  9127. * Gets the OBB (object bounding box) directions
  9128. */
  9129. readonly directions: Vector3[];
  9130. /**
  9131. * Gets the 8 vectors representing the bounding box in world space
  9132. */
  9133. readonly vectorsWorld: Vector3[];
  9134. /**
  9135. * Gets the minimum vector in world space
  9136. */
  9137. readonly minimumWorld: Vector3;
  9138. /**
  9139. * Gets the maximum vector in world space
  9140. */
  9141. readonly maximumWorld: Vector3;
  9142. /**
  9143. * Gets the minimum vector in local space
  9144. */
  9145. readonly minimum: Vector3;
  9146. /**
  9147. * Gets the maximum vector in local space
  9148. */
  9149. readonly maximum: Vector3;
  9150. private _worldMatrix;
  9151. private static readonly TmpVector3;
  9152. /**
  9153. * @hidden
  9154. */
  9155. _tag: number;
  9156. /**
  9157. * Creates a new bounding box
  9158. * @param min defines the minimum vector (in local space)
  9159. * @param max defines the maximum vector (in local space)
  9160. * @param worldMatrix defines the new world matrix
  9161. */
  9162. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  9163. /**
  9164. * Recreates the entire bounding box from scratch as if we call the constructor in place
  9165. * @param min defines the new minimum vector (in local space)
  9166. * @param max defines the new maximum vector (in local space)
  9167. * @param worldMatrix defines the new world matrix
  9168. */
  9169. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  9170. /**
  9171. * Scale the current bounding box by applying a scale factor
  9172. * @param factor defines the scale factor to apply
  9173. * @returns the current bounding box
  9174. */
  9175. scale(factor: number): BoundingBox;
  9176. /**
  9177. * Gets the world matrix of the bounding box
  9178. * @returns a matrix
  9179. */
  9180. getWorldMatrix(): DeepImmutable<Matrix>;
  9181. /** @hidden */
  9182. _update(world: DeepImmutable<Matrix>): void;
  9183. /**
  9184. * Tests if the bounding box is intersecting the frustum planes
  9185. * @param frustumPlanes defines the frustum planes to test
  9186. * @returns true if there is an intersection
  9187. */
  9188. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9189. /**
  9190. * Tests if the bounding box is entirely inside the frustum planes
  9191. * @param frustumPlanes defines the frustum planes to test
  9192. * @returns true if there is an inclusion
  9193. */
  9194. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9195. /**
  9196. * Tests if a point is inside the bounding box
  9197. * @param point defines the point to test
  9198. * @returns true if the point is inside the bounding box
  9199. */
  9200. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  9201. /**
  9202. * Tests if the bounding box intersects with a bounding sphere
  9203. * @param sphere defines the sphere to test
  9204. * @returns true if there is an intersection
  9205. */
  9206. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  9207. /**
  9208. * Tests if the bounding box intersects with a box defined by a min and max vectors
  9209. * @param min defines the min vector to use
  9210. * @param max defines the max vector to use
  9211. * @returns true if there is an intersection
  9212. */
  9213. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  9214. /**
  9215. * Tests if two bounding boxes are intersections
  9216. * @param box0 defines the first box to test
  9217. * @param box1 defines the second box to test
  9218. * @returns true if there is an intersection
  9219. */
  9220. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  9221. /**
  9222. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  9223. * @param minPoint defines the minimum vector of the bounding box
  9224. * @param maxPoint defines the maximum vector of the bounding box
  9225. * @param sphereCenter defines the sphere center
  9226. * @param sphereRadius defines the sphere radius
  9227. * @returns true if there is an intersection
  9228. */
  9229. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  9230. /**
  9231. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  9232. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  9233. * @param frustumPlanes defines the frustum planes to test
  9234. * @return true if there is an inclusion
  9235. */
  9236. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9237. /**
  9238. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  9239. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  9240. * @param frustumPlanes defines the frustum planes to test
  9241. * @return true if there is an intersection
  9242. */
  9243. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9244. }
  9245. }
  9246. declare module BABYLON {
  9247. /**
  9248. * Interface for cullable objects
  9249. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  9250. */
  9251. interface ICullable {
  9252. /**
  9253. * Checks if the object or part of the object is in the frustum
  9254. * @param frustumPlanes Camera near/planes
  9255. * @returns true if the object is in frustum otherwise false
  9256. */
  9257. isInFrustum(frustumPlanes: Plane[]): boolean;
  9258. /**
  9259. * Checks if a cullable object (mesh...) is in the camera frustum
  9260. * Unlike isInFrustum this cheks the full bounding box
  9261. * @param frustumPlanes Camera near/planes
  9262. * @returns true if the object is in frustum otherwise false
  9263. */
  9264. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  9265. }
  9266. /**
  9267. * Info for a bounding data of a mesh
  9268. */
  9269. class BoundingInfo implements ICullable {
  9270. /**
  9271. * Bounding box for the mesh
  9272. */
  9273. readonly boundingBox: BoundingBox;
  9274. /**
  9275. * Bounding sphere for the mesh
  9276. */
  9277. readonly boundingSphere: BoundingSphere;
  9278. private _isLocked;
  9279. private static readonly TmpVector3;
  9280. /**
  9281. * Constructs bounding info
  9282. * @param minimum min vector of the bounding box/sphere
  9283. * @param maximum max vector of the bounding box/sphere
  9284. * @param worldMatrix defines the new world matrix
  9285. */
  9286. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  9287. /**
  9288. * Recreates the entire bounding info from scratch as if we call the constructor in place
  9289. * @param min defines the new minimum vector (in local space)
  9290. * @param max defines the new maximum vector (in local space)
  9291. * @param worldMatrix defines the new world matrix
  9292. */
  9293. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  9294. /**
  9295. * min vector of the bounding box/sphere
  9296. */
  9297. readonly minimum: Vector3;
  9298. /**
  9299. * max vector of the bounding box/sphere
  9300. */
  9301. readonly maximum: Vector3;
  9302. /**
  9303. * If the info is locked and won't be updated to avoid perf overhead
  9304. */
  9305. isLocked: boolean;
  9306. /**
  9307. * Updates the bounding sphere and box
  9308. * @param world world matrix to be used to update
  9309. */
  9310. update(world: DeepImmutable<Matrix>): void;
  9311. /**
  9312. * Recreate the bounding info to be centered around a specific point given a specific extend.
  9313. * @param center New center of the bounding info
  9314. * @param extend New extend of the bounding info
  9315. * @returns the current bounding info
  9316. */
  9317. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  9318. /**
  9319. * Scale the current bounding info by applying a scale factor
  9320. * @param factor defines the scale factor to apply
  9321. * @returns the current bounding info
  9322. */
  9323. scale(factor: number): BoundingInfo;
  9324. /**
  9325. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  9326. * @param frustumPlanes defines the frustum to test
  9327. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  9328. * @returns true if the bounding info is in the frustum planes
  9329. */
  9330. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  9331. /**
  9332. * Gets the world distance between the min and max points of the bounding box
  9333. */
  9334. readonly diagonalLength: number;
  9335. /**
  9336. * Checks if a cullable object (mesh...) is in the camera frustum
  9337. * Unlike isInFrustum this cheks the full bounding box
  9338. * @param frustumPlanes Camera near/planes
  9339. * @returns true if the object is in frustum otherwise false
  9340. */
  9341. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9342. /** @hidden */
  9343. _checkCollision(collider: Collider): boolean;
  9344. /**
  9345. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  9346. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  9347. * @param point the point to check intersection with
  9348. * @returns if the point intersects
  9349. */
  9350. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  9351. /**
  9352. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  9353. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  9354. * @param boundingInfo the bounding info to check intersection with
  9355. * @param precise if the intersection should be done using OBB
  9356. * @returns if the bounding info intersects
  9357. */
  9358. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  9359. }
  9360. }
  9361. declare module BABYLON {
  9362. /**
  9363. * Class used to store bounding sphere information
  9364. */
  9365. class BoundingSphere {
  9366. /**
  9367. * Gets the center of the bounding sphere in local space
  9368. */
  9369. readonly center: Vector3;
  9370. /**
  9371. * Radius of the bounding sphere in local space
  9372. */
  9373. radius: number;
  9374. /**
  9375. * Gets the center of the bounding sphere in world space
  9376. */
  9377. readonly centerWorld: Vector3;
  9378. /**
  9379. * Radius of the bounding sphere in world space
  9380. */
  9381. radiusWorld: number;
  9382. /**
  9383. * Gets the minimum vector in local space
  9384. */
  9385. readonly minimum: Vector3;
  9386. /**
  9387. * Gets the maximum vector in local space
  9388. */
  9389. readonly maximum: Vector3;
  9390. private _worldMatrix;
  9391. private static readonly TmpVector3;
  9392. /**
  9393. * Creates a new bounding sphere
  9394. * @param min defines the minimum vector (in local space)
  9395. * @param max defines the maximum vector (in local space)
  9396. * @param worldMatrix defines the new world matrix
  9397. */
  9398. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  9399. /**
  9400. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  9401. * @param min defines the new minimum vector (in local space)
  9402. * @param max defines the new maximum vector (in local space)
  9403. * @param worldMatrix defines the new world matrix
  9404. */
  9405. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  9406. /**
  9407. * Scale the current bounding sphere by applying a scale factor
  9408. * @param factor defines the scale factor to apply
  9409. * @returns the current bounding box
  9410. */
  9411. scale(factor: number): BoundingSphere;
  9412. /**
  9413. * Gets the world matrix of the bounding box
  9414. * @returns a matrix
  9415. */
  9416. getWorldMatrix(): DeepImmutable<Matrix>;
  9417. /** @hidden */
  9418. _update(worldMatrix: DeepImmutable<Matrix>): void;
  9419. /**
  9420. * Tests if the bounding sphere is intersecting the frustum planes
  9421. * @param frustumPlanes defines the frustum planes to test
  9422. * @returns true if there is an intersection
  9423. */
  9424. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  9425. /**
  9426. * Tests if a point is inside the bounding sphere
  9427. * @param point defines the point to test
  9428. * @returns true if the point is inside the bounding sphere
  9429. */
  9430. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  9431. /**
  9432. * Checks if two sphere intersct
  9433. * @param sphere0 sphere 0
  9434. * @param sphere1 sphere 1
  9435. * @returns true if the speres intersect
  9436. */
  9437. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  9438. }
  9439. }
  9440. declare module BABYLON {
  9441. /**
  9442. * Class representing a ray with position and direction
  9443. */
  9444. class Ray {
  9445. /** origin point */
  9446. origin: Vector3;
  9447. /** direction */
  9448. direction: Vector3;
  9449. /** length of the ray */
  9450. length: number;
  9451. private static readonly TmpVector3;
  9452. private _tmpRay;
  9453. /**
  9454. * Creates a new ray
  9455. * @param origin origin point
  9456. * @param direction direction
  9457. * @param length length of the ray
  9458. */
  9459. constructor(
  9460. /** origin point */
  9461. origin: Vector3,
  9462. /** direction */
  9463. direction: Vector3,
  9464. /** length of the ray */
  9465. length?: number);
  9466. /**
  9467. * Checks if the ray intersects a box
  9468. * @param minimum bound of the box
  9469. * @param maximum bound of the box
  9470. * @param intersectionTreshold extra extend to be added to the box in all direction
  9471. * @returns if the box was hit
  9472. */
  9473. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9474. /**
  9475. * Checks if the ray intersects a box
  9476. * @param box the bounding box to check
  9477. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9478. * @returns if the box was hit
  9479. */
  9480. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9481. /**
  9482. * If the ray hits a sphere
  9483. * @param sphere the bounding sphere to check
  9484. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9485. * @returns true if it hits the sphere
  9486. */
  9487. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9488. /**
  9489. * If the ray hits a triange
  9490. * @param vertex0 triangle vertex
  9491. * @param vertex1 triangle vertex
  9492. * @param vertex2 triangle vertex
  9493. * @returns intersection information if hit
  9494. */
  9495. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9496. /**
  9497. * Checks if ray intersects a plane
  9498. * @param plane the plane to check
  9499. * @returns the distance away it was hit
  9500. */
  9501. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9502. /**
  9503. * Checks if ray intersects a mesh
  9504. * @param mesh the mesh to check
  9505. * @param fastCheck if only the bounding box should checked
  9506. * @returns picking info of the intersecton
  9507. */
  9508. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9509. /**
  9510. * Checks if ray intersects a mesh
  9511. * @param meshes the meshes to check
  9512. * @param fastCheck if only the bounding box should checked
  9513. * @param results array to store result in
  9514. * @returns Array of picking infos
  9515. */
  9516. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9517. private _comparePickingInfo;
  9518. private static smallnum;
  9519. private static rayl;
  9520. /**
  9521. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9522. * @param sega the first point of the segment to test the intersection against
  9523. * @param segb the second point of the segment to test the intersection against
  9524. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9525. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9526. */
  9527. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9528. /**
  9529. * Update the ray from viewport position
  9530. * @param x position
  9531. * @param y y position
  9532. * @param viewportWidth viewport width
  9533. * @param viewportHeight viewport height
  9534. * @param world world matrix
  9535. * @param view view matrix
  9536. * @param projection projection matrix
  9537. * @returns this ray updated
  9538. */
  9539. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9540. /**
  9541. * Creates a ray with origin and direction of 0,0,0
  9542. * @returns the new ray
  9543. */
  9544. static Zero(): Ray;
  9545. /**
  9546. * Creates a new ray from screen space and viewport
  9547. * @param x position
  9548. * @param y y position
  9549. * @param viewportWidth viewport width
  9550. * @param viewportHeight viewport height
  9551. * @param world world matrix
  9552. * @param view view matrix
  9553. * @param projection projection matrix
  9554. * @returns new ray
  9555. */
  9556. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9557. /**
  9558. * 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
  9559. * transformed to the given world matrix.
  9560. * @param origin The origin point
  9561. * @param end The end point
  9562. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9563. * @returns the new ray
  9564. */
  9565. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9566. /**
  9567. * Transforms a ray by a matrix
  9568. * @param ray ray to transform
  9569. * @param matrix matrix to apply
  9570. * @returns the resulting new ray
  9571. */
  9572. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9573. /**
  9574. * Transforms a ray by a matrix
  9575. * @param ray ray to transform
  9576. * @param matrix matrix to apply
  9577. * @param result ray to store result in
  9578. */
  9579. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9580. }
  9581. }
  9582. /**
  9583. * Module Debug contains the (visual) components to debug a scene correctly
  9584. */
  9585. declare module BABYLON.Debug {
  9586. /**
  9587. * The Axes viewer will show 3 axes in a specific point in space
  9588. */
  9589. class AxesViewer {
  9590. private _xAxis;
  9591. private _yAxis;
  9592. private _zAxis;
  9593. private _scaleLinesFactor;
  9594. private _instanced;
  9595. /**
  9596. * Gets the hosting scene
  9597. */
  9598. scene: Scene;
  9599. /**
  9600. * Gets or sets a number used to scale line length
  9601. */
  9602. scaleLines: number;
  9603. /** Gets the node hierarchy used to render x-axis */
  9604. readonly xAxis: TransformNode;
  9605. /** Gets the node hierarchy used to render y-axis */
  9606. readonly yAxis: TransformNode;
  9607. /** Gets the node hierarchy used to render z-axis */
  9608. readonly zAxis: TransformNode;
  9609. /**
  9610. * Creates a new AxesViewer
  9611. * @param scene defines the hosting scene
  9612. * @param scaleLines defines a number used to scale line length (1 by default)
  9613. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  9614. * @param xAxis defines the node hierarchy used to render the x-axis
  9615. * @param yAxis defines the node hierarchy used to render the y-axis
  9616. * @param zAxis defines the node hierarchy used to render the z-axis
  9617. */
  9618. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  9619. /**
  9620. * Force the viewer to update
  9621. * @param position defines the position of the viewer
  9622. * @param xaxis defines the x axis of the viewer
  9623. * @param yaxis defines the y axis of the viewer
  9624. * @param zaxis defines the z axis of the viewer
  9625. */
  9626. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9627. /**
  9628. * Creates an instance of this axes viewer.
  9629. * @returns a new axes viewer with instanced meshes
  9630. */
  9631. createInstance(): AxesViewer;
  9632. /** Releases resources */
  9633. dispose(): void;
  9634. private static _SetRenderingGroupId;
  9635. }
  9636. }
  9637. declare module BABYLON.Debug {
  9638. /**
  9639. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9640. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9641. */
  9642. class BoneAxesViewer extends AxesViewer {
  9643. /**
  9644. * Gets or sets the target mesh where to display the axes viewer
  9645. */
  9646. mesh: Nullable<Mesh>;
  9647. /**
  9648. * Gets or sets the target bone where to display the axes viewer
  9649. */
  9650. bone: Nullable<Bone>;
  9651. /** Gets current position */
  9652. pos: Vector3;
  9653. /** Gets direction of X axis */
  9654. xaxis: Vector3;
  9655. /** Gets direction of Y axis */
  9656. yaxis: Vector3;
  9657. /** Gets direction of Z axis */
  9658. zaxis: Vector3;
  9659. /**
  9660. * Creates a new BoneAxesViewer
  9661. * @param scene defines the hosting scene
  9662. * @param bone defines the target bone
  9663. * @param mesh defines the target mesh
  9664. * @param scaleLines defines a scaling factor for line length (1 by default)
  9665. */
  9666. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9667. /**
  9668. * Force the viewer to update
  9669. */
  9670. update(): void;
  9671. /** Releases resources */
  9672. dispose(): void;
  9673. }
  9674. }
  9675. declare module BABYLON {
  9676. /**
  9677. * Interface used to define scene explorer extensibility option
  9678. */
  9679. interface IExplorerExtensibilityOption {
  9680. /**
  9681. * Define the option label
  9682. */
  9683. label: string;
  9684. /**
  9685. * Defines the action to execute on click
  9686. */
  9687. action: (entity: any) => void;
  9688. }
  9689. /**
  9690. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  9691. */
  9692. interface IExplorerExtensibilityGroup {
  9693. /**
  9694. * Defines a predicate to test if a given type mut be extended
  9695. */
  9696. predicate: (entity: any) => boolean;
  9697. /**
  9698. * Gets the list of options added to a type
  9699. */
  9700. entries: IExplorerExtensibilityOption[];
  9701. }
  9702. /**
  9703. * Interface used to define the options to use to create the Inspector
  9704. */
  9705. interface IInspectorOptions {
  9706. /**
  9707. * Display in overlay mode (default: false)
  9708. */
  9709. overlay?: boolean;
  9710. /**
  9711. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  9712. */
  9713. globalRoot?: HTMLElement;
  9714. /**
  9715. * Display the Scene explorer
  9716. */
  9717. showExplorer?: boolean;
  9718. /**
  9719. * Display the property inspector
  9720. */
  9721. showInspector?: boolean;
  9722. /**
  9723. * Display in embed mode (both panes on the right)
  9724. */
  9725. embedMode?: boolean;
  9726. /**
  9727. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  9728. */
  9729. handleResize?: boolean;
  9730. /**
  9731. * Allow the panes to popup (default: true)
  9732. */
  9733. enablePopup?: boolean;
  9734. /**
  9735. * Allow the panes to be closed by users (default: true)
  9736. */
  9737. enableClose?: boolean;
  9738. /**
  9739. * Optional list of extensibility entries
  9740. */
  9741. explorerExtensibility?: IExplorerExtensibilityGroup[];
  9742. }
  9743. interface Scene {
  9744. /**
  9745. * @hidden
  9746. * Backing field
  9747. */
  9748. _debugLayer: DebugLayer;
  9749. /**
  9750. * Gets the debug layer (aka Inspector) associated with the scene
  9751. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9752. */
  9753. debugLayer: DebugLayer;
  9754. }
  9755. /**
  9756. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9757. * what is happening in your scene
  9758. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9759. */
  9760. class DebugLayer {
  9761. /**
  9762. * Define the url to get the inspector script from.
  9763. * By default it uses the babylonjs CDN.
  9764. * @ignoreNaming
  9765. */
  9766. static InspectorURL: string;
  9767. private _scene;
  9768. private BJSINSPECTOR;
  9769. /**
  9770. * Observable triggered when a property is changed through the inspector.
  9771. */
  9772. onPropertyChangedObservable: Observable<{
  9773. object: any;
  9774. property: string;
  9775. value: any;
  9776. initialValue: any;
  9777. }>;
  9778. /**
  9779. * Instantiates a new debug layer.
  9780. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9781. * what is happening in your scene
  9782. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9783. * @param scene Defines the scene to inspect
  9784. */
  9785. constructor(scene: Scene);
  9786. /** Creates the inspector window. */
  9787. private _createInspector;
  9788. /**
  9789. * Get if the inspector is visible or not.
  9790. * @returns true if visible otherwise, false
  9791. */
  9792. isVisible(): boolean;
  9793. /**
  9794. * Hide the inspector and close its window.
  9795. */
  9796. hide(): void;
  9797. /**
  9798. * Launch the debugLayer.
  9799. * @param config Define the configuration of the inspector
  9800. */
  9801. show(config?: IInspectorOptions): void;
  9802. }
  9803. }
  9804. declare module BABYLON.Debug {
  9805. /**
  9806. * Used to show the physics impostor around the specific mesh
  9807. */
  9808. class PhysicsViewer {
  9809. /** @hidden */
  9810. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9811. /** @hidden */
  9812. protected _meshes: Array<Nullable<AbstractMesh>>;
  9813. /** @hidden */
  9814. protected _scene: Nullable<Scene>;
  9815. /** @hidden */
  9816. protected _numMeshes: number;
  9817. /** @hidden */
  9818. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9819. private _renderFunction;
  9820. private _utilityLayer;
  9821. private _debugBoxMesh;
  9822. private _debugSphereMesh;
  9823. private _debugMaterial;
  9824. /**
  9825. * Creates a new PhysicsViewer
  9826. * @param scene defines the hosting scene
  9827. */
  9828. constructor(scene: Scene);
  9829. /** @hidden */
  9830. protected _updateDebugMeshes(): void;
  9831. /**
  9832. * Renders a specified physic impostor
  9833. * @param impostor defines the impostor to render
  9834. * @returns the new debug mesh used to render the impostor
  9835. */
  9836. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  9837. /**
  9838. * Hides a specified physic impostor
  9839. * @param impostor defines the impostor to hide
  9840. */
  9841. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9842. private _getDebugMaterial;
  9843. private _getDebugBoxMesh;
  9844. private _getDebugSphereMesh;
  9845. private _getDebugMesh;
  9846. /** Releases all resources */
  9847. dispose(): void;
  9848. }
  9849. }
  9850. declare module BABYLON {
  9851. /**
  9852. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9853. * in order to better appreciate the issue one might have.
  9854. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9855. */
  9856. class RayHelper {
  9857. /**
  9858. * Defines the ray we are currently tryin to visualize.
  9859. */
  9860. ray: Nullable<Ray>;
  9861. private _renderPoints;
  9862. private _renderLine;
  9863. private _renderFunction;
  9864. private _scene;
  9865. private _updateToMeshFunction;
  9866. private _attachedToMesh;
  9867. private _meshSpaceDirection;
  9868. private _meshSpaceOrigin;
  9869. /**
  9870. * Helper function to create a colored helper in a scene in one line.
  9871. * @param ray Defines the ray we are currently tryin to visualize
  9872. * @param scene Defines the scene the ray is used in
  9873. * @param color Defines the color we want to see the ray in
  9874. * @returns The newly created ray helper.
  9875. */
  9876. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9877. /**
  9878. * Instantiate a new ray helper.
  9879. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9880. * in order to better appreciate the issue one might have.
  9881. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9882. * @param ray Defines the ray we are currently tryin to visualize
  9883. */
  9884. constructor(ray: Ray);
  9885. /**
  9886. * Shows the ray we are willing to debug.
  9887. * @param scene Defines the scene the ray needs to be rendered in
  9888. * @param color Defines the color the ray needs to be rendered in
  9889. */
  9890. show(scene: Scene, color?: Color3): void;
  9891. /**
  9892. * Hides the ray we are debugging.
  9893. */
  9894. hide(): void;
  9895. private _render;
  9896. /**
  9897. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  9898. * @param mesh Defines the mesh we want the helper attached to
  9899. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  9900. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  9901. * @param length Defines the length of the ray
  9902. */
  9903. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9904. /**
  9905. * Detach the ray helper from the mesh it has previously been attached to.
  9906. */
  9907. detachFromMesh(): void;
  9908. private _updateToMesh;
  9909. /**
  9910. * Dispose the helper and release its associated resources.
  9911. */
  9912. dispose(): void;
  9913. }
  9914. }
  9915. declare module BABYLON.Debug {
  9916. /**
  9917. * Class used to render a debug view of a given skeleton
  9918. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9919. */
  9920. class SkeletonViewer {
  9921. /** defines the skeleton to render */
  9922. skeleton: Skeleton;
  9923. /** defines the mesh attached to the skeleton */
  9924. mesh: AbstractMesh;
  9925. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9926. autoUpdateBonesMatrices: boolean;
  9927. /** defines the rendering group id to use with the viewer */
  9928. renderingGroupId: number;
  9929. /** Gets or sets the color used to render the skeleton */
  9930. color: Color3;
  9931. private _scene;
  9932. private _debugLines;
  9933. private _debugMesh;
  9934. private _isEnabled;
  9935. private _renderFunction;
  9936. private _utilityLayer;
  9937. /**
  9938. * Returns the mesh used to render the bones
  9939. */
  9940. readonly debugMesh: Nullable<LinesMesh>;
  9941. /**
  9942. * Creates a new SkeletonViewer
  9943. * @param skeleton defines the skeleton to render
  9944. * @param mesh defines the mesh attached to the skeleton
  9945. * @param scene defines the hosting scene
  9946. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9947. * @param renderingGroupId defines the rendering group id to use with the viewer
  9948. */
  9949. constructor(
  9950. /** defines the skeleton to render */
  9951. skeleton: Skeleton,
  9952. /** defines the mesh attached to the skeleton */
  9953. mesh: AbstractMesh, scene: Scene,
  9954. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9955. autoUpdateBonesMatrices?: boolean,
  9956. /** defines the rendering group id to use with the viewer */
  9957. renderingGroupId?: number);
  9958. /** Gets or sets a boolean indicating if the viewer is enabled */
  9959. isEnabled: boolean;
  9960. private _getBonePosition;
  9961. private _getLinesForBonesWithLength;
  9962. private _getLinesForBonesNoLength;
  9963. /** Update the viewer to sync with current skeleton state */
  9964. update(): void;
  9965. /** Release associated resources */
  9966. dispose(): void;
  9967. }
  9968. }
  9969. declare module BABYLON {
  9970. /**
  9971. * Interface for attribute information associated with buffer instanciation
  9972. */
  9973. class InstancingAttributeInfo {
  9974. /**
  9975. * Index/offset of the attribute in the vertex shader
  9976. */
  9977. index: number;
  9978. /**
  9979. * size of the attribute, 1, 2, 3 or 4
  9980. */
  9981. attributeSize: number;
  9982. /**
  9983. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9984. * default is FLOAT
  9985. */
  9986. attribyteType: number;
  9987. /**
  9988. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9989. */
  9990. normalized: boolean;
  9991. /**
  9992. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  9993. */
  9994. offset: number;
  9995. /**
  9996. * Name of the GLSL attribute, for debugging purpose only
  9997. */
  9998. attributeName: string;
  9999. }
  10000. /**
  10001. * Define options used to create a render target texture
  10002. */
  10003. class RenderTargetCreationOptions {
  10004. /**
  10005. * Specifies is mipmaps must be generated
  10006. */
  10007. generateMipMaps?: boolean;
  10008. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  10009. generateDepthBuffer?: boolean;
  10010. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  10011. generateStencilBuffer?: boolean;
  10012. /** Defines texture type (int by default) */
  10013. type?: number;
  10014. /** Defines sampling mode (trilinear by default) */
  10015. samplingMode?: number;
  10016. /** Defines format (RGBA by default) */
  10017. format?: number;
  10018. }
  10019. /**
  10020. * Define options used to create a depth texture
  10021. */
  10022. class DepthTextureCreationOptions {
  10023. /** Specifies whether or not a stencil should be allocated in the texture */
  10024. generateStencil?: boolean;
  10025. /** Specifies whether or not bilinear filtering is enable on the texture */
  10026. bilinearFiltering?: boolean;
  10027. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  10028. comparisonFunction?: number;
  10029. /** Specifies if the created texture is a cube texture */
  10030. isCube?: boolean;
  10031. }
  10032. /**
  10033. * Class used to describe the capabilities of the engine relatively to the current browser
  10034. */
  10035. class EngineCapabilities {
  10036. /** Maximum textures units per fragment shader */
  10037. maxTexturesImageUnits: number;
  10038. /** Maximum texture units per vertex shader */
  10039. maxVertexTextureImageUnits: number;
  10040. /** Maximum textures units in the entire pipeline */
  10041. maxCombinedTexturesImageUnits: number;
  10042. /** Maximum texture size */
  10043. maxTextureSize: number;
  10044. /** Maximum cube texture size */
  10045. maxCubemapTextureSize: number;
  10046. /** Maximum render texture size */
  10047. maxRenderTextureSize: number;
  10048. /** Maximum number of vertex attributes */
  10049. maxVertexAttribs: number;
  10050. /** Maximum number of varyings */
  10051. maxVaryingVectors: number;
  10052. /** Maximum number of uniforms per vertex shader */
  10053. maxVertexUniformVectors: number;
  10054. /** Maximum number of uniforms per fragment shader */
  10055. maxFragmentUniformVectors: number;
  10056. /** Defines if standard derivates (dx/dy) are supported */
  10057. standardDerivatives: boolean;
  10058. /** Defines if s3tc texture compression is supported */
  10059. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  10060. /** Defines if pvrtc texture compression is supported */
  10061. pvrtc: any;
  10062. /** Defines if etc1 texture compression is supported */
  10063. etc1: any;
  10064. /** Defines if etc2 texture compression is supported */
  10065. etc2: any;
  10066. /** Defines if astc texture compression is supported */
  10067. astc: any;
  10068. /** Defines if float textures are supported */
  10069. textureFloat: boolean;
  10070. /** Defines if vertex array objects are supported */
  10071. vertexArrayObject: boolean;
  10072. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  10073. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  10074. /** Gets the maximum level of anisotropy supported */
  10075. maxAnisotropy: number;
  10076. /** Defines if instancing is supported */
  10077. instancedArrays: boolean;
  10078. /** Defines if 32 bits indices are supported */
  10079. uintIndices: boolean;
  10080. /** Defines if high precision shaders are supported */
  10081. highPrecisionShaderSupported: boolean;
  10082. /** Defines if depth reading in the fragment shader is supported */
  10083. fragmentDepthSupported: boolean;
  10084. /** Defines if float texture linear filtering is supported*/
  10085. textureFloatLinearFiltering: boolean;
  10086. /** Defines if rendering to float textures is supported */
  10087. textureFloatRender: boolean;
  10088. /** Defines if half float textures are supported*/
  10089. textureHalfFloat: boolean;
  10090. /** Defines if half float texture linear filtering is supported*/
  10091. textureHalfFloatLinearFiltering: boolean;
  10092. /** Defines if rendering to half float textures is supported */
  10093. textureHalfFloatRender: boolean;
  10094. /** Defines if textureLOD shader command is supported */
  10095. textureLOD: boolean;
  10096. /** Defines if draw buffers extension is supported */
  10097. drawBuffersExtension: boolean;
  10098. /** Defines if depth textures are supported */
  10099. depthTextureExtension: boolean;
  10100. /** Defines if float color buffer are supported */
  10101. colorBufferFloat: boolean;
  10102. /** Gets disjoint timer query extension (null if not supported) */
  10103. timerQuery: EXT_disjoint_timer_query;
  10104. /** Defines if timestamp can be used with timer query */
  10105. canUseTimestampForTimerQuery: boolean;
  10106. /** Function used to let the system compiles shaders in background */
  10107. parallelShaderCompile: {
  10108. MAX_SHADER_COMPILER_THREADS_KHR: number;
  10109. maxShaderCompilerThreadsKHR: (thread: number) => void;
  10110. COMPLETION_STATUS_KHR: number;
  10111. };
  10112. }
  10113. /** Interface defining initialization parameters for Engine class */
  10114. interface EngineOptions extends WebGLContextAttributes {
  10115. /**
  10116. * Defines if the engine should no exceed a specified device ratio
  10117. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  10118. */
  10119. limitDeviceRatio?: number;
  10120. /**
  10121. * Defines if webvr should be enabled automatically
  10122. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10123. */
  10124. autoEnableWebVR?: boolean;
  10125. /**
  10126. * Defines if webgl2 should be turned off even if supported
  10127. * @see http://doc.babylonjs.com/features/webgl2
  10128. */
  10129. disableWebGL2Support?: boolean;
  10130. /**
  10131. * Defines if webaudio should be initialized as well
  10132. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10133. */
  10134. audioEngine?: boolean;
  10135. /**
  10136. * Defines if animations should run using a deterministic lock step
  10137. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10138. */
  10139. deterministicLockstep?: boolean;
  10140. /** Defines the maximum steps to use with deterministic lock step mode */
  10141. lockstepMaxSteps?: number;
  10142. /**
  10143. * Defines that engine should ignore context lost events
  10144. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  10145. */
  10146. doNotHandleContextLost?: boolean;
  10147. }
  10148. /**
  10149. * Defines the interface used by display changed events
  10150. */
  10151. interface IDisplayChangedEventArgs {
  10152. /** Gets the vrDisplay object (if any) */
  10153. vrDisplay: Nullable<any>;
  10154. /** Gets a boolean indicating if webVR is supported */
  10155. vrSupported: boolean;
  10156. }
  10157. /**
  10158. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  10159. */
  10160. class Engine {
  10161. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  10162. static ExceptionList: ({
  10163. key: string;
  10164. capture: string;
  10165. captureConstraint: number;
  10166. targets: string[];
  10167. } | {
  10168. key: string;
  10169. capture: null;
  10170. captureConstraint: null;
  10171. targets: string[];
  10172. })[];
  10173. /** Gets the list of created engines */
  10174. static Instances: Engine[];
  10175. /**
  10176. * Gets the latest created engine
  10177. */
  10178. static readonly LastCreatedEngine: Nullable<Engine>;
  10179. /**
  10180. * Gets the latest created scene
  10181. */
  10182. static readonly LastCreatedScene: Nullable<Scene>;
  10183. /**
  10184. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  10185. * @param flag defines which part of the materials must be marked as dirty
  10186. * @param predicate defines a predicate used to filter which materials should be affected
  10187. */
  10188. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  10189. /**
  10190. * Hidden
  10191. */
  10192. static _TextureLoaders: IInternalTextureLoader[];
  10193. /** Defines that alpha blending is disabled */
  10194. static readonly ALPHA_DISABLE: number;
  10195. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  10196. static readonly ALPHA_ADD: number;
  10197. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  10198. static readonly ALPHA_COMBINE: number;
  10199. /** Defines that alpha blending to DEST - SRC * DEST */
  10200. static readonly ALPHA_SUBTRACT: number;
  10201. /** Defines that alpha blending to SRC * DEST */
  10202. static readonly ALPHA_MULTIPLY: number;
  10203. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  10204. static readonly ALPHA_MAXIMIZED: number;
  10205. /** Defines that alpha blending to SRC + DEST */
  10206. static readonly ALPHA_ONEONE: number;
  10207. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  10208. static readonly ALPHA_PREMULTIPLIED: number;
  10209. /**
  10210. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  10211. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  10212. */
  10213. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  10214. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  10215. static readonly ALPHA_INTERPOLATE: number;
  10216. /**
  10217. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  10218. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  10219. */
  10220. static readonly ALPHA_SCREENMODE: number;
  10221. /** Defines that the ressource is not delayed*/
  10222. static readonly DELAYLOADSTATE_NONE: number;
  10223. /** Defines that the ressource was successfully delay loaded */
  10224. static readonly DELAYLOADSTATE_LOADED: number;
  10225. /** Defines that the ressource is currently delay loading */
  10226. static readonly DELAYLOADSTATE_LOADING: number;
  10227. /** Defines that the ressource is delayed and has not started loading */
  10228. static readonly DELAYLOADSTATE_NOTLOADED: number;
  10229. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  10230. static readonly NEVER: number;
  10231. /** 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 */
  10232. static readonly ALWAYS: number;
  10233. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  10234. static readonly LESS: number;
  10235. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  10236. static readonly EQUAL: number;
  10237. /** 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 */
  10238. static readonly LEQUAL: number;
  10239. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  10240. static readonly GREATER: number;
  10241. /** 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 */
  10242. static readonly GEQUAL: number;
  10243. /** 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 */
  10244. static readonly NOTEQUAL: number;
  10245. /** Passed to stencilOperation to specify that stencil value must be kept */
  10246. static readonly KEEP: number;
  10247. /** Passed to stencilOperation to specify that stencil value must be replaced */
  10248. static readonly REPLACE: number;
  10249. /** Passed to stencilOperation to specify that stencil value must be incremented */
  10250. static readonly INCR: number;
  10251. /** Passed to stencilOperation to specify that stencil value must be decremented */
  10252. static readonly DECR: number;
  10253. /** Passed to stencilOperation to specify that stencil value must be inverted */
  10254. static readonly INVERT: number;
  10255. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  10256. static readonly INCR_WRAP: number;
  10257. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  10258. static readonly DECR_WRAP: number;
  10259. /** Texture is not repeating outside of 0..1 UVs */
  10260. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  10261. /** Texture is repeating outside of 0..1 UVs */
  10262. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  10263. /** Texture is repeating and mirrored */
  10264. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  10265. /** ALPHA */
  10266. static readonly TEXTUREFORMAT_ALPHA: number;
  10267. /** LUMINANCE */
  10268. static readonly TEXTUREFORMAT_LUMINANCE: number;
  10269. /** LUMINANCE_ALPHA */
  10270. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  10271. /** RGB */
  10272. static readonly TEXTUREFORMAT_RGB: number;
  10273. /** RGBA */
  10274. static readonly TEXTUREFORMAT_RGBA: number;
  10275. /** RED */
  10276. static readonly TEXTUREFORMAT_RED: number;
  10277. /** RED (2nd reference) */
  10278. static readonly TEXTUREFORMAT_R: number;
  10279. /** RG */
  10280. static readonly TEXTUREFORMAT_RG: number;
  10281. /** RED_INTEGER */
  10282. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  10283. /** RED_INTEGER (2nd reference) */
  10284. static readonly TEXTUREFORMAT_R_INTEGER: number;
  10285. /** RG_INTEGER */
  10286. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  10287. /** RGB_INTEGER */
  10288. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  10289. /** RGBA_INTEGER */
  10290. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  10291. /** UNSIGNED_BYTE */
  10292. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  10293. /** UNSIGNED_BYTE (2nd reference) */
  10294. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  10295. /** FLOAT */
  10296. static readonly TEXTURETYPE_FLOAT: number;
  10297. /** HALF_FLOAT */
  10298. static readonly TEXTURETYPE_HALF_FLOAT: number;
  10299. /** BYTE */
  10300. static readonly TEXTURETYPE_BYTE: number;
  10301. /** SHORT */
  10302. static readonly TEXTURETYPE_SHORT: number;
  10303. /** UNSIGNED_SHORT */
  10304. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  10305. /** INT */
  10306. static readonly TEXTURETYPE_INT: number;
  10307. /** UNSIGNED_INT */
  10308. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  10309. /** UNSIGNED_SHORT_4_4_4_4 */
  10310. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  10311. /** UNSIGNED_SHORT_5_5_5_1 */
  10312. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  10313. /** UNSIGNED_SHORT_5_6_5 */
  10314. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  10315. /** UNSIGNED_INT_2_10_10_10_REV */
  10316. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  10317. /** UNSIGNED_INT_24_8 */
  10318. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  10319. /** UNSIGNED_INT_10F_11F_11F_REV */
  10320. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  10321. /** UNSIGNED_INT_5_9_9_9_REV */
  10322. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  10323. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  10324. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  10325. /** nearest is mag = nearest and min = nearest and mip = linear */
  10326. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  10327. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10328. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  10329. /** Trilinear is mag = linear and min = linear and mip = linear */
  10330. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  10331. /** nearest is mag = nearest and min = nearest and mip = linear */
  10332. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  10333. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10334. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  10335. /** Trilinear is mag = linear and min = linear and mip = linear */
  10336. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  10337. /** mag = nearest and min = nearest and mip = nearest */
  10338. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  10339. /** mag = nearest and min = linear and mip = nearest */
  10340. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  10341. /** mag = nearest and min = linear and mip = linear */
  10342. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  10343. /** mag = nearest and min = linear and mip = none */
  10344. static readonly TEXTURE_NEAREST_LINEAR: number;
  10345. /** mag = nearest and min = nearest and mip = none */
  10346. static readonly TEXTURE_NEAREST_NEAREST: number;
  10347. /** mag = linear and min = nearest and mip = nearest */
  10348. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  10349. /** mag = linear and min = nearest and mip = linear */
  10350. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  10351. /** mag = linear and min = linear and mip = none */
  10352. static readonly TEXTURE_LINEAR_LINEAR: number;
  10353. /** mag = linear and min = nearest and mip = none */
  10354. static readonly TEXTURE_LINEAR_NEAREST: number;
  10355. /** Explicit coordinates mode */
  10356. static readonly TEXTURE_EXPLICIT_MODE: number;
  10357. /** Spherical coordinates mode */
  10358. static readonly TEXTURE_SPHERICAL_MODE: number;
  10359. /** Planar coordinates mode */
  10360. static readonly TEXTURE_PLANAR_MODE: number;
  10361. /** Cubic coordinates mode */
  10362. static readonly TEXTURE_CUBIC_MODE: number;
  10363. /** Projection coordinates mode */
  10364. static readonly TEXTURE_PROJECTION_MODE: number;
  10365. /** Skybox coordinates mode */
  10366. static readonly TEXTURE_SKYBOX_MODE: number;
  10367. /** Inverse Cubic coordinates mode */
  10368. static readonly TEXTURE_INVCUBIC_MODE: number;
  10369. /** Equirectangular coordinates mode */
  10370. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  10371. /** Equirectangular Fixed coordinates mode */
  10372. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  10373. /** Equirectangular Fixed Mirrored coordinates mode */
  10374. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  10375. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  10376. static readonly SCALEMODE_FLOOR: number;
  10377. /** Defines that texture rescaling will look for the nearest power of 2 size */
  10378. static readonly SCALEMODE_NEAREST: number;
  10379. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  10380. static readonly SCALEMODE_CEILING: number;
  10381. /**
  10382. * Returns the current version of the framework
  10383. */
  10384. static readonly Version: string;
  10385. /**
  10386. * Returns a string describing the current engine
  10387. */
  10388. readonly description: string;
  10389. /**
  10390. * Gets or sets the epsilon value used by collision engine
  10391. */
  10392. static CollisionsEpsilon: number;
  10393. /**
  10394. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  10395. */
  10396. static CodeRepository: string;
  10397. /**
  10398. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  10399. */
  10400. static ShadersRepository: string;
  10401. /**
  10402. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  10403. */
  10404. forcePOTTextures: boolean;
  10405. /**
  10406. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  10407. */
  10408. isFullscreen: boolean;
  10409. /**
  10410. * Gets a boolean indicating if the pointer is currently locked
  10411. */
  10412. isPointerLock: boolean;
  10413. /**
  10414. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  10415. */
  10416. cullBackFaces: boolean;
  10417. /**
  10418. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  10419. */
  10420. renderEvenInBackground: boolean;
  10421. /**
  10422. * Gets or sets a boolean indicating that cache can be kept between frames
  10423. */
  10424. preventCacheWipeBetweenFrames: boolean;
  10425. /**
  10426. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  10427. **/
  10428. enableOfflineSupport: boolean;
  10429. /**
  10430. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (Babylon.js will always consider the database is up to date)
  10431. **/
  10432. disableManifestCheck: boolean;
  10433. /**
  10434. * Gets the list of created scenes
  10435. */
  10436. scenes: Scene[];
  10437. /**
  10438. * Event raised when a new scene is created
  10439. */
  10440. onNewSceneAddedObservable: Observable<Scene>;
  10441. /**
  10442. * Gets the list of created postprocesses
  10443. */
  10444. postProcesses: PostProcess[];
  10445. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  10446. validateShaderPrograms: boolean;
  10447. /**
  10448. * Observable event triggered each time the rendering canvas is resized
  10449. */
  10450. onResizeObservable: Observable<Engine>;
  10451. /**
  10452. * Observable event triggered each time the canvas loses focus
  10453. */
  10454. onCanvasBlurObservable: Observable<Engine>;
  10455. /**
  10456. * Observable event triggered each time the canvas gains focus
  10457. */
  10458. onCanvasFocusObservable: Observable<Engine>;
  10459. /**
  10460. * Observable event triggered each time the canvas receives pointerout event
  10461. */
  10462. onCanvasPointerOutObservable: Observable<PointerEvent>;
  10463. /**
  10464. * Observable event triggered before each texture is initialized
  10465. */
  10466. onBeforeTextureInitObservable: Observable<Texture>;
  10467. private _vrDisplay;
  10468. private _vrSupported;
  10469. private _oldSize;
  10470. private _oldHardwareScaleFactor;
  10471. private _vrExclusivePointerMode;
  10472. private _webVRInitPromise;
  10473. /**
  10474. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  10475. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  10476. */
  10477. readonly isInVRExclusivePointerMode: boolean;
  10478. /**
  10479. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  10480. */
  10481. disableUniformBuffers: boolean;
  10482. /** @hidden */
  10483. _uniformBuffers: UniformBuffer[];
  10484. /**
  10485. * Gets a boolean indicating that the engine supports uniform buffers
  10486. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10487. */
  10488. readonly supportsUniformBuffers: boolean;
  10489. /**
  10490. * Observable raised when the engine begins a new frame
  10491. */
  10492. onBeginFrameObservable: Observable<Engine>;
  10493. /**
  10494. * If set, will be used to request the next animation frame for the render loop
  10495. */
  10496. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  10497. /**
  10498. * Observable raised when the engine ends the current frame
  10499. */
  10500. onEndFrameObservable: Observable<Engine>;
  10501. /**
  10502. * Observable raised when the engine is about to compile a shader
  10503. */
  10504. onBeforeShaderCompilationObservable: Observable<Engine>;
  10505. /**
  10506. * Observable raised when the engine has jsut compiled a shader
  10507. */
  10508. onAfterShaderCompilationObservable: Observable<Engine>;
  10509. /** @hidden */
  10510. _gl: WebGLRenderingContext;
  10511. private _renderingCanvas;
  10512. private _windowIsBackground;
  10513. private _webGLVersion;
  10514. /**
  10515. * Gets a boolean indicating that only power of 2 textures are supported
  10516. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  10517. */
  10518. readonly needPOTTextures: boolean;
  10519. /** @hidden */
  10520. _badOS: boolean;
  10521. /** @hidden */
  10522. _badDesktopOS: boolean;
  10523. /**
  10524. * Gets or sets a value indicating if we want to disable texture binding optimization.
  10525. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  10526. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  10527. */
  10528. disableTextureBindingOptimization: boolean;
  10529. /**
  10530. * Gets the audio engine
  10531. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10532. * @ignorenaming
  10533. */
  10534. static audioEngine: IAudioEngine;
  10535. /**
  10536. * Default AudioEngine factory responsible of creating the Audio Engine.
  10537. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  10538. */
  10539. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  10540. /**
  10541. * Default offline support factory responsible of creating a tool used to store data locally.
  10542. * By default, this will create a Database object if the workload has been embedded.
  10543. */
  10544. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  10545. private _onFocus;
  10546. private _onBlur;
  10547. private _onCanvasPointerOut;
  10548. private _onCanvasBlur;
  10549. private _onCanvasFocus;
  10550. private _onFullscreenChange;
  10551. private _onPointerLockChange;
  10552. private _onVRDisplayPointerRestricted;
  10553. private _onVRDisplayPointerUnrestricted;
  10554. private _onVrDisplayConnect;
  10555. private _onVrDisplayDisconnect;
  10556. private _onVrDisplayPresentChange;
  10557. /**
  10558. * Observable signaled when VR display mode changes
  10559. */
  10560. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  10561. /**
  10562. * Observable signaled when VR request present is complete
  10563. */
  10564. onVRRequestPresentComplete: Observable<boolean>;
  10565. /**
  10566. * Observable signaled when VR request present starts
  10567. */
  10568. onVRRequestPresentStart: Observable<Engine>;
  10569. private _hardwareScalingLevel;
  10570. /** @hidden */
  10571. protected _caps: EngineCapabilities;
  10572. private _pointerLockRequested;
  10573. private _isStencilEnable;
  10574. private _colorWrite;
  10575. private _loadingScreen;
  10576. /** @hidden */
  10577. _drawCalls: PerfCounter;
  10578. /** @hidden */
  10579. _textureCollisions: PerfCounter;
  10580. private _glVersion;
  10581. private _glRenderer;
  10582. private _glVendor;
  10583. private _videoTextureSupported;
  10584. private _renderingQueueLaunched;
  10585. private _activeRenderLoops;
  10586. private _deterministicLockstep;
  10587. private _lockstepMaxSteps;
  10588. /**
  10589. * Observable signaled when a context lost event is raised
  10590. */
  10591. onContextLostObservable: Observable<Engine>;
  10592. /**
  10593. * Observable signaled when a context restored event is raised
  10594. */
  10595. onContextRestoredObservable: Observable<Engine>;
  10596. private _onContextLost;
  10597. private _onContextRestored;
  10598. private _contextWasLost;
  10599. private _doNotHandleContextLost;
  10600. /**
  10601. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  10602. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  10603. */
  10604. doNotHandleContextLost: boolean;
  10605. private _performanceMonitor;
  10606. private _fps;
  10607. private _deltaTime;
  10608. /**
  10609. * Turn this value on if you want to pause FPS computation when in background
  10610. */
  10611. disablePerformanceMonitorInBackground: boolean;
  10612. /**
  10613. * Gets the performance monitor attached to this engine
  10614. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  10615. */
  10616. readonly performanceMonitor: PerformanceMonitor;
  10617. /** @hidden */
  10618. protected _depthCullingState: _DepthCullingState;
  10619. /** @hidden */
  10620. protected _stencilState: _StencilState;
  10621. /** @hidden */
  10622. protected _alphaState: _AlphaState;
  10623. /** @hidden */
  10624. protected _alphaMode: number;
  10625. protected _internalTexturesCache: InternalTexture[];
  10626. /** @hidden */
  10627. protected _activeChannel: number;
  10628. private _currentTextureChannel;
  10629. /** @hidden */
  10630. protected _boundTexturesCache: {
  10631. [key: string]: Nullable<InternalTexture>;
  10632. };
  10633. /** @hidden */
  10634. protected _currentEffect: Nullable<Effect>;
  10635. /** @hidden */
  10636. protected _currentProgram: Nullable<WebGLProgram>;
  10637. private _compiledEffects;
  10638. private _vertexAttribArraysEnabled;
  10639. /** @hidden */
  10640. protected _cachedViewport: Nullable<Viewport>;
  10641. private _cachedVertexArrayObject;
  10642. /** @hidden */
  10643. protected _cachedVertexBuffers: any;
  10644. /** @hidden */
  10645. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  10646. /** @hidden */
  10647. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  10648. /** @hidden */
  10649. protected _currentRenderTarget: Nullable<InternalTexture>;
  10650. private _uintIndicesCurrentlySet;
  10651. private _currentBoundBuffer;
  10652. /** @hidden */
  10653. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  10654. private _currentBufferPointers;
  10655. private _currentInstanceLocations;
  10656. private _currentInstanceBuffers;
  10657. private _textureUnits;
  10658. private _firstBoundInternalTextureTracker;
  10659. private _lastBoundInternalTextureTracker;
  10660. private _workingCanvas;
  10661. private _workingContext;
  10662. private _rescalePostProcess;
  10663. private _dummyFramebuffer;
  10664. private _externalData;
  10665. private _bindedRenderFunction;
  10666. private _vaoRecordInProgress;
  10667. private _mustWipeVertexAttributes;
  10668. private _emptyTexture;
  10669. private _emptyCubeTexture;
  10670. private _emptyTexture3D;
  10671. /** @hidden */
  10672. _frameHandler: number;
  10673. private _nextFreeTextureSlots;
  10674. private _maxSimultaneousTextures;
  10675. private _activeRequests;
  10676. private _texturesSupported;
  10677. private _textureFormatInUse;
  10678. /**
  10679. * Gets the list of texture formats supported
  10680. */
  10681. readonly texturesSupported: Array<string>;
  10682. /**
  10683. * Gets the list of texture formats in use
  10684. */
  10685. readonly textureFormatInUse: Nullable<string>;
  10686. /**
  10687. * Gets the current viewport
  10688. */
  10689. readonly currentViewport: Nullable<Viewport>;
  10690. /**
  10691. * Gets the default empty texture
  10692. */
  10693. readonly emptyTexture: InternalTexture;
  10694. /**
  10695. * Gets the default empty 3D texture
  10696. */
  10697. readonly emptyTexture3D: InternalTexture;
  10698. /**
  10699. * Gets the default empty cube texture
  10700. */
  10701. readonly emptyCubeTexture: InternalTexture;
  10702. /**
  10703. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10704. */
  10705. readonly premultipliedAlpha: boolean;
  10706. /**
  10707. * Creates a new engine
  10708. * @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
  10709. * @param antialias defines enable antialiasing (default: false)
  10710. * @param options defines further options to be sent to the getContext() function
  10711. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10712. */
  10713. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10714. private _rebuildInternalTextures;
  10715. private _rebuildEffects;
  10716. /**
  10717. * Gets a boolean indicating if all created effects are ready
  10718. * @returns true if all effects are ready
  10719. */
  10720. areAllEffectsReady(): boolean;
  10721. private _rebuildBuffers;
  10722. private _initGLContext;
  10723. /**
  10724. * Gets version of the current webGL context
  10725. */
  10726. readonly webGLVersion: number;
  10727. /**
  10728. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10729. */
  10730. readonly isStencilEnable: boolean;
  10731. private _prepareWorkingCanvas;
  10732. /**
  10733. * Reset the texture cache to empty state
  10734. */
  10735. resetTextureCache(): void;
  10736. /**
  10737. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10738. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10739. * @returns true if engine is in deterministic lock step mode
  10740. */
  10741. isDeterministicLockStep(): boolean;
  10742. /**
  10743. * Gets the max steps when engine is running in deterministic lock step
  10744. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10745. * @returns the max steps
  10746. */
  10747. getLockstepMaxSteps(): number;
  10748. /**
  10749. * Gets an object containing information about the current webGL context
  10750. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10751. */
  10752. getGlInfo(): {
  10753. vendor: string;
  10754. renderer: string;
  10755. version: string;
  10756. };
  10757. /**
  10758. * Gets current aspect ratio
  10759. * @param camera defines the camera to use to get the aspect ratio
  10760. * @param useScreen defines if screen size must be used (or the current render target if any)
  10761. * @returns a number defining the aspect ratio
  10762. */
  10763. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10764. /**
  10765. * Gets current screen aspect ratio
  10766. * @returns a number defining the aspect ratio
  10767. */
  10768. getScreenAspectRatio(): number;
  10769. /**
  10770. * Gets the current render width
  10771. * @param useScreen defines if screen size must be used (or the current render target if any)
  10772. * @returns a number defining the current render width
  10773. */
  10774. getRenderWidth(useScreen?: boolean): number;
  10775. /**
  10776. * Gets the current render height
  10777. * @param useScreen defines if screen size must be used (or the current render target if any)
  10778. * @returns a number defining the current render height
  10779. */
  10780. getRenderHeight(useScreen?: boolean): number;
  10781. /**
  10782. * Gets the HTML canvas attached with the current webGL context
  10783. * @returns a HTML canvas
  10784. */
  10785. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10786. /**
  10787. * Gets the client rect of the HTML canvas attached with the current webGL context
  10788. * @returns a client rectanglee
  10789. */
  10790. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10791. /**
  10792. * Defines the hardware scaling level.
  10793. * By default the hardware scaling level is computed from the window device ratio.
  10794. * 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.
  10795. * @param level defines the level to use
  10796. */
  10797. setHardwareScalingLevel(level: number): void;
  10798. /**
  10799. * Gets the current hardware scaling level.
  10800. * By default the hardware scaling level is computed from the window device ratio.
  10801. * 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.
  10802. * @returns a number indicating the current hardware scaling level
  10803. */
  10804. getHardwareScalingLevel(): number;
  10805. /**
  10806. * Gets the list of loaded textures
  10807. * @returns an array containing all loaded textures
  10808. */
  10809. getLoadedTexturesCache(): InternalTexture[];
  10810. /**
  10811. * Gets the object containing all engine capabilities
  10812. * @returns the EngineCapabilities object
  10813. */
  10814. getCaps(): EngineCapabilities;
  10815. /**
  10816. * Gets the current depth function
  10817. * @returns a number defining the depth function
  10818. */
  10819. getDepthFunction(): Nullable<number>;
  10820. /**
  10821. * Sets the current depth function
  10822. * @param depthFunc defines the function to use
  10823. */
  10824. setDepthFunction(depthFunc: number): void;
  10825. /**
  10826. * Sets the current depth function to GREATER
  10827. */
  10828. setDepthFunctionToGreater(): void;
  10829. /**
  10830. * Sets the current depth function to GEQUAL
  10831. */
  10832. setDepthFunctionToGreaterOrEqual(): void;
  10833. /**
  10834. * Sets the current depth function to LESS
  10835. */
  10836. setDepthFunctionToLess(): void;
  10837. /**
  10838. * Sets the current depth function to LEQUAL
  10839. */
  10840. setDepthFunctionToLessOrEqual(): void;
  10841. /**
  10842. * Gets a boolean indicating if stencil buffer is enabled
  10843. * @returns the current stencil buffer state
  10844. */
  10845. getStencilBuffer(): boolean;
  10846. /**
  10847. * Enable or disable the stencil buffer
  10848. * @param enable defines if the stencil buffer must be enabled or disabled
  10849. */
  10850. setStencilBuffer(enable: boolean): void;
  10851. /**
  10852. * Gets the current stencil mask
  10853. * @returns a number defining the new stencil mask to use
  10854. */
  10855. getStencilMask(): number;
  10856. /**
  10857. * Sets the current stencil mask
  10858. * @param mask defines the new stencil mask to use
  10859. */
  10860. setStencilMask(mask: number): void;
  10861. /**
  10862. * Gets the current stencil function
  10863. * @returns a number defining the stencil function to use
  10864. */
  10865. getStencilFunction(): number;
  10866. /**
  10867. * Gets the current stencil reference value
  10868. * @returns a number defining the stencil reference value to use
  10869. */
  10870. getStencilFunctionReference(): number;
  10871. /**
  10872. * Gets the current stencil mask
  10873. * @returns a number defining the stencil mask to use
  10874. */
  10875. getStencilFunctionMask(): number;
  10876. /**
  10877. * Sets the current stencil function
  10878. * @param stencilFunc defines the new stencil function to use
  10879. */
  10880. setStencilFunction(stencilFunc: number): void;
  10881. /**
  10882. * Sets the current stencil reference
  10883. * @param reference defines the new stencil reference to use
  10884. */
  10885. setStencilFunctionReference(reference: number): void;
  10886. /**
  10887. * Sets the current stencil mask
  10888. * @param mask defines the new stencil mask to use
  10889. */
  10890. setStencilFunctionMask(mask: number): void;
  10891. /**
  10892. * Gets the current stencil operation when stencil fails
  10893. * @returns a number defining stencil operation to use when stencil fails
  10894. */
  10895. getStencilOperationFail(): number;
  10896. /**
  10897. * Gets the current stencil operation when depth fails
  10898. * @returns a number defining stencil operation to use when depth fails
  10899. */
  10900. getStencilOperationDepthFail(): number;
  10901. /**
  10902. * Gets the current stencil operation when stencil passes
  10903. * @returns a number defining stencil operation to use when stencil passes
  10904. */
  10905. getStencilOperationPass(): number;
  10906. /**
  10907. * Sets the stencil operation to use when stencil fails
  10908. * @param operation defines the stencil operation to use when stencil fails
  10909. */
  10910. setStencilOperationFail(operation: number): void;
  10911. /**
  10912. * Sets the stencil operation to use when depth fails
  10913. * @param operation defines the stencil operation to use when depth fails
  10914. */
  10915. setStencilOperationDepthFail(operation: number): void;
  10916. /**
  10917. * Sets the stencil operation to use when stencil passes
  10918. * @param operation defines the stencil operation to use when stencil passes
  10919. */
  10920. setStencilOperationPass(operation: number): void;
  10921. /**
  10922. * Sets a boolean indicating if the dithering state is enabled or disabled
  10923. * @param value defines the dithering state
  10924. */
  10925. setDitheringState(value: boolean): void;
  10926. /**
  10927. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10928. * @param value defines the rasterizer state
  10929. */
  10930. setRasterizerState(value: boolean): void;
  10931. /**
  10932. * stop executing a render loop function and remove it from the execution array
  10933. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10934. */
  10935. stopRenderLoop(renderFunction?: () => void): void;
  10936. /** @hidden */
  10937. _renderLoop(): void;
  10938. /**
  10939. * Register and execute a render loop. The engine can have more than one render function
  10940. * @param renderFunction defines the function to continuously execute
  10941. */
  10942. runRenderLoop(renderFunction: () => void): void;
  10943. /**
  10944. * Toggle full screen mode
  10945. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10946. */
  10947. switchFullscreen(requestPointerLock: boolean): void;
  10948. /**
  10949. * Clear the current render buffer or the current render target (if any is set up)
  10950. * @param color defines the color to use
  10951. * @param backBuffer defines if the back buffer must be cleared
  10952. * @param depth defines if the depth buffer must be cleared
  10953. * @param stencil defines if the stencil buffer must be cleared
  10954. */
  10955. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10956. /**
  10957. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10958. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10959. * @param y defines the y-coordinate of the corner of the clear rectangle
  10960. * @param width defines the width of the clear rectangle
  10961. * @param height defines the height of the clear rectangle
  10962. * @param clearColor defines the clear color
  10963. */
  10964. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10965. /**
  10966. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  10967. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10968. * @param y defines the y-coordinate of the corner of the clear rectangle
  10969. * @param width defines the width of the clear rectangle
  10970. * @param height defines the height of the clear rectangle
  10971. */
  10972. enableScissor(x: number, y: number, width: number, height: number): void;
  10973. /**
  10974. * Disable previously set scissor test rectangle
  10975. */
  10976. disableScissor(): void;
  10977. private _viewportCached;
  10978. /** @hidden */
  10979. _viewport(x: number, y: number, width: number, height: number): void;
  10980. /**
  10981. * Set the WebGL's viewport
  10982. * @param viewport defines the viewport element to be used
  10983. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10984. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  10985. */
  10986. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  10987. /**
  10988. * Directly set the WebGL Viewport
  10989. * @param x defines the x coordinate of the viewport (in screen space)
  10990. * @param y defines the y coordinate of the viewport (in screen space)
  10991. * @param width defines the width of the viewport (in screen space)
  10992. * @param height defines the height of the viewport (in screen space)
  10993. * @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
  10994. */
  10995. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  10996. /**
  10997. * Begin a new frame
  10998. */
  10999. beginFrame(): void;
  11000. /**
  11001. * Enf the current frame
  11002. */
  11003. endFrame(): void;
  11004. /**
  11005. * Resize the view according to the canvas' size
  11006. */
  11007. resize(): void;
  11008. /**
  11009. * Force a specific size of the canvas
  11010. * @param width defines the new canvas' width
  11011. * @param height defines the new canvas' height
  11012. */
  11013. setSize(width: number, height: number): void;
  11014. /**
  11015. * Gets a boolean indicating if a webVR device was detected
  11016. * @returns true if a webVR device was detected
  11017. */
  11018. isVRDevicePresent(): boolean;
  11019. /**
  11020. * Gets the current webVR device
  11021. * @returns the current webVR device (or null)
  11022. */
  11023. getVRDevice(): any;
  11024. /**
  11025. * Initializes a webVR display and starts listening to display change events
  11026. * The onVRDisplayChangedObservable will be notified upon these changes
  11027. * @returns The onVRDisplayChangedObservable
  11028. */
  11029. initWebVR(): Observable<IDisplayChangedEventArgs>;
  11030. /**
  11031. * Initializes a webVR display and starts listening to display change events
  11032. * The onVRDisplayChangedObservable will be notified upon these changes
  11033. * @returns A promise containing a VRDisplay and if vr is supported
  11034. */
  11035. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  11036. /**
  11037. * Call this function to switch to webVR mode
  11038. * Will do nothing if webVR is not supported or if there is no webVR device
  11039. * @see http://doc.babylonjs.com/how_to/webvr_camera
  11040. */
  11041. enableVR(): void;
  11042. /**
  11043. * Call this function to leave webVR mode
  11044. * Will do nothing if webVR is not supported or if there is no webVR device
  11045. * @see http://doc.babylonjs.com/how_to/webvr_camera
  11046. */
  11047. disableVR(): void;
  11048. private _onVRFullScreenTriggered;
  11049. private _getVRDisplaysAsync;
  11050. /**
  11051. * Binds the frame buffer to the specified texture.
  11052. * @param texture The texture to render to or null for the default canvas
  11053. * @param faceIndex The face of the texture to render to in case of cube texture
  11054. * @param requiredWidth The width of the target to render to
  11055. * @param requiredHeight The height of the target to render to
  11056. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  11057. * @param depthStencilTexture The depth stencil texture to use to render
  11058. * @param lodLevel defines le lod level to bind to the frame buffer
  11059. */
  11060. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  11061. private bindUnboundFramebuffer;
  11062. /**
  11063. * Unbind the current render target texture from the webGL context
  11064. * @param texture defines the render target texture to unbind
  11065. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  11066. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  11067. */
  11068. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11069. /**
  11070. * Unbind a list of render target textures from the webGL context
  11071. * This is used only when drawBuffer extension or webGL2 are active
  11072. * @param textures defines the render target textures to unbind
  11073. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  11074. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  11075. */
  11076. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  11077. /**
  11078. * Force the mipmap generation for the given render target texture
  11079. * @param texture defines the render target texture to use
  11080. */
  11081. generateMipMapsForCubemap(texture: InternalTexture): void;
  11082. /**
  11083. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  11084. */
  11085. flushFramebuffer(): void;
  11086. /**
  11087. * Unbind the current render target and bind the default framebuffer
  11088. */
  11089. restoreDefaultFramebuffer(): void;
  11090. /**
  11091. * Create an uniform buffer
  11092. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11093. * @param elements defines the content of the uniform buffer
  11094. * @returns the webGL uniform buffer
  11095. */
  11096. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  11097. /**
  11098. * Create a dynamic uniform buffer
  11099. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11100. * @param elements defines the content of the uniform buffer
  11101. * @returns the webGL uniform buffer
  11102. */
  11103. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  11104. /**
  11105. * Update an existing uniform buffer
  11106. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  11107. * @param uniformBuffer defines the target uniform buffer
  11108. * @param elements defines the content to update
  11109. * @param offset defines the offset in the uniform buffer where update should start
  11110. * @param count defines the size of the data to update
  11111. */
  11112. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  11113. private _resetVertexBufferBinding;
  11114. /**
  11115. * Creates a vertex buffer
  11116. * @param data the data for the vertex buffer
  11117. * @returns the new WebGL static buffer
  11118. */
  11119. createVertexBuffer(data: DataArray): WebGLBuffer;
  11120. /**
  11121. * Creates a dynamic vertex buffer
  11122. * @param data the data for the dynamic vertex buffer
  11123. * @returns the new WebGL dynamic buffer
  11124. */
  11125. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  11126. /**
  11127. * Update a dynamic index buffer
  11128. * @param indexBuffer defines the target index buffer
  11129. * @param indices defines the data to update
  11130. * @param offset defines the offset in the target index buffer where update should start
  11131. */
  11132. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  11133. /**
  11134. * Updates a dynamic vertex buffer.
  11135. * @param vertexBuffer the vertex buffer to update
  11136. * @param data the data used to update the vertex buffer
  11137. * @param byteOffset the byte offset of the data
  11138. * @param byteLength the byte length of the data
  11139. */
  11140. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11141. private _resetIndexBufferBinding;
  11142. /**
  11143. * Creates a new index buffer
  11144. * @param indices defines the content of the index buffer
  11145. * @param updatable defines if the index buffer must be updatable
  11146. * @returns a new webGL buffer
  11147. */
  11148. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  11149. /**
  11150. * Bind a webGL buffer to the webGL context
  11151. * @param buffer defines the buffer to bind
  11152. */
  11153. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  11154. /**
  11155. * Bind an uniform buffer to the current webGL context
  11156. * @param buffer defines the buffer to bind
  11157. */
  11158. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  11159. /**
  11160. * Bind a buffer to the current webGL context at a given location
  11161. * @param buffer defines the buffer to bind
  11162. * @param location defines the index where to bind the buffer
  11163. */
  11164. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  11165. /**
  11166. * Bind a specific block at a given index in a specific shader program
  11167. * @param shaderProgram defines the shader program
  11168. * @param blockName defines the block name
  11169. * @param index defines the index where to bind the block
  11170. */
  11171. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  11172. private bindIndexBuffer;
  11173. private bindBuffer;
  11174. /**
  11175. * update the bound buffer with the given data
  11176. * @param data defines the data to update
  11177. */
  11178. updateArrayBuffer(data: Float32Array): void;
  11179. private _vertexAttribPointer;
  11180. private _bindIndexBufferWithCache;
  11181. private _bindVertexBuffersAttributes;
  11182. /**
  11183. * Records a vertex array object
  11184. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11185. * @param vertexBuffers defines the list of vertex buffers to store
  11186. * @param indexBuffer defines the index buffer to store
  11187. * @param effect defines the effect to store
  11188. * @returns the new vertex array object
  11189. */
  11190. recordVertexArrayObject(vertexBuffers: {
  11191. [key: string]: VertexBuffer;
  11192. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  11193. /**
  11194. * Bind a specific vertex array object
  11195. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11196. * @param vertexArrayObject defines the vertex array object to bind
  11197. * @param indexBuffer defines the index buffer to bind
  11198. */
  11199. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  11200. /**
  11201. * Bind webGl buffers directly to the webGL context
  11202. * @param vertexBuffer defines the vertex buffer to bind
  11203. * @param indexBuffer defines the index buffer to bind
  11204. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  11205. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  11206. * @param effect defines the effect associated with the vertex buffer
  11207. */
  11208. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  11209. private _unbindVertexArrayObject;
  11210. /**
  11211. * Bind a list of vertex buffers to the webGL context
  11212. * @param vertexBuffers defines the list of vertex buffers to bind
  11213. * @param indexBuffer defines the index buffer to bind
  11214. * @param effect defines the effect associated with the vertex buffers
  11215. */
  11216. bindBuffers(vertexBuffers: {
  11217. [key: string]: Nullable<VertexBuffer>;
  11218. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  11219. /**
  11220. * Unbind all instance attributes
  11221. */
  11222. unbindInstanceAttributes(): void;
  11223. /**
  11224. * Release and free the memory of a vertex array object
  11225. * @param vao defines the vertex array object to delete
  11226. */
  11227. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  11228. /** @hidden */
  11229. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11230. /**
  11231. * Creates a webGL buffer to use with instanciation
  11232. * @param capacity defines the size of the buffer
  11233. * @returns the webGL buffer
  11234. */
  11235. createInstancesBuffer(capacity: number): WebGLBuffer;
  11236. /**
  11237. * Delete a webGL buffer used with instanciation
  11238. * @param buffer defines the webGL buffer to delete
  11239. */
  11240. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  11241. /**
  11242. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  11243. * @param instancesBuffer defines the webGL buffer to update and bind
  11244. * @param data defines the data to store in the buffer
  11245. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  11246. */
  11247. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  11248. /**
  11249. * Apply all cached states (depth, culling, stencil and alpha)
  11250. */
  11251. applyStates(): void;
  11252. /**
  11253. * Send a draw order
  11254. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11255. * @param indexStart defines the starting index
  11256. * @param indexCount defines the number of index to draw
  11257. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11258. */
  11259. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11260. /**
  11261. * Draw a list of points
  11262. * @param verticesStart defines the index of first vertex to draw
  11263. * @param verticesCount defines the count of vertices to draw
  11264. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11265. */
  11266. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11267. /**
  11268. * Draw a list of unindexed primitives
  11269. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11270. * @param verticesStart defines the index of first vertex to draw
  11271. * @param verticesCount defines the count of vertices to draw
  11272. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11273. */
  11274. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11275. /**
  11276. * Draw a list of indexed primitives
  11277. * @param fillMode defines the primitive to use
  11278. * @param indexStart defines the starting index
  11279. * @param indexCount defines the number of index to draw
  11280. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11281. */
  11282. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11283. /**
  11284. * Draw a list of unindexed primitives
  11285. * @param fillMode defines the primitive to use
  11286. * @param verticesStart defines the index of first vertex to draw
  11287. * @param verticesCount defines the count of vertices to draw
  11288. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11289. */
  11290. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11291. private _drawMode;
  11292. /** @hidden */
  11293. _releaseEffect(effect: Effect): void;
  11294. /** @hidden */
  11295. _deleteProgram(program: WebGLProgram): void;
  11296. /**
  11297. * Create a new effect (used to store vertex/fragment shaders)
  11298. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  11299. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  11300. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  11301. * @param samplers defines an array of string used to represent textures
  11302. * @param defines defines the string containing the defines to use to compile the shaders
  11303. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  11304. * @param onCompiled defines a function to call when the effect creation is successful
  11305. * @param onError defines a function to call when the effect creation has failed
  11306. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  11307. * @returns the new Effect
  11308. */
  11309. 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;
  11310. private _compileShader;
  11311. private _compileRawShader;
  11312. /**
  11313. * Directly creates a webGL program
  11314. * @param vertexCode defines the vertex shader code to use
  11315. * @param fragmentCode defines the fragment shader code to use
  11316. * @param context defines the webGL context to use (if not set, the current one will be used)
  11317. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11318. * @returns the new webGL program
  11319. */
  11320. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11321. /**
  11322. * Creates a webGL program
  11323. * @param vertexCode defines the vertex shader code to use
  11324. * @param fragmentCode defines the fragment shader code to use
  11325. * @param defines defines the string containing the defines to use to compile the shaders
  11326. * @param context defines the webGL context to use (if not set, the current one will be used)
  11327. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11328. * @returns the new webGL program
  11329. */
  11330. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11331. private _createShaderProgram;
  11332. private _finalizeProgram;
  11333. /** @hidden */
  11334. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  11335. /** @hidden */
  11336. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  11337. /**
  11338. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  11339. * @param shaderProgram defines the webGL program to use
  11340. * @param uniformsNames defines the list of uniform names
  11341. * @returns an array of webGL uniform locations
  11342. */
  11343. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  11344. /**
  11345. * Gets the lsit of active attributes for a given webGL program
  11346. * @param shaderProgram defines the webGL program to use
  11347. * @param attributesNames defines the list of attribute names to get
  11348. * @returns an array of indices indicating the offset of each attribute
  11349. */
  11350. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11351. /**
  11352. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  11353. * @param effect defines the effect to activate
  11354. */
  11355. enableEffect(effect: Nullable<Effect>): void;
  11356. /**
  11357. * Set the value of an uniform to an array of int32
  11358. * @param uniform defines the webGL uniform location where to store the value
  11359. * @param array defines the array of int32 to store
  11360. */
  11361. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11362. /**
  11363. * Set the value of an uniform to an array of int32 (stored as vec2)
  11364. * @param uniform defines the webGL uniform location where to store the value
  11365. * @param array defines the array of int32 to store
  11366. */
  11367. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11368. /**
  11369. * Set the value of an uniform to an array of int32 (stored as vec3)
  11370. * @param uniform defines the webGL uniform location where to store the value
  11371. * @param array defines the array of int32 to store
  11372. */
  11373. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11374. /**
  11375. * Set the value of an uniform to an array of int32 (stored as vec4)
  11376. * @param uniform defines the webGL uniform location where to store the value
  11377. * @param array defines the array of int32 to store
  11378. */
  11379. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11380. /**
  11381. * Set the value of an uniform to an array of float32
  11382. * @param uniform defines the webGL uniform location where to store the value
  11383. * @param array defines the array of float32 to store
  11384. */
  11385. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11386. /**
  11387. * Set the value of an uniform to an array of float32 (stored as vec2)
  11388. * @param uniform defines the webGL uniform location where to store the value
  11389. * @param array defines the array of float32 to store
  11390. */
  11391. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11392. /**
  11393. * Set the value of an uniform to an array of float32 (stored as vec3)
  11394. * @param uniform defines the webGL uniform location where to store the value
  11395. * @param array defines the array of float32 to store
  11396. */
  11397. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11398. /**
  11399. * Set the value of an uniform to an array of float32 (stored as vec4)
  11400. * @param uniform defines the webGL uniform location where to store the value
  11401. * @param array defines the array of float32 to store
  11402. */
  11403. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11404. /**
  11405. * Set the value of an uniform to an array of number
  11406. * @param uniform defines the webGL uniform location where to store the value
  11407. * @param array defines the array of number to store
  11408. */
  11409. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11410. /**
  11411. * Set the value of an uniform to an array of number (stored as vec2)
  11412. * @param uniform defines the webGL uniform location where to store the value
  11413. * @param array defines the array of number to store
  11414. */
  11415. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11416. /**
  11417. * Set the value of an uniform to an array of number (stored as vec3)
  11418. * @param uniform defines the webGL uniform location where to store the value
  11419. * @param array defines the array of number to store
  11420. */
  11421. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11422. /**
  11423. * Set the value of an uniform to an array of number (stored as vec4)
  11424. * @param uniform defines the webGL uniform location where to store the value
  11425. * @param array defines the array of number to store
  11426. */
  11427. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11428. /**
  11429. * Set the value of an uniform to an array of float32 (stored as matrices)
  11430. * @param uniform defines the webGL uniform location where to store the value
  11431. * @param matrices defines the array of float32 to store
  11432. */
  11433. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  11434. /**
  11435. * Set the value of an uniform to a matrix
  11436. * @param uniform defines the webGL uniform location where to store the value
  11437. * @param matrix defines the matrix to store
  11438. */
  11439. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  11440. /**
  11441. * Set the value of an uniform to a matrix (3x3)
  11442. * @param uniform defines the webGL uniform location where to store the value
  11443. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  11444. */
  11445. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11446. /**
  11447. * Set the value of an uniform to a matrix (2x2)
  11448. * @param uniform defines the webGL uniform location where to store the value
  11449. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  11450. */
  11451. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11452. /**
  11453. * Set the value of an uniform to a number (int)
  11454. * @param uniform defines the webGL uniform location where to store the value
  11455. * @param value defines the int number to store
  11456. */
  11457. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11458. /**
  11459. * Set the value of an uniform to a number (float)
  11460. * @param uniform defines the webGL uniform location where to store the value
  11461. * @param value defines the float number to store
  11462. */
  11463. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11464. /**
  11465. * Set the value of an uniform to a vec2
  11466. * @param uniform defines the webGL uniform location where to store the value
  11467. * @param x defines the 1st component of the value
  11468. * @param y defines the 2nd component of the value
  11469. */
  11470. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  11471. /**
  11472. * Set the value of an uniform to a vec3
  11473. * @param uniform defines the webGL uniform location where to store the value
  11474. * @param x defines the 1st component of the value
  11475. * @param y defines the 2nd component of the value
  11476. * @param z defines the 3rd component of the value
  11477. */
  11478. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  11479. /**
  11480. * Set the value of an uniform to a boolean
  11481. * @param uniform defines the webGL uniform location where to store the value
  11482. * @param bool defines the boolean to store
  11483. */
  11484. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  11485. /**
  11486. * Set the value of an uniform to a vec4
  11487. * @param uniform defines the webGL uniform location where to store the value
  11488. * @param x defines the 1st component of the value
  11489. * @param y defines the 2nd component of the value
  11490. * @param z defines the 3rd component of the value
  11491. * @param w defines the 4th component of the value
  11492. */
  11493. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  11494. /**
  11495. * Set the value of an uniform to a Color3
  11496. * @param uniform defines the webGL uniform location where to store the value
  11497. * @param color3 defines the color to store
  11498. */
  11499. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  11500. /**
  11501. * Set the value of an uniform to a Color3 and an alpha value
  11502. * @param uniform defines the webGL uniform location where to store the value
  11503. * @param color3 defines the color to store
  11504. * @param alpha defines the alpha component to store
  11505. */
  11506. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  11507. /**
  11508. * Sets a Color4 on a uniform variable
  11509. * @param uniform defines the uniform location
  11510. * @param color4 defines the value to be set
  11511. */
  11512. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  11513. /**
  11514. * Set various states to the webGL context
  11515. * @param culling defines backface culling state
  11516. * @param zOffset defines the value to apply to zOffset (0 by default)
  11517. * @param force defines if states must be applied even if cache is up to date
  11518. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  11519. */
  11520. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11521. /**
  11522. * Set the z offset to apply to current rendering
  11523. * @param value defines the offset to apply
  11524. */
  11525. setZOffset(value: number): void;
  11526. /**
  11527. * Gets the current value of the zOffset
  11528. * @returns the current zOffset state
  11529. */
  11530. getZOffset(): number;
  11531. /**
  11532. * Enable or disable depth buffering
  11533. * @param enable defines the state to set
  11534. */
  11535. setDepthBuffer(enable: boolean): void;
  11536. /**
  11537. * Gets a boolean indicating if depth writing is enabled
  11538. * @returns the current depth writing state
  11539. */
  11540. getDepthWrite(): boolean;
  11541. /**
  11542. * Enable or disable depth writing
  11543. * @param enable defines the state to set
  11544. */
  11545. setDepthWrite(enable: boolean): void;
  11546. /**
  11547. * Enable or disable color writing
  11548. * @param enable defines the state to set
  11549. */
  11550. setColorWrite(enable: boolean): void;
  11551. /**
  11552. * Gets a boolean indicating if color writing is enabled
  11553. * @returns the current color writing state
  11554. */
  11555. getColorWrite(): boolean;
  11556. /**
  11557. * Sets alpha constants used by some alpha blending modes
  11558. * @param r defines the red component
  11559. * @param g defines the green component
  11560. * @param b defines the blue component
  11561. * @param a defines the alpha component
  11562. */
  11563. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  11564. /**
  11565. * Sets the current alpha mode
  11566. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  11567. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  11568. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11569. */
  11570. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11571. /**
  11572. * Gets the current alpha mode
  11573. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11574. * @returns the current alpha mode
  11575. */
  11576. getAlphaMode(): number;
  11577. /**
  11578. * Clears the list of texture accessible through engine.
  11579. * This can help preventing texture load conflict due to name collision.
  11580. */
  11581. clearInternalTexturesCache(): void;
  11582. /**
  11583. * Force the entire cache to be cleared
  11584. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  11585. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  11586. */
  11587. wipeCaches(bruteForce?: boolean): void;
  11588. /**
  11589. * Set the compressed texture format to use, based on the formats you have, and the formats
  11590. * supported by the hardware / browser.
  11591. *
  11592. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  11593. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  11594. * to API arguments needed to compressed textures. This puts the burden on the container
  11595. * generator to house the arcane code for determining these for current & future formats.
  11596. *
  11597. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  11598. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  11599. *
  11600. * Note: The result of this call is not taken into account when a texture is base64.
  11601. *
  11602. * @param formatsAvailable defines the list of those format families you have created
  11603. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  11604. *
  11605. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  11606. * @returns The extension selected.
  11607. */
  11608. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  11609. private _getSamplingParameters;
  11610. private _partialLoadImg;
  11611. private _cascadeLoadImgs;
  11612. /** @hidden */
  11613. _createTexture(): WebGLTexture;
  11614. /**
  11615. * Usually called from BABYLON.Texture.ts.
  11616. * Passed information to create a WebGLTexture
  11617. * @param urlArg defines a value which contains one of the following:
  11618. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  11619. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  11620. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  11621. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  11622. * @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)
  11623. * @param scene needed for loading to the correct scene
  11624. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  11625. * @param onLoad optional callback to be called upon successful completion
  11626. * @param onError optional callback to be called upon failure
  11627. * @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
  11628. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  11629. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  11630. * @param forcedExtension defines the extension to use to pick the right loader
  11631. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  11632. * @returns a InternalTexture for assignment back into BABYLON.Texture
  11633. */
  11634. 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;
  11635. private _rescaleTexture;
  11636. /**
  11637. * Update a raw texture
  11638. * @param texture defines the texture to update
  11639. * @param data defines the data to store in the texture
  11640. * @param format defines the format of the data
  11641. * @param invertY defines if data must be stored with Y axis inverted
  11642. * @param compression defines the compression used (null by default)
  11643. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11644. */
  11645. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  11646. /**
  11647. * Creates a raw texture
  11648. * @param data defines the data to store in the texture
  11649. * @param width defines the width of the texture
  11650. * @param height defines the height of the texture
  11651. * @param format defines the format of the data
  11652. * @param generateMipMaps defines if the engine should generate the mip levels
  11653. * @param invertY defines if data must be stored with Y axis inverted
  11654. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11655. * @param compression defines the compression used (null by default)
  11656. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11657. * @returns the raw texture inside an InternalTexture
  11658. */
  11659. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  11660. private _unpackFlipYCached;
  11661. /**
  11662. * In case you are sharing the context with other applications, it might
  11663. * be interested to not cache the unpack flip y state to ensure a consistent
  11664. * value would be set.
  11665. */
  11666. enableUnpackFlipYCached: boolean;
  11667. /** @hidden */
  11668. _unpackFlipY(value: boolean): void;
  11669. /** @hidden */
  11670. _getUnpackAlignement(): number;
  11671. /**
  11672. * Creates a dynamic texture
  11673. * @param width defines the width of the texture
  11674. * @param height defines the height of the texture
  11675. * @param generateMipMaps defines if the engine should generate the mip levels
  11676. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11677. * @returns the dynamic texture inside an InternalTexture
  11678. */
  11679. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11680. /**
  11681. * Update the sampling mode of a given texture
  11682. * @param samplingMode defines the required sampling mode
  11683. * @param texture defines the texture to update
  11684. */
  11685. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11686. /**
  11687. * Update the content of a dynamic texture
  11688. * @param texture defines the texture to update
  11689. * @param canvas defines the canvas containing the source
  11690. * @param invertY defines if data must be stored with Y axis inverted
  11691. * @param premulAlpha defines if alpha is stored as premultiplied
  11692. * @param format defines the format of the data
  11693. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11694. */
  11695. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11696. /**
  11697. * Update a video texture
  11698. * @param texture defines the texture to update
  11699. * @param video defines the video element to use
  11700. * @param invertY defines if data must be stored with Y axis inverted
  11701. */
  11702. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11703. /**
  11704. * Updates a depth texture Comparison Mode and Function.
  11705. * If the comparison Function is equal to 0, the mode will be set to none.
  11706. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11707. * @param texture The texture to set the comparison function for
  11708. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11709. */
  11710. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11711. private _setupDepthStencilTexture;
  11712. /**
  11713. * Creates a depth stencil texture.
  11714. * This is only available in WebGL 2 or with the depth texture extension available.
  11715. * @param size The size of face edge in the texture.
  11716. * @param options The options defining the texture.
  11717. * @returns The texture
  11718. */
  11719. createDepthStencilTexture(size: number | {
  11720. width: number;
  11721. height: number;
  11722. }, options: DepthTextureCreationOptions): InternalTexture;
  11723. /**
  11724. * Creates a depth stencil texture.
  11725. * This is only available in WebGL 2 or with the depth texture extension available.
  11726. * @param size The size of face edge in the texture.
  11727. * @param options The options defining the texture.
  11728. * @returns The texture
  11729. */
  11730. private _createDepthStencilTexture;
  11731. /**
  11732. * Creates a depth stencil cube texture.
  11733. * This is only available in WebGL 2.
  11734. * @param size The size of face edge in the cube texture.
  11735. * @param options The options defining the cube texture.
  11736. * @returns The cube texture
  11737. */
  11738. private _createDepthStencilCubeTexture;
  11739. /**
  11740. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11741. * @param renderTarget The render target to set the frame buffer for
  11742. */
  11743. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11744. /**
  11745. * Creates a new render target texture
  11746. * @param size defines the size of the texture
  11747. * @param options defines the options used to create the texture
  11748. * @returns a new render target texture stored in an InternalTexture
  11749. */
  11750. createRenderTargetTexture(size: number | {
  11751. width: number;
  11752. height: number;
  11753. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11754. /**
  11755. * Create a multi render target texture
  11756. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11757. * @param size defines the size of the texture
  11758. * @param options defines the creation options
  11759. * @returns the cube texture as an InternalTexture
  11760. */
  11761. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11762. private _setupFramebufferDepthAttachments;
  11763. /**
  11764. * Updates the sample count of a render target texture
  11765. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11766. * @param texture defines the texture to update
  11767. * @param samples defines the sample count to set
  11768. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11769. */
  11770. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11771. /**
  11772. * Update the sample count for a given multiple render target texture
  11773. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11774. * @param textures defines the textures to update
  11775. * @param samples defines the sample count to set
  11776. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11777. */
  11778. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11779. /** @hidden */
  11780. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11781. /** @hidden */
  11782. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11783. /** @hidden */
  11784. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11785. /** @hidden */
  11786. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11787. /**
  11788. * Creates a new render target cube texture
  11789. * @param size defines the size of the texture
  11790. * @param options defines the options used to create the texture
  11791. * @returns a new render target cube texture stored in an InternalTexture
  11792. */
  11793. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11794. /**
  11795. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11796. * @param rootUrl defines the url where the file to load is located
  11797. * @param scene defines the current scene
  11798. * @param lodScale defines scale to apply to the mip map selection
  11799. * @param lodOffset defines offset to apply to the mip map selection
  11800. * @param onLoad defines an optional callback raised when the texture is loaded
  11801. * @param onError defines an optional callback raised if there is an issue to load the texture
  11802. * @param format defines the format of the data
  11803. * @param forcedExtension defines the extension to use to pick the right loader
  11804. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11805. * @returns the cube texture as an InternalTexture
  11806. */
  11807. 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;
  11808. /**
  11809. * Creates a cube texture
  11810. * @param rootUrl defines the url where the files to load is located
  11811. * @param scene defines the current scene
  11812. * @param files defines the list of files to load (1 per face)
  11813. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11814. * @param onLoad defines an optional callback raised when the texture is loaded
  11815. * @param onError defines an optional callback raised if there is an issue to load the texture
  11816. * @param format defines the format of the data
  11817. * @param forcedExtension defines the extension to use to pick the right loader
  11818. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11819. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11820. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11821. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11822. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  11823. * @returns the cube texture as an InternalTexture
  11824. */
  11825. 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;
  11826. /**
  11827. * @hidden
  11828. */
  11829. _setCubeMapTextureParams(loadMipmap: boolean): void;
  11830. /**
  11831. * Update a raw cube texture
  11832. * @param texture defines the texture to udpdate
  11833. * @param data defines the data to store
  11834. * @param format defines the data format
  11835. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11836. * @param invertY defines if data must be stored with Y axis inverted
  11837. * @param compression defines the compression used (null by default)
  11838. * @param level defines which level of the texture to update
  11839. */
  11840. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11841. /**
  11842. * Creates a new raw cube texture
  11843. * @param data defines the array of data to use to create each face
  11844. * @param size defines the size of the textures
  11845. * @param format defines the format of the data
  11846. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11847. * @param generateMipMaps defines if the engine should generate the mip levels
  11848. * @param invertY defines if data must be stored with Y axis inverted
  11849. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11850. * @param compression defines the compression used (null by default)
  11851. * @returns the cube texture as an InternalTexture
  11852. */
  11853. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11854. /**
  11855. * Creates a new raw cube texture from a specified url
  11856. * @param url defines the url where the data is located
  11857. * @param scene defines the current scene
  11858. * @param size defines the size of the textures
  11859. * @param format defines the format of the data
  11860. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11861. * @param noMipmap defines if the engine should avoid generating the mip levels
  11862. * @param callback defines a callback used to extract texture data from loaded data
  11863. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11864. * @param onLoad defines a callback called when texture is loaded
  11865. * @param onError defines a callback called if there is an error
  11866. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11867. * @param invertY defines if data must be stored with Y axis inverted
  11868. * @returns the cube texture as an InternalTexture
  11869. */
  11870. 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;
  11871. /**
  11872. * Update a raw 3D texture
  11873. * @param texture defines the texture to update
  11874. * @param data defines the data to store
  11875. * @param format defines the data format
  11876. * @param invertY defines if data must be stored with Y axis inverted
  11877. * @param compression defines the used compression (can be null)
  11878. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11879. */
  11880. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11881. /**
  11882. * Creates a new raw 3D texture
  11883. * @param data defines the data used to create the texture
  11884. * @param width defines the width of the texture
  11885. * @param height defines the height of the texture
  11886. * @param depth defines the depth of the texture
  11887. * @param format defines the format of the texture
  11888. * @param generateMipMaps defines if the engine must generate mip levels
  11889. * @param invertY defines if data must be stored with Y axis inverted
  11890. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11891. * @param compression defines the compressed used (can be null)
  11892. * @param textureType defines the compressed used (can be null)
  11893. * @returns a new raw 3D texture (stored in an InternalTexture)
  11894. */
  11895. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11896. private _prepareWebGLTextureContinuation;
  11897. private _prepareWebGLTexture;
  11898. private _convertRGBtoRGBATextureData;
  11899. /** @hidden */
  11900. _releaseFramebufferObjects(texture: InternalTexture): void;
  11901. /** @hidden */
  11902. _releaseTexture(texture: InternalTexture): void;
  11903. private setProgram;
  11904. private _boundUniforms;
  11905. /**
  11906. * Binds an effect to the webGL context
  11907. * @param effect defines the effect to bind
  11908. */
  11909. bindSamplers(effect: Effect): void;
  11910. private _moveBoundTextureOnTop;
  11911. private _getCorrectTextureChannel;
  11912. private _linkTrackers;
  11913. private _removeDesignatedSlot;
  11914. private _activateCurrentTexture;
  11915. /** @hidden */
  11916. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11917. /** @hidden */
  11918. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  11919. /**
  11920. * Sets a texture to the webGL context from a postprocess
  11921. * @param channel defines the channel to use
  11922. * @param postProcess defines the source postprocess
  11923. */
  11924. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11925. /**
  11926. * Binds the output of the passed in post process to the texture channel specified
  11927. * @param channel The channel the texture should be bound to
  11928. * @param postProcess The post process which's output should be bound
  11929. */
  11930. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11931. /**
  11932. * Unbind all textures from the webGL context
  11933. */
  11934. unbindAllTextures(): void;
  11935. /**
  11936. * Sets a texture to the according uniform.
  11937. * @param channel The texture channel
  11938. * @param uniform The uniform to set
  11939. * @param texture The texture to apply
  11940. */
  11941. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11942. /**
  11943. * Sets a depth stencil texture from a render target to the according uniform.
  11944. * @param channel The texture channel
  11945. * @param uniform The uniform to set
  11946. * @param texture The render target texture containing the depth stencil texture to apply
  11947. */
  11948. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11949. private _bindSamplerUniformToChannel;
  11950. private _getTextureWrapMode;
  11951. private _setTexture;
  11952. /**
  11953. * Sets an array of texture to the webGL context
  11954. * @param channel defines the channel where the texture array must be set
  11955. * @param uniform defines the associated uniform location
  11956. * @param textures defines the array of textures to bind
  11957. */
  11958. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11959. /** @hidden */
  11960. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  11961. private _setTextureParameterFloat;
  11962. private _setTextureParameterInteger;
  11963. /**
  11964. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11965. * @param x defines the x coordinate of the rectangle where pixels must be read
  11966. * @param y defines the y coordinate of the rectangle where pixels must be read
  11967. * @param width defines the width of the rectangle where pixels must be read
  11968. * @param height defines the height of the rectangle where pixels must be read
  11969. * @returns a Uint8Array containing RGBA colors
  11970. */
  11971. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11972. /**
  11973. * Add an externaly attached data from its key.
  11974. * This method call will fail and return false, if such key already exists.
  11975. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11976. * @param key the unique key that identifies the data
  11977. * @param data the data object to associate to the key for this Engine instance
  11978. * @return true if no such key were already present and the data was added successfully, false otherwise
  11979. */
  11980. addExternalData<T>(key: string, data: T): boolean;
  11981. /**
  11982. * Get an externaly attached data from its key
  11983. * @param key the unique key that identifies the data
  11984. * @return the associated data, if present (can be null), or undefined if not present
  11985. */
  11986. getExternalData<T>(key: string): T;
  11987. /**
  11988. * Get an externaly attached data from its key, create it using a factory if it's not already present
  11989. * @param key the unique key that identifies the data
  11990. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  11991. * @return the associated data, can be null if the factory returned null.
  11992. */
  11993. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  11994. /**
  11995. * Remove an externaly attached data from the Engine instance
  11996. * @param key the unique key that identifies the data
  11997. * @return true if the data was successfully removed, false if it doesn't exist
  11998. */
  11999. removeExternalData(key: string): boolean;
  12000. /**
  12001. * Unbind all vertex attributes from the webGL context
  12002. */
  12003. unbindAllAttributes(): void;
  12004. /**
  12005. * 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
  12006. */
  12007. releaseEffects(): void;
  12008. /**
  12009. * Dispose and release all associated resources
  12010. */
  12011. dispose(): void;
  12012. /**
  12013. * Display the loading screen
  12014. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12015. */
  12016. displayLoadingUI(): void;
  12017. /**
  12018. * Hide the loading screen
  12019. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12020. */
  12021. hideLoadingUI(): void;
  12022. /**
  12023. * Gets the current loading screen object
  12024. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12025. */
  12026. /**
  12027. * Sets the current loading screen object
  12028. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12029. */
  12030. loadingScreen: ILoadingScreen;
  12031. /**
  12032. * Sets the current loading screen text
  12033. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12034. */
  12035. loadingUIText: string;
  12036. /**
  12037. * Sets the current loading screen background color
  12038. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  12039. */
  12040. loadingUIBackgroundColor: string;
  12041. /**
  12042. * Attach a new callback raised when context lost event is fired
  12043. * @param callback defines the callback to call
  12044. */
  12045. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  12046. /**
  12047. * Attach a new callback raised when context restored event is fired
  12048. * @param callback defines the callback to call
  12049. */
  12050. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  12051. /**
  12052. * Gets the source code of the vertex shader associated with a specific webGL program
  12053. * @param program defines the program to use
  12054. * @returns a string containing the source code of the vertex shader associated with the program
  12055. */
  12056. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  12057. /**
  12058. * Gets the source code of the fragment shader associated with a specific webGL program
  12059. * @param program defines the program to use
  12060. * @returns a string containing the source code of the fragment shader associated with the program
  12061. */
  12062. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  12063. /**
  12064. * Get the current error code of the webGL context
  12065. * @returns the error code
  12066. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12067. */
  12068. getError(): number;
  12069. /**
  12070. * Gets the current framerate
  12071. * @returns a number representing the framerate
  12072. */
  12073. getFps(): number;
  12074. /**
  12075. * Gets the time spent between current and previous frame
  12076. * @returns a number representing the delta time in ms
  12077. */
  12078. getDeltaTime(): number;
  12079. private _measureFps;
  12080. /** @hidden */
  12081. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  12082. private _canRenderToFloatFramebuffer;
  12083. private _canRenderToHalfFloatFramebuffer;
  12084. private _canRenderToFramebuffer;
  12085. /** @hidden */
  12086. _getWebGLTextureType(type: number): number;
  12087. private _getInternalFormat;
  12088. /** @hidden */
  12089. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  12090. /** @hidden */
  12091. _getRGBAMultiSampleBufferFormat(type: number): number;
  12092. /** @hidden */
  12093. _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;
  12094. /** @hidden */
  12095. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  12096. private _partialLoadFile;
  12097. private _cascadeLoadFiles;
  12098. /**
  12099. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  12100. * @returns true if the engine can be created
  12101. * @ignorenaming
  12102. */
  12103. static isSupported(): boolean;
  12104. }
  12105. }
  12106. declare module BABYLON {
  12107. /**
  12108. * Options to create the null engine
  12109. */
  12110. class NullEngineOptions {
  12111. /**
  12112. * Render width (Default: 512)
  12113. */
  12114. renderWidth: number;
  12115. /**
  12116. * Render height (Default: 256)
  12117. */
  12118. renderHeight: number;
  12119. /**
  12120. * Texture size (Default: 512)
  12121. */
  12122. textureSize: number;
  12123. /**
  12124. * If delta time between frames should be constant
  12125. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12126. */
  12127. deterministicLockstep: boolean;
  12128. /**
  12129. * Maximum about of steps between frames (Default: 4)
  12130. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12131. */
  12132. lockstepMaxSteps: number;
  12133. }
  12134. /**
  12135. * The null engine class provides support for headless version of babylon.js.
  12136. * This can be used in server side scenario or for testing purposes
  12137. */
  12138. class NullEngine extends Engine {
  12139. private _options;
  12140. /**
  12141. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12142. */
  12143. isDeterministicLockStep(): boolean;
  12144. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  12145. getLockstepMaxSteps(): number;
  12146. /**
  12147. * Sets hardware scaling, used to save performance if needed
  12148. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  12149. */
  12150. getHardwareScalingLevel(): number;
  12151. constructor(options?: NullEngineOptions);
  12152. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12153. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  12154. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  12155. getRenderWidth(useScreen?: boolean): number;
  12156. getRenderHeight(useScreen?: boolean): number;
  12157. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  12158. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  12159. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  12160. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  12161. bindSamplers(effect: Effect): void;
  12162. enableEffect(effect: Effect): void;
  12163. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  12164. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  12165. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  12166. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  12167. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  12168. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  12169. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  12170. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  12171. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  12172. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  12173. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  12174. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  12175. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  12176. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  12177. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  12178. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12179. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12180. setFloat(uniform: WebGLUniformLocation, value: number): void;
  12181. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  12182. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  12183. setBool(uniform: WebGLUniformLocation, bool: number): void;
  12184. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  12185. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  12186. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  12187. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12188. bindBuffers(vertexBuffers: {
  12189. [key: string]: VertexBuffer;
  12190. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  12191. wipeCaches(bruteForce?: boolean): void;
  12192. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  12193. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  12194. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  12195. /** @hidden */
  12196. _createTexture(): WebGLTexture;
  12197. /** @hidden */
  12198. _releaseTexture(texture: InternalTexture): void;
  12199. 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;
  12200. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12201. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  12202. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  12203. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  12204. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12205. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  12206. areAllEffectsReady(): boolean;
  12207. /**
  12208. * @hidden
  12209. * Get the current error code of the webGL context
  12210. * @returns the error code
  12211. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12212. */
  12213. getError(): number;
  12214. /** @hidden */
  12215. _getUnpackAlignement(): number;
  12216. /** @hidden */
  12217. _unpackFlipY(value: boolean): void;
  12218. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  12219. /**
  12220. * Updates a dynamic vertex buffer.
  12221. * @param vertexBuffer the vertex buffer to update
  12222. * @param data the data used to update the vertex buffer
  12223. * @param byteOffset the byte offset of the data (optional)
  12224. * @param byteLength the byte length of the data (optional)
  12225. */
  12226. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  12227. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  12228. /** @hidden */
  12229. _bindTexture(channel: number, texture: InternalTexture): void;
  12230. /** @hidden */
  12231. _releaseBuffer(buffer: WebGLBuffer): boolean;
  12232. releaseEffects(): void;
  12233. displayLoadingUI(): void;
  12234. hideLoadingUI(): void;
  12235. /** @hidden */
  12236. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12237. /** @hidden */
  12238. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12239. /** @hidden */
  12240. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12241. /** @hidden */
  12242. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  12243. }
  12244. }
  12245. interface WebGLRenderingContext {
  12246. readonly RASTERIZER_DISCARD: number;
  12247. readonly DEPTH_COMPONENT24: number;
  12248. readonly TEXTURE_3D: number;
  12249. readonly TEXTURE_2D_ARRAY: number;
  12250. readonly TEXTURE_COMPARE_FUNC: number;
  12251. readonly TEXTURE_COMPARE_MODE: number;
  12252. readonly COMPARE_REF_TO_TEXTURE: number;
  12253. readonly TEXTURE_WRAP_R: number;
  12254. readonly HALF_FLOAT: number;
  12255. readonly RGB8: number;
  12256. readonly RED_INTEGER: number;
  12257. readonly RG_INTEGER: number;
  12258. readonly RGB_INTEGER: number;
  12259. readonly RGBA_INTEGER: number;
  12260. readonly R8_SNORM: number;
  12261. readonly RG8_SNORM: number;
  12262. readonly RGB8_SNORM: number;
  12263. readonly RGBA8_SNORM: number;
  12264. readonly R8I: number;
  12265. readonly RG8I: number;
  12266. readonly RGB8I: number;
  12267. readonly RGBA8I: number;
  12268. readonly R8UI: number;
  12269. readonly RG8UI: number;
  12270. readonly RGB8UI: number;
  12271. readonly RGBA8UI: number;
  12272. readonly R16I: number;
  12273. readonly RG16I: number;
  12274. readonly RGB16I: number;
  12275. readonly RGBA16I: number;
  12276. readonly R16UI: number;
  12277. readonly RG16UI: number;
  12278. readonly RGB16UI: number;
  12279. readonly RGBA16UI: number;
  12280. readonly R32I: number;
  12281. readonly RG32I: number;
  12282. readonly RGB32I: number;
  12283. readonly RGBA32I: number;
  12284. readonly R32UI: number;
  12285. readonly RG32UI: number;
  12286. readonly RGB32UI: number;
  12287. readonly RGBA32UI: number;
  12288. readonly RGB10_A2UI: number;
  12289. readonly R11F_G11F_B10F: number;
  12290. readonly RGB9_E5: number;
  12291. readonly RGB10_A2: number;
  12292. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  12293. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  12294. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  12295. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  12296. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  12297. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  12298. 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;
  12299. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  12300. readonly TRANSFORM_FEEDBACK: number;
  12301. readonly INTERLEAVED_ATTRIBS: number;
  12302. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  12303. createTransformFeedback(): WebGLTransformFeedback;
  12304. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  12305. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  12306. beginTransformFeedback(primitiveMode: number): void;
  12307. endTransformFeedback(): void;
  12308. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  12309. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12310. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12311. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12312. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  12313. }
  12314. interface ImageBitmap {
  12315. readonly width: number;
  12316. readonly height: number;
  12317. close(): void;
  12318. }
  12319. interface WebGLQuery extends WebGLObject {
  12320. }
  12321. declare var WebGLQuery: {
  12322. prototype: WebGLQuery;
  12323. new (): WebGLQuery;
  12324. };
  12325. interface WebGLSampler extends WebGLObject {
  12326. }
  12327. declare var WebGLSampler: {
  12328. prototype: WebGLSampler;
  12329. new (): WebGLSampler;
  12330. };
  12331. interface WebGLSync extends WebGLObject {
  12332. }
  12333. declare var WebGLSync: {
  12334. prototype: WebGLSync;
  12335. new (): WebGLSync;
  12336. };
  12337. interface WebGLTransformFeedback extends WebGLObject {
  12338. }
  12339. declare var WebGLTransformFeedback: {
  12340. prototype: WebGLTransformFeedback;
  12341. new (): WebGLTransformFeedback;
  12342. };
  12343. interface WebGLVertexArrayObject extends WebGLObject {
  12344. }
  12345. declare var WebGLVertexArrayObject: {
  12346. prototype: WebGLVertexArrayObject;
  12347. new (): WebGLVertexArrayObject;
  12348. };
  12349. declare module BABYLON {
  12350. /**
  12351. * Gather the list of clipboard event types as constants.
  12352. */
  12353. class ClipboardEventTypes {
  12354. /**
  12355. * The clipboard event is fired when a copy command is active (pressed).
  12356. */
  12357. static readonly COPY: number;
  12358. /**
  12359. * The clipboard event is fired when a cut command is active (pressed).
  12360. */
  12361. static readonly CUT: number;
  12362. /**
  12363. * The clipboard event is fired when a paste command is active (pressed).
  12364. */
  12365. static readonly PASTE: number;
  12366. }
  12367. /**
  12368. * This class is used to store clipboard related info for the onClipboardObservable event.
  12369. */
  12370. class ClipboardInfo {
  12371. /**
  12372. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12373. */
  12374. type: number;
  12375. /**
  12376. * Defines the related dom event
  12377. */
  12378. event: ClipboardEvent;
  12379. /**
  12380. *Creates an instance of ClipboardInfo.
  12381. * @param {number} type
  12382. * @param {ClipboardEvent} event
  12383. */
  12384. constructor(
  12385. /**
  12386. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12387. */
  12388. type: number,
  12389. /**
  12390. * Defines the related dom event
  12391. */
  12392. event: ClipboardEvent);
  12393. /**
  12394. * Get the clipboard event's type from the keycode.
  12395. * @param keyCode Defines the keyCode for the current keyboard event.
  12396. * @return {number}
  12397. */
  12398. static GetTypeFromCharacter(keyCode: number): number;
  12399. }
  12400. }
  12401. declare module BABYLON {
  12402. /**
  12403. * Gather the list of keyboard event types as constants.
  12404. */
  12405. class KeyboardEventTypes {
  12406. /**
  12407. * The keydown event is fired when a key becomes active (pressed).
  12408. */
  12409. static readonly KEYDOWN: number;
  12410. /**
  12411. * The keyup event is fired when a key has been released.
  12412. */
  12413. static readonly KEYUP: number;
  12414. }
  12415. /**
  12416. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12417. */
  12418. class KeyboardInfo {
  12419. /**
  12420. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12421. */
  12422. type: number;
  12423. /**
  12424. * Defines the related dom event
  12425. */
  12426. event: KeyboardEvent;
  12427. /**
  12428. * Instantiates a new keyboard info.
  12429. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12430. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12431. * @param event Defines the related dom event
  12432. */
  12433. constructor(
  12434. /**
  12435. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12436. */
  12437. type: number,
  12438. /**
  12439. * Defines the related dom event
  12440. */
  12441. event: KeyboardEvent);
  12442. }
  12443. /**
  12444. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12445. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  12446. */
  12447. class KeyboardInfoPre extends KeyboardInfo {
  12448. /**
  12449. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12450. */
  12451. type: number;
  12452. /**
  12453. * Defines the related dom event
  12454. */
  12455. event: KeyboardEvent;
  12456. /**
  12457. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  12458. */
  12459. skipOnPointerObservable: boolean;
  12460. /**
  12461. * Instantiates a new keyboard pre info.
  12462. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12463. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12464. * @param event Defines the related dom event
  12465. */
  12466. constructor(
  12467. /**
  12468. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12469. */
  12470. type: number,
  12471. /**
  12472. * Defines the related dom event
  12473. */
  12474. event: KeyboardEvent);
  12475. }
  12476. }
  12477. declare module BABYLON {
  12478. /**
  12479. * Gather the list of pointer event types as constants.
  12480. */
  12481. class PointerEventTypes {
  12482. /**
  12483. * 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.
  12484. */
  12485. static readonly POINTERDOWN: number;
  12486. /**
  12487. * The pointerup event is fired when a pointer is no longer active.
  12488. */
  12489. static readonly POINTERUP: number;
  12490. /**
  12491. * The pointermove event is fired when a pointer changes coordinates.
  12492. */
  12493. static readonly POINTERMOVE: number;
  12494. /**
  12495. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12496. */
  12497. static readonly POINTERWHEEL: number;
  12498. /**
  12499. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12500. */
  12501. static readonly POINTERPICK: number;
  12502. /**
  12503. * The pointertap event is fired when a the object has been touched and released without drag.
  12504. */
  12505. static readonly POINTERTAP: number;
  12506. /**
  12507. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12508. */
  12509. static readonly POINTERDOUBLETAP: number;
  12510. }
  12511. /**
  12512. * Base class of pointer info types.
  12513. */
  12514. class PointerInfoBase {
  12515. /**
  12516. * Defines the type of event (BABYLON.PointerEventTypes)
  12517. */
  12518. type: number;
  12519. /**
  12520. * Defines the related dom event
  12521. */
  12522. event: PointerEvent | MouseWheelEvent;
  12523. /**
  12524. * Instantiates the base class of pointers info.
  12525. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12526. * @param event Defines the related dom event
  12527. */
  12528. constructor(
  12529. /**
  12530. * Defines the type of event (BABYLON.PointerEventTypes)
  12531. */
  12532. type: number,
  12533. /**
  12534. * Defines the related dom event
  12535. */
  12536. event: PointerEvent | MouseWheelEvent);
  12537. }
  12538. /**
  12539. * This class is used to store pointer related info for the onPrePointerObservable event.
  12540. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12541. */
  12542. class PointerInfoPre extends PointerInfoBase {
  12543. /**
  12544. * Ray from a pointer if availible (eg. 6dof controller)
  12545. */
  12546. ray: Nullable<Ray>;
  12547. /**
  12548. * Defines the local position of the pointer on the canvas.
  12549. */
  12550. localPosition: Vector2;
  12551. /**
  12552. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12553. */
  12554. skipOnPointerObservable: boolean;
  12555. /**
  12556. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12557. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12558. * @param event Defines the related dom event
  12559. * @param localX Defines the local x coordinates of the pointer when the event occured
  12560. * @param localY Defines the local y coordinates of the pointer when the event occured
  12561. */
  12562. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12563. }
  12564. /**
  12565. * This type contains all the data related to a pointer event in Babylon.js.
  12566. * 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.
  12567. */
  12568. class PointerInfo extends PointerInfoBase {
  12569. /**
  12570. * Defines the picking info associated to the info (if any)\
  12571. */
  12572. pickInfo: Nullable<PickingInfo>;
  12573. /**
  12574. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12575. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12576. * @param event Defines the related dom event
  12577. * @param pickInfo Defines the picking info associated to the info (if any)\
  12578. */
  12579. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12580. /**
  12581. * Defines the picking info associated to the info (if any)\
  12582. */
  12583. pickInfo: Nullable<PickingInfo>);
  12584. }
  12585. }
  12586. declare module BABYLON {
  12587. /**
  12588. * Represents a gamepad control stick position
  12589. */
  12590. class StickValues {
  12591. /**
  12592. * The x component of the control stick
  12593. */
  12594. x: number;
  12595. /**
  12596. * The y component of the control stick
  12597. */
  12598. y: number;
  12599. /**
  12600. * Initializes the gamepad x and y control stick values
  12601. * @param x The x component of the gamepad control stick value
  12602. * @param y The y component of the gamepad control stick value
  12603. */
  12604. constructor(
  12605. /**
  12606. * The x component of the control stick
  12607. */
  12608. x: number,
  12609. /**
  12610. * The y component of the control stick
  12611. */
  12612. y: number);
  12613. }
  12614. /**
  12615. * An interface which manages callbacks for gamepad button changes
  12616. */
  12617. interface GamepadButtonChanges {
  12618. /**
  12619. * Called when a gamepad has been changed
  12620. */
  12621. changed: boolean;
  12622. /**
  12623. * Called when a gamepad press event has been triggered
  12624. */
  12625. pressChanged: boolean;
  12626. /**
  12627. * Called when a touch event has been triggered
  12628. */
  12629. touchChanged: boolean;
  12630. /**
  12631. * Called when a value has changed
  12632. */
  12633. valueChanged: boolean;
  12634. }
  12635. /**
  12636. * Represents a gamepad
  12637. */
  12638. class Gamepad {
  12639. /**
  12640. * The id of the gamepad
  12641. */
  12642. id: string;
  12643. /**
  12644. * The index of the gamepad
  12645. */
  12646. index: number;
  12647. /**
  12648. * The browser gamepad
  12649. */
  12650. browserGamepad: any;
  12651. /**
  12652. * Specifies what type of gamepad this represents
  12653. */
  12654. type: number;
  12655. private _leftStick;
  12656. private _rightStick;
  12657. /** @hidden */
  12658. _isConnected: boolean;
  12659. private _leftStickAxisX;
  12660. private _leftStickAxisY;
  12661. private _rightStickAxisX;
  12662. private _rightStickAxisY;
  12663. /**
  12664. * Triggered when the left control stick has been changed
  12665. */
  12666. private _onleftstickchanged;
  12667. /**
  12668. * Triggered when the right control stick has been changed
  12669. */
  12670. private _onrightstickchanged;
  12671. /**
  12672. * Represents a gamepad controller
  12673. */
  12674. static GAMEPAD: number;
  12675. /**
  12676. * Represents a generic controller
  12677. */
  12678. static GENERIC: number;
  12679. /**
  12680. * Represents an XBox controller
  12681. */
  12682. static XBOX: number;
  12683. /**
  12684. * Represents a pose-enabled controller
  12685. */
  12686. static POSE_ENABLED: number;
  12687. /**
  12688. * Specifies whether the left control stick should be Y-inverted
  12689. */
  12690. protected _invertLeftStickY: boolean;
  12691. /**
  12692. * Specifies if the gamepad has been connected
  12693. */
  12694. readonly isConnected: boolean;
  12695. /**
  12696. * Initializes the gamepad
  12697. * @param id The id of the gamepad
  12698. * @param index The index of the gamepad
  12699. * @param browserGamepad The browser gamepad
  12700. * @param leftStickX The x component of the left joystick
  12701. * @param leftStickY The y component of the left joystick
  12702. * @param rightStickX The x component of the right joystick
  12703. * @param rightStickY The y component of the right joystick
  12704. */
  12705. constructor(
  12706. /**
  12707. * The id of the gamepad
  12708. */
  12709. id: string,
  12710. /**
  12711. * The index of the gamepad
  12712. */
  12713. index: number,
  12714. /**
  12715. * The browser gamepad
  12716. */
  12717. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12718. /**
  12719. * Callback triggered when the left joystick has changed
  12720. * @param callback
  12721. */
  12722. onleftstickchanged(callback: (values: StickValues) => void): void;
  12723. /**
  12724. * Callback triggered when the right joystick has changed
  12725. * @param callback
  12726. */
  12727. onrightstickchanged(callback: (values: StickValues) => void): void;
  12728. /**
  12729. * Gets the left joystick
  12730. */
  12731. /**
  12732. * Sets the left joystick values
  12733. */
  12734. leftStick: StickValues;
  12735. /**
  12736. * Gets the right joystick
  12737. */
  12738. /**
  12739. * Sets the right joystick value
  12740. */
  12741. rightStick: StickValues;
  12742. /**
  12743. * Updates the gamepad joystick positions
  12744. */
  12745. update(): void;
  12746. /**
  12747. * Disposes the gamepad
  12748. */
  12749. dispose(): void;
  12750. }
  12751. /**
  12752. * Represents a generic gamepad
  12753. */
  12754. class GenericPad extends Gamepad {
  12755. private _buttons;
  12756. private _onbuttondown;
  12757. private _onbuttonup;
  12758. /**
  12759. * Observable triggered when a button has been pressed
  12760. */
  12761. onButtonDownObservable: Observable<number>;
  12762. /**
  12763. * Observable triggered when a button has been released
  12764. */
  12765. onButtonUpObservable: Observable<number>;
  12766. /**
  12767. * Callback triggered when a button has been pressed
  12768. * @param callback Called when a button has been pressed
  12769. */
  12770. onbuttondown(callback: (buttonPressed: number) => void): void;
  12771. /**
  12772. * Callback triggered when a button has been released
  12773. * @param callback Called when a button has been released
  12774. */
  12775. onbuttonup(callback: (buttonReleased: number) => void): void;
  12776. /**
  12777. * Initializes the generic gamepad
  12778. * @param id The id of the generic gamepad
  12779. * @param index The index of the generic gamepad
  12780. * @param browserGamepad The browser gamepad
  12781. */
  12782. constructor(id: string, index: number, browserGamepad: any);
  12783. private _setButtonValue;
  12784. /**
  12785. * Updates the generic gamepad
  12786. */
  12787. update(): void;
  12788. /**
  12789. * Disposes the generic gamepad
  12790. */
  12791. dispose(): void;
  12792. }
  12793. }
  12794. declare module BABYLON {
  12795. /**
  12796. * Manager for handling gamepads
  12797. */
  12798. class GamepadManager {
  12799. private _scene?;
  12800. private _babylonGamepads;
  12801. private _oneGamepadConnected;
  12802. /** @hidden */
  12803. _isMonitoring: boolean;
  12804. private _gamepadEventSupported;
  12805. private _gamepadSupport;
  12806. /**
  12807. * observable to be triggered when the gamepad controller has been connected
  12808. */
  12809. onGamepadConnectedObservable: Observable<Gamepad>;
  12810. /**
  12811. * observable to be triggered when the gamepad controller has been disconnected
  12812. */
  12813. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12814. private _onGamepadConnectedEvent;
  12815. private _onGamepadDisconnectedEvent;
  12816. /**
  12817. * Initializes the gamepad manager
  12818. * @param _scene BabylonJS scene
  12819. */
  12820. constructor(_scene?: Scene | undefined);
  12821. /**
  12822. * The gamepads in the game pad manager
  12823. */
  12824. readonly gamepads: Gamepad[];
  12825. /**
  12826. * Get the gamepad controllers based on type
  12827. * @param type The type of gamepad controller
  12828. * @returns Nullable gamepad
  12829. */
  12830. getGamepadByType(type?: number): Nullable<Gamepad>;
  12831. /**
  12832. * Disposes the gamepad manager
  12833. */
  12834. dispose(): void;
  12835. private _addNewGamepad;
  12836. private _startMonitoringGamepads;
  12837. private _stopMonitoringGamepads;
  12838. /** @hidden */
  12839. _checkGamepadsStatus(): void;
  12840. private _updateGamepadObjects;
  12841. }
  12842. }
  12843. declare module BABYLON {
  12844. interface Scene {
  12845. /** @hidden */
  12846. _gamepadManager: Nullable<GamepadManager>;
  12847. /**
  12848. * Gets the gamepad manager associated with the scene
  12849. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12850. */
  12851. gamepadManager: GamepadManager;
  12852. }
  12853. /**
  12854. * Interface representing a free camera inputs manager
  12855. */
  12856. interface FreeCameraInputsManager {
  12857. /**
  12858. * Adds gamepad input support to the FreeCameraInputsManager.
  12859. * @returns the FreeCameraInputsManager
  12860. */
  12861. addGamepad(): FreeCameraInputsManager;
  12862. }
  12863. /**
  12864. * Interface representing an arc rotate camera inputs manager
  12865. */
  12866. interface ArcRotateCameraInputsManager {
  12867. /**
  12868. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12869. * @returns the camera inputs manager
  12870. */
  12871. addGamepad(): ArcRotateCameraInputsManager;
  12872. }
  12873. /**
  12874. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12875. */
  12876. class GamepadSystemSceneComponent implements ISceneComponent {
  12877. /**
  12878. * The component name helpfull to identify the component in the list of scene components.
  12879. */
  12880. readonly name: string;
  12881. /**
  12882. * The scene the component belongs to.
  12883. */
  12884. scene: Scene;
  12885. /**
  12886. * Creates a new instance of the component for the given scene
  12887. * @param scene Defines the scene to register the component in
  12888. */
  12889. constructor(scene: Scene);
  12890. /**
  12891. * Registers the component in a given scene
  12892. */
  12893. register(): void;
  12894. /**
  12895. * Rebuilds the elements related to this component in case of
  12896. * context lost for instance.
  12897. */
  12898. rebuild(): void;
  12899. /**
  12900. * Disposes the component and the associated ressources
  12901. */
  12902. dispose(): void;
  12903. private _beforeCameraUpdate;
  12904. }
  12905. }
  12906. declare module BABYLON {
  12907. /**
  12908. * Defines supported buttons for XBox360 compatible gamepads
  12909. */
  12910. enum Xbox360Button {
  12911. /** A */
  12912. A = 0,
  12913. /** B */
  12914. B = 1,
  12915. /** X */
  12916. X = 2,
  12917. /** Y */
  12918. Y = 3,
  12919. /** Start */
  12920. Start = 4,
  12921. /** Back */
  12922. Back = 5,
  12923. /** Left button */
  12924. LB = 6,
  12925. /** Right button */
  12926. RB = 7,
  12927. /** Left stick */
  12928. LeftStick = 8,
  12929. /** Right stick */
  12930. RightStick = 9
  12931. }
  12932. /** Defines values for XBox360 DPad */
  12933. enum Xbox360Dpad {
  12934. /** Up */
  12935. Up = 0,
  12936. /** Down */
  12937. Down = 1,
  12938. /** Left */
  12939. Left = 2,
  12940. /** Right */
  12941. Right = 3
  12942. }
  12943. /**
  12944. * Defines a XBox360 gamepad
  12945. */
  12946. class Xbox360Pad extends Gamepad {
  12947. private _leftTrigger;
  12948. private _rightTrigger;
  12949. private _onlefttriggerchanged;
  12950. private _onrighttriggerchanged;
  12951. private _onbuttondown;
  12952. private _onbuttonup;
  12953. private _ondpaddown;
  12954. private _ondpadup;
  12955. /** Observable raised when a button is pressed */
  12956. onButtonDownObservable: Observable<Xbox360Button>;
  12957. /** Observable raised when a button is released */
  12958. onButtonUpObservable: Observable<Xbox360Button>;
  12959. /** Observable raised when a pad is pressed */
  12960. onPadDownObservable: Observable<Xbox360Dpad>;
  12961. /** Observable raised when a pad is released */
  12962. onPadUpObservable: Observable<Xbox360Dpad>;
  12963. private _buttonA;
  12964. private _buttonB;
  12965. private _buttonX;
  12966. private _buttonY;
  12967. private _buttonBack;
  12968. private _buttonStart;
  12969. private _buttonLB;
  12970. private _buttonRB;
  12971. private _buttonLeftStick;
  12972. private _buttonRightStick;
  12973. private _dPadUp;
  12974. private _dPadDown;
  12975. private _dPadLeft;
  12976. private _dPadRight;
  12977. private _isXboxOnePad;
  12978. /**
  12979. * Creates a new XBox360 gamepad object
  12980. * @param id defines the id of this gamepad
  12981. * @param index defines its index
  12982. * @param gamepad defines the internal HTML gamepad object
  12983. * @param xboxOne defines if it is a XBox One gamepad
  12984. */
  12985. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12986. /**
  12987. * Defines the callback to call when left trigger is pressed
  12988. * @param callback defines the callback to use
  12989. */
  12990. onlefttriggerchanged(callback: (value: number) => void): void;
  12991. /**
  12992. * Defines the callback to call when right trigger is pressed
  12993. * @param callback defines the callback to use
  12994. */
  12995. onrighttriggerchanged(callback: (value: number) => void): void;
  12996. /**
  12997. * Gets the left trigger value
  12998. */
  12999. /**
  13000. * Sets the left trigger value
  13001. */
  13002. leftTrigger: number;
  13003. /**
  13004. * Gets the right trigger value
  13005. */
  13006. /**
  13007. * Sets the right trigger value
  13008. */
  13009. rightTrigger: number;
  13010. /**
  13011. * Defines the callback to call when a button is pressed
  13012. * @param callback defines the callback to use
  13013. */
  13014. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  13015. /**
  13016. * Defines the callback to call when a button is released
  13017. * @param callback defines the callback to use
  13018. */
  13019. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  13020. /**
  13021. * Defines the callback to call when a pad is pressed
  13022. * @param callback defines the callback to use
  13023. */
  13024. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  13025. /**
  13026. * Defines the callback to call when a pad is released
  13027. * @param callback defines the callback to use
  13028. */
  13029. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  13030. private _setButtonValue;
  13031. private _setDPadValue;
  13032. /**
  13033. * Gets the value of the `A` button
  13034. */
  13035. /**
  13036. * Sets the value of the `A` button
  13037. */
  13038. buttonA: number;
  13039. /**
  13040. * Gets the value of the `B` button
  13041. */
  13042. /**
  13043. * Sets the value of the `B` button
  13044. */
  13045. buttonB: number;
  13046. /**
  13047. * Gets the value of the `X` button
  13048. */
  13049. /**
  13050. * Sets the value of the `X` button
  13051. */
  13052. buttonX: number;
  13053. /**
  13054. * Gets the value of the `Y` button
  13055. */
  13056. /**
  13057. * Sets the value of the `Y` button
  13058. */
  13059. buttonY: number;
  13060. /**
  13061. * Gets the value of the `Start` button
  13062. */
  13063. /**
  13064. * Sets the value of the `Start` button
  13065. */
  13066. buttonStart: number;
  13067. /**
  13068. * Gets the value of the `Back` button
  13069. */
  13070. /**
  13071. * Sets the value of the `Back` button
  13072. */
  13073. buttonBack: number;
  13074. /**
  13075. * Gets the value of the `Left` button
  13076. */
  13077. /**
  13078. * Sets the value of the `Left` button
  13079. */
  13080. buttonLB: number;
  13081. /**
  13082. * Gets the value of the `Right` button
  13083. */
  13084. /**
  13085. * Sets the value of the `Right` button
  13086. */
  13087. buttonRB: number;
  13088. /**
  13089. * Gets the value of the Left joystick
  13090. */
  13091. /**
  13092. * Sets the value of the Left joystick
  13093. */
  13094. buttonLeftStick: number;
  13095. /**
  13096. * Gets the value of the Right joystick
  13097. */
  13098. /**
  13099. * Sets the value of the Right joystick
  13100. */
  13101. buttonRightStick: number;
  13102. /**
  13103. * Gets the value of D-pad up
  13104. */
  13105. /**
  13106. * Sets the value of D-pad up
  13107. */
  13108. dPadUp: number;
  13109. /**
  13110. * Gets the value of D-pad down
  13111. */
  13112. /**
  13113. * Sets the value of D-pad down
  13114. */
  13115. dPadDown: number;
  13116. /**
  13117. * Gets the value of D-pad left
  13118. */
  13119. /**
  13120. * Sets the value of D-pad left
  13121. */
  13122. dPadLeft: number;
  13123. /**
  13124. * Gets the value of D-pad right
  13125. */
  13126. /**
  13127. * Sets the value of D-pad right
  13128. */
  13129. dPadRight: number;
  13130. /**
  13131. * Force the gamepad to synchronize with device values
  13132. */
  13133. update(): void;
  13134. /**
  13135. * Disposes the gamepad
  13136. */
  13137. dispose(): void;
  13138. }
  13139. }
  13140. declare module BABYLON {
  13141. /**
  13142. * Single axis drag gizmo
  13143. */
  13144. class AxisDragGizmo extends Gizmo {
  13145. /**
  13146. * Drag behavior responsible for the gizmos dragging interactions
  13147. */
  13148. dragBehavior: PointerDragBehavior;
  13149. private _pointerObserver;
  13150. /**
  13151. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13152. */
  13153. snapDistance: number;
  13154. /**
  13155. * Event that fires each time the gizmo snaps to a new location.
  13156. * * snapDistance is the the change in distance
  13157. */
  13158. onSnapObservable: Observable<{
  13159. snapDistance: number;
  13160. }>;
  13161. /** @hidden */
  13162. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  13163. /** @hidden */
  13164. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  13165. /**
  13166. * Creates an AxisDragGizmo
  13167. * @param gizmoLayer The utility layer the gizmo will be added to
  13168. * @param dragAxis The axis which the gizmo will be able to drag on
  13169. * @param color The color of the gizmo
  13170. */
  13171. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13172. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13173. /**
  13174. * Disposes of the gizmo
  13175. */
  13176. dispose(): void;
  13177. }
  13178. }
  13179. declare module BABYLON {
  13180. /**
  13181. * Single axis scale gizmo
  13182. */
  13183. class AxisScaleGizmo extends Gizmo {
  13184. private _coloredMaterial;
  13185. /**
  13186. * Drag behavior responsible for the gizmos dragging interactions
  13187. */
  13188. dragBehavior: PointerDragBehavior;
  13189. private _pointerObserver;
  13190. /**
  13191. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13192. */
  13193. snapDistance: number;
  13194. /**
  13195. * Event that fires each time the gizmo snaps to a new location.
  13196. * * snapDistance is the the change in distance
  13197. */
  13198. onSnapObservable: Observable<{
  13199. snapDistance: number;
  13200. }>;
  13201. /**
  13202. * If the scaling operation should be done on all axis (default: false)
  13203. */
  13204. uniformScaling: boolean;
  13205. /**
  13206. * Creates an AxisScaleGizmo
  13207. * @param gizmoLayer The utility layer the gizmo will be added to
  13208. * @param dragAxis The axis which the gizmo will be able to scale on
  13209. * @param color The color of the gizmo
  13210. */
  13211. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13212. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13213. /**
  13214. * Disposes of the gizmo
  13215. */
  13216. dispose(): void;
  13217. /**
  13218. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13219. * @param mesh The mesh to replace the default mesh of the gizmo
  13220. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  13221. */
  13222. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  13223. }
  13224. }
  13225. declare module BABYLON {
  13226. /**
  13227. * Bounding box gizmo
  13228. */
  13229. class BoundingBoxGizmo extends Gizmo {
  13230. private _lineBoundingBox;
  13231. private _rotateSpheresParent;
  13232. private _scaleBoxesParent;
  13233. private _boundingDimensions;
  13234. private _renderObserver;
  13235. private _pointerObserver;
  13236. private _scaleDragSpeed;
  13237. private _tmpQuaternion;
  13238. private _tmpVector;
  13239. private _tmpRotationMatrix;
  13240. /**
  13241. * 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)
  13242. */
  13243. ignoreChildren: boolean;
  13244. /**
  13245. * 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)
  13246. */
  13247. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  13248. /**
  13249. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  13250. */
  13251. rotationSphereSize: number;
  13252. /**
  13253. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  13254. */
  13255. scaleBoxSize: number;
  13256. /**
  13257. * 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)
  13258. */
  13259. fixedDragMeshScreenSize: boolean;
  13260. /**
  13261. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  13262. */
  13263. fixedDragMeshScreenSizeDistanceFactor: number;
  13264. /**
  13265. * Fired when a rotation sphere or scale box is dragged
  13266. */
  13267. onDragStartObservable: Observable<{}>;
  13268. /**
  13269. * Fired when a scale box is dragged
  13270. */
  13271. onScaleBoxDragObservable: Observable<{}>;
  13272. /**
  13273. * Fired when a scale box drag is ended
  13274. */
  13275. onScaleBoxDragEndObservable: Observable<{}>;
  13276. /**
  13277. * Fired when a rotation sphere is dragged
  13278. */
  13279. onRotationSphereDragObservable: Observable<{}>;
  13280. /**
  13281. * Fired when a rotation sphere drag is ended
  13282. */
  13283. onRotationSphereDragEndObservable: Observable<{}>;
  13284. /**
  13285. * 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)
  13286. */
  13287. scalePivot: Nullable<Vector3>;
  13288. private _anchorMesh;
  13289. private _existingMeshScale;
  13290. private static _PivotCached;
  13291. private static _OldPivotPoint;
  13292. private static _PivotTranslation;
  13293. private static _PivotTmpVector;
  13294. /** @hidden */
  13295. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  13296. /** @hidden */
  13297. static _RestorePivotPoint(mesh: AbstractMesh): void;
  13298. /**
  13299. * Creates an BoundingBoxGizmo
  13300. * @param gizmoLayer The utility layer the gizmo will be added to
  13301. * @param color The color of the gizmo
  13302. */
  13303. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13304. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13305. private _selectNode;
  13306. /**
  13307. * Updates the bounding box information for the Gizmo
  13308. */
  13309. updateBoundingBox(): void;
  13310. private _updateRotationSpheres;
  13311. private _updateScaleBoxes;
  13312. /**
  13313. * Enables rotation on the specified axis and disables rotation on the others
  13314. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  13315. */
  13316. setEnabledRotationAxis(axis: string): void;
  13317. /**
  13318. * Disposes of the gizmo
  13319. */
  13320. dispose(): void;
  13321. /**
  13322. * 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)
  13323. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  13324. * @returns the bounding box mesh with the passed in mesh as a child
  13325. */
  13326. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  13327. /**
  13328. * CustomMeshes are not supported by this gizmo
  13329. * @param mesh The mesh to replace the default mesh of the gizmo
  13330. */
  13331. setCustomMesh(mesh: Mesh): void;
  13332. }
  13333. }
  13334. declare module BABYLON {
  13335. /**
  13336. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  13337. */
  13338. class Gizmo implements IDisposable {
  13339. /** The utility layer the gizmo will be added to */
  13340. gizmoLayer: UtilityLayerRenderer;
  13341. /**
  13342. * The root mesh of the gizmo
  13343. */
  13344. protected _rootMesh: Mesh;
  13345. private _attachedMesh;
  13346. /**
  13347. * Ratio for the scale of the gizmo (Default: 1)
  13348. */
  13349. scaleRatio: number;
  13350. private _tmpMatrix;
  13351. /**
  13352. * If a custom mesh has been set (Default: false)
  13353. */
  13354. protected _customMeshSet: boolean;
  13355. /**
  13356. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  13357. * * When set, interactions will be enabled
  13358. */
  13359. attachedMesh: Nullable<AbstractMesh>;
  13360. /**
  13361. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13362. * @param mesh The mesh to replace the default mesh of the gizmo
  13363. */
  13364. setCustomMesh(mesh: Mesh): void;
  13365. /**
  13366. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  13367. */
  13368. updateGizmoRotationToMatchAttachedMesh: boolean;
  13369. /**
  13370. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  13371. */
  13372. updateGizmoPositionToMatchAttachedMesh: boolean;
  13373. /**
  13374. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  13375. */
  13376. protected _updateScale: boolean;
  13377. protected _interactionsEnabled: boolean;
  13378. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13379. private _beforeRenderObserver;
  13380. /**
  13381. * Creates a gizmo
  13382. * @param gizmoLayer The utility layer the gizmo will be added to
  13383. */
  13384. constructor(
  13385. /** The utility layer the gizmo will be added to */
  13386. gizmoLayer?: UtilityLayerRenderer);
  13387. private _tempVector;
  13388. /**
  13389. * @hidden
  13390. * Updates the gizmo to match the attached mesh's position/rotation
  13391. */
  13392. protected _update(): void;
  13393. /**
  13394. * Disposes of the gizmo
  13395. */
  13396. dispose(): void;
  13397. }
  13398. }
  13399. declare module BABYLON {
  13400. /**
  13401. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  13402. */
  13403. class GizmoManager implements IDisposable {
  13404. private scene;
  13405. /**
  13406. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  13407. */
  13408. gizmos: {
  13409. positionGizmo: Nullable<PositionGizmo>;
  13410. rotationGizmo: Nullable<RotationGizmo>;
  13411. scaleGizmo: Nullable<ScaleGizmo>;
  13412. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  13413. };
  13414. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  13415. clearGizmoOnEmptyPointerEvent: boolean;
  13416. /** Fires an event when the manager is attached to a mesh */
  13417. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  13418. private _gizmosEnabled;
  13419. private _pointerObserver;
  13420. private _attachedMesh;
  13421. private _boundingBoxColor;
  13422. private _defaultUtilityLayer;
  13423. private _defaultKeepDepthUtilityLayer;
  13424. /**
  13425. * When bounding box gizmo is enabled, this can be used to track drag/end events
  13426. */
  13427. boundingBoxDragBehavior: SixDofDragBehavior;
  13428. /**
  13429. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  13430. */
  13431. attachableMeshes: Nullable<Array<AbstractMesh>>;
  13432. /**
  13433. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  13434. */
  13435. usePointerToAttachGizmos: boolean;
  13436. /**
  13437. * Instatiates a gizmo manager
  13438. * @param scene the scene to overlay the gizmos on top of
  13439. */
  13440. constructor(scene: Scene);
  13441. /**
  13442. * Attaches a set of gizmos to the specified mesh
  13443. * @param mesh The mesh the gizmo's should be attached to
  13444. */
  13445. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  13446. /**
  13447. * If the position gizmo is enabled
  13448. */
  13449. positionGizmoEnabled: boolean;
  13450. /**
  13451. * If the rotation gizmo is enabled
  13452. */
  13453. rotationGizmoEnabled: boolean;
  13454. /**
  13455. * If the scale gizmo is enabled
  13456. */
  13457. scaleGizmoEnabled: boolean;
  13458. /**
  13459. * If the boundingBox gizmo is enabled
  13460. */
  13461. boundingBoxGizmoEnabled: boolean;
  13462. /**
  13463. * Disposes of the gizmo manager
  13464. */
  13465. dispose(): void;
  13466. }
  13467. }
  13468. declare module BABYLON {
  13469. /**
  13470. * Single plane rotation gizmo
  13471. */
  13472. class PlaneRotationGizmo extends Gizmo {
  13473. /**
  13474. * Drag behavior responsible for the gizmos dragging interactions
  13475. */
  13476. dragBehavior: PointerDragBehavior;
  13477. private _pointerObserver;
  13478. /**
  13479. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  13480. */
  13481. snapDistance: number;
  13482. /**
  13483. * Event that fires each time the gizmo snaps to a new location.
  13484. * * snapDistance is the the change in distance
  13485. */
  13486. onSnapObservable: Observable<{
  13487. snapDistance: number;
  13488. }>;
  13489. /**
  13490. * Creates a PlaneRotationGizmo
  13491. * @param gizmoLayer The utility layer the gizmo will be added to
  13492. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  13493. * @param color The color of the gizmo
  13494. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13495. */
  13496. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13497. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13498. /**
  13499. * Disposes of the gizmo
  13500. */
  13501. dispose(): void;
  13502. }
  13503. }
  13504. declare module BABYLON {
  13505. /**
  13506. * Gizmo that enables dragging a mesh along 3 axis
  13507. */
  13508. class PositionGizmo extends Gizmo {
  13509. /**
  13510. * Internal gizmo used for interactions on the x axis
  13511. */
  13512. xGizmo: AxisDragGizmo;
  13513. /**
  13514. * Internal gizmo used for interactions on the y axis
  13515. */
  13516. yGizmo: AxisDragGizmo;
  13517. /**
  13518. * Internal gizmo used for interactions on the z axis
  13519. */
  13520. zGizmo: AxisDragGizmo;
  13521. /** Fires an event when any of it's sub gizmos are dragged */
  13522. onDragStartObservable: Observable<{}>;
  13523. /** Fires an event when any of it's sub gizmos are released from dragging */
  13524. onDragEndObservable: Observable<{}>;
  13525. attachedMesh: Nullable<AbstractMesh>;
  13526. /**
  13527. * Creates a PositionGizmo
  13528. * @param gizmoLayer The utility layer the gizmo will be added to
  13529. */
  13530. constructor(gizmoLayer?: UtilityLayerRenderer);
  13531. updateGizmoRotationToMatchAttachedMesh: boolean;
  13532. /**
  13533. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13534. */
  13535. snapDistance: number;
  13536. /**
  13537. * Ratio for the scale of the gizmo (Default: 1)
  13538. */
  13539. scaleRatio: number;
  13540. /**
  13541. * Disposes of the gizmo
  13542. */
  13543. dispose(): void;
  13544. /**
  13545. * CustomMeshes are not supported by this gizmo
  13546. * @param mesh The mesh to replace the default mesh of the gizmo
  13547. */
  13548. setCustomMesh(mesh: Mesh): void;
  13549. }
  13550. }
  13551. declare module BABYLON {
  13552. /**
  13553. * Gizmo that enables rotating a mesh along 3 axis
  13554. */
  13555. class RotationGizmo extends Gizmo {
  13556. /**
  13557. * Internal gizmo used for interactions on the x axis
  13558. */
  13559. xGizmo: PlaneRotationGizmo;
  13560. /**
  13561. * Internal gizmo used for interactions on the y axis
  13562. */
  13563. yGizmo: PlaneRotationGizmo;
  13564. /**
  13565. * Internal gizmo used for interactions on the z axis
  13566. */
  13567. zGizmo: PlaneRotationGizmo;
  13568. /** Fires an event when any of it's sub gizmos are dragged */
  13569. onDragStartObservable: Observable<{}>;
  13570. /** Fires an event when any of it's sub gizmos are released from dragging */
  13571. onDragEndObservable: Observable<{}>;
  13572. attachedMesh: Nullable<AbstractMesh>;
  13573. /**
  13574. * Creates a RotationGizmo
  13575. * @param gizmoLayer The utility layer the gizmo will be added to
  13576. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13577. */
  13578. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13579. updateGizmoRotationToMatchAttachedMesh: boolean;
  13580. /**
  13581. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13582. */
  13583. snapDistance: number;
  13584. /**
  13585. * Ratio for the scale of the gizmo (Default: 1)
  13586. */
  13587. scaleRatio: number;
  13588. /**
  13589. * Disposes of the gizmo
  13590. */
  13591. dispose(): void;
  13592. /**
  13593. * CustomMeshes are not supported by this gizmo
  13594. * @param mesh The mesh to replace the default mesh of the gizmo
  13595. */
  13596. setCustomMesh(mesh: Mesh): void;
  13597. }
  13598. }
  13599. declare module BABYLON {
  13600. /**
  13601. * Gizmo that enables scaling a mesh along 3 axis
  13602. */
  13603. class ScaleGizmo extends Gizmo {
  13604. /**
  13605. * Internal gizmo used for interactions on the x axis
  13606. */
  13607. xGizmo: AxisScaleGizmo;
  13608. /**
  13609. * Internal gizmo used for interactions on the y axis
  13610. */
  13611. yGizmo: AxisScaleGizmo;
  13612. /**
  13613. * Internal gizmo used for interactions on the z axis
  13614. */
  13615. zGizmo: AxisScaleGizmo;
  13616. /**
  13617. * Internal gizmo used to scale all axis equally
  13618. */
  13619. uniformScaleGizmo: AxisScaleGizmo;
  13620. /** Fires an event when any of it's sub gizmos are dragged */
  13621. onDragStartObservable: Observable<{}>;
  13622. /** Fires an event when any of it's sub gizmos are released from dragging */
  13623. onDragEndObservable: Observable<{}>;
  13624. attachedMesh: Nullable<AbstractMesh>;
  13625. /**
  13626. * Creates a ScaleGizmo
  13627. * @param gizmoLayer The utility layer the gizmo will be added to
  13628. */
  13629. constructor(gizmoLayer?: UtilityLayerRenderer);
  13630. updateGizmoRotationToMatchAttachedMesh: boolean;
  13631. /**
  13632. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13633. */
  13634. snapDistance: number;
  13635. /**
  13636. * Ratio for the scale of the gizmo (Default: 1)
  13637. */
  13638. scaleRatio: number;
  13639. /**
  13640. * Disposes of the gizmo
  13641. */
  13642. dispose(): void;
  13643. }
  13644. }
  13645. declare module BABYLON {
  13646. /**
  13647. * Represents the different options available during the creation of
  13648. * a Environment helper.
  13649. *
  13650. * This can control the default ground, skybox and image processing setup of your scene.
  13651. */
  13652. interface IEnvironmentHelperOptions {
  13653. /**
  13654. * Specifies wether or not to create a ground.
  13655. * True by default.
  13656. */
  13657. createGround: boolean;
  13658. /**
  13659. * Specifies the ground size.
  13660. * 15 by default.
  13661. */
  13662. groundSize: number;
  13663. /**
  13664. * The texture used on the ground for the main color.
  13665. * Comes from the BabylonJS CDN by default.
  13666. *
  13667. * Remarks: Can be either a texture or a url.
  13668. */
  13669. groundTexture: string | BaseTexture;
  13670. /**
  13671. * The color mixed in the ground texture by default.
  13672. * BabylonJS clearColor by default.
  13673. */
  13674. groundColor: Color3;
  13675. /**
  13676. * Specifies the ground opacity.
  13677. * 1 by default.
  13678. */
  13679. groundOpacity: number;
  13680. /**
  13681. * Enables the ground to receive shadows.
  13682. * True by default.
  13683. */
  13684. enableGroundShadow: boolean;
  13685. /**
  13686. * Helps preventing the shadow to be fully black on the ground.
  13687. * 0.5 by default.
  13688. */
  13689. groundShadowLevel: number;
  13690. /**
  13691. * Creates a mirror texture attach to the ground.
  13692. * false by default.
  13693. */
  13694. enableGroundMirror: boolean;
  13695. /**
  13696. * Specifies the ground mirror size ratio.
  13697. * 0.3 by default as the default kernel is 64.
  13698. */
  13699. groundMirrorSizeRatio: number;
  13700. /**
  13701. * Specifies the ground mirror blur kernel size.
  13702. * 64 by default.
  13703. */
  13704. groundMirrorBlurKernel: number;
  13705. /**
  13706. * Specifies the ground mirror visibility amount.
  13707. * 1 by default
  13708. */
  13709. groundMirrorAmount: number;
  13710. /**
  13711. * Specifies the ground mirror reflectance weight.
  13712. * This uses the standard weight of the background material to setup the fresnel effect
  13713. * of the mirror.
  13714. * 1 by default.
  13715. */
  13716. groundMirrorFresnelWeight: number;
  13717. /**
  13718. * Specifies the ground mirror Falloff distance.
  13719. * This can helps reducing the size of the reflection.
  13720. * 0 by Default.
  13721. */
  13722. groundMirrorFallOffDistance: number;
  13723. /**
  13724. * Specifies the ground mirror texture type.
  13725. * Unsigned Int by Default.
  13726. */
  13727. groundMirrorTextureType: number;
  13728. /**
  13729. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  13730. * the shown objects.
  13731. */
  13732. groundYBias: number;
  13733. /**
  13734. * Specifies wether or not to create a skybox.
  13735. * True by default.
  13736. */
  13737. createSkybox: boolean;
  13738. /**
  13739. * Specifies the skybox size.
  13740. * 20 by default.
  13741. */
  13742. skyboxSize: number;
  13743. /**
  13744. * The texture used on the skybox for the main color.
  13745. * Comes from the BabylonJS CDN by default.
  13746. *
  13747. * Remarks: Can be either a texture or a url.
  13748. */
  13749. skyboxTexture: string | BaseTexture;
  13750. /**
  13751. * The color mixed in the skybox texture by default.
  13752. * BabylonJS clearColor by default.
  13753. */
  13754. skyboxColor: Color3;
  13755. /**
  13756. * The background rotation around the Y axis of the scene.
  13757. * This helps aligning the key lights of your scene with the background.
  13758. * 0 by default.
  13759. */
  13760. backgroundYRotation: number;
  13761. /**
  13762. * Compute automatically the size of the elements to best fit with the scene.
  13763. */
  13764. sizeAuto: boolean;
  13765. /**
  13766. * Default position of the rootMesh if autoSize is not true.
  13767. */
  13768. rootPosition: Vector3;
  13769. /**
  13770. * Sets up the image processing in the scene.
  13771. * true by default.
  13772. */
  13773. setupImageProcessing: boolean;
  13774. /**
  13775. * The texture used as your environment texture in the scene.
  13776. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13777. *
  13778. * Remarks: Can be either a texture or a url.
  13779. */
  13780. environmentTexture: string | BaseTexture;
  13781. /**
  13782. * The value of the exposure to apply to the scene.
  13783. * 0.6 by default if setupImageProcessing is true.
  13784. */
  13785. cameraExposure: number;
  13786. /**
  13787. * The value of the contrast to apply to the scene.
  13788. * 1.6 by default if setupImageProcessing is true.
  13789. */
  13790. cameraContrast: number;
  13791. /**
  13792. * Specifies wether or not tonemapping should be enabled in the scene.
  13793. * true by default if setupImageProcessing is true.
  13794. */
  13795. toneMappingEnabled: boolean;
  13796. }
  13797. /**
  13798. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13799. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13800. * It also helps with the default setup of your imageProcessing configuration.
  13801. */
  13802. class EnvironmentHelper {
  13803. /**
  13804. * Default ground texture URL.
  13805. */
  13806. private static _groundTextureCDNUrl;
  13807. /**
  13808. * Default skybox texture URL.
  13809. */
  13810. private static _skyboxTextureCDNUrl;
  13811. /**
  13812. * Default environment texture URL.
  13813. */
  13814. private static _environmentTextureCDNUrl;
  13815. /**
  13816. * Creates the default options for the helper.
  13817. */
  13818. private static _getDefaultOptions;
  13819. private _rootMesh;
  13820. /**
  13821. * Gets the root mesh created by the helper.
  13822. */
  13823. readonly rootMesh: Mesh;
  13824. private _skybox;
  13825. /**
  13826. * Gets the skybox created by the helper.
  13827. */
  13828. readonly skybox: Nullable<Mesh>;
  13829. private _skyboxTexture;
  13830. /**
  13831. * Gets the skybox texture created by the helper.
  13832. */
  13833. readonly skyboxTexture: Nullable<BaseTexture>;
  13834. private _skyboxMaterial;
  13835. /**
  13836. * Gets the skybox material created by the helper.
  13837. */
  13838. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13839. private _ground;
  13840. /**
  13841. * Gets the ground mesh created by the helper.
  13842. */
  13843. readonly ground: Nullable<Mesh>;
  13844. private _groundTexture;
  13845. /**
  13846. * Gets the ground texture created by the helper.
  13847. */
  13848. readonly groundTexture: Nullable<BaseTexture>;
  13849. private _groundMirror;
  13850. /**
  13851. * Gets the ground mirror created by the helper.
  13852. */
  13853. readonly groundMirror: Nullable<MirrorTexture>;
  13854. /**
  13855. * Gets the ground mirror render list to helps pushing the meshes
  13856. * you wish in the ground reflection.
  13857. */
  13858. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13859. private _groundMaterial;
  13860. /**
  13861. * Gets the ground material created by the helper.
  13862. */
  13863. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13864. /**
  13865. * Stores the creation options.
  13866. */
  13867. private readonly _scene;
  13868. private _options;
  13869. /**
  13870. * This observable will be notified with any error during the creation of the environment,
  13871. * mainly texture creation errors.
  13872. */
  13873. onErrorObservable: Observable<{
  13874. message?: string;
  13875. exception?: any;
  13876. }>;
  13877. /**
  13878. * constructor
  13879. * @param options
  13880. * @param scene The scene to add the material to
  13881. */
  13882. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13883. /**
  13884. * Updates the background according to the new options
  13885. * @param options
  13886. */
  13887. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13888. /**
  13889. * Sets the primary color of all the available elements.
  13890. * @param color the main color to affect to the ground and the background
  13891. */
  13892. setMainColor(color: Color3): void;
  13893. /**
  13894. * Setup the image processing according to the specified options.
  13895. */
  13896. private _setupImageProcessing;
  13897. /**
  13898. * Setup the environment texture according to the specified options.
  13899. */
  13900. private _setupEnvironmentTexture;
  13901. /**
  13902. * Setup the background according to the specified options.
  13903. */
  13904. private _setupBackground;
  13905. /**
  13906. * Get the scene sizes according to the setup.
  13907. */
  13908. private _getSceneSize;
  13909. /**
  13910. * Setup the ground according to the specified options.
  13911. */
  13912. private _setupGround;
  13913. /**
  13914. * Setup the ground material according to the specified options.
  13915. */
  13916. private _setupGroundMaterial;
  13917. /**
  13918. * Setup the ground diffuse texture according to the specified options.
  13919. */
  13920. private _setupGroundDiffuseTexture;
  13921. /**
  13922. * Setup the ground mirror texture according to the specified options.
  13923. */
  13924. private _setupGroundMirrorTexture;
  13925. /**
  13926. * Setup the ground to receive the mirror texture.
  13927. */
  13928. private _setupMirrorInGroundMaterial;
  13929. /**
  13930. * Setup the skybox according to the specified options.
  13931. */
  13932. private _setupSkybox;
  13933. /**
  13934. * Setup the skybox material according to the specified options.
  13935. */
  13936. private _setupSkyboxMaterial;
  13937. /**
  13938. * Setup the skybox reflection texture according to the specified options.
  13939. */
  13940. private _setupSkyboxReflectionTexture;
  13941. private _errorHandler;
  13942. /**
  13943. * Dispose all the elements created by the Helper.
  13944. */
  13945. dispose(): void;
  13946. }
  13947. }
  13948. declare module BABYLON {
  13949. /**
  13950. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13951. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13952. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13953. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13954. */
  13955. class PhotoDome extends TransformNode {
  13956. private _useDirectMapping;
  13957. /**
  13958. * The texture being displayed on the sphere
  13959. */
  13960. protected _photoTexture: Texture;
  13961. /**
  13962. * Gets or sets the texture being displayed on the sphere
  13963. */
  13964. photoTexture: Texture;
  13965. /**
  13966. * Observable raised when an error occured while loading the 360 image
  13967. */
  13968. onLoadErrorObservable: Observable<string>;
  13969. /**
  13970. * The skybox material
  13971. */
  13972. protected _material: BackgroundMaterial;
  13973. /**
  13974. * The surface used for the skybox
  13975. */
  13976. protected _mesh: Mesh;
  13977. /**
  13978. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13979. * Also see the options.resolution property.
  13980. */
  13981. fovMultiplier: number;
  13982. /**
  13983. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  13984. * @param name Element's name, child elements will append suffixes for their own names.
  13985. * @param urlsOfPhoto defines the url of the photo to display
  13986. * @param options defines an object containing optional or exposed sub element properties
  13987. * @param onError defines a callback called when an error occured while loading the texture
  13988. */
  13989. constructor(name: string, urlOfPhoto: string, options: {
  13990. resolution?: number;
  13991. size?: number;
  13992. useDirectMapping?: boolean;
  13993. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  13994. /**
  13995. * Releases resources associated with this node.
  13996. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13997. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13998. */
  13999. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14000. }
  14001. }
  14002. declare module BABYLON {
  14003. interface Scene {
  14004. /**
  14005. * Creates a default light for the scene.
  14006. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  14007. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  14008. */
  14009. createDefaultLight(replace?: boolean): void;
  14010. /**
  14011. * Creates a default camera for the scene.
  14012. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  14013. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  14014. * @param replace has default false, when true replaces the active camera in the scene
  14015. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  14016. */
  14017. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  14018. /**
  14019. * Creates a default camera and a default light.
  14020. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  14021. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  14022. * @param replace has the default false, when true replaces the active camera/light in the scene
  14023. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  14024. */
  14025. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  14026. /**
  14027. * Creates a new sky box
  14028. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  14029. * @param environmentTexture defines the texture to use as environment texture
  14030. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  14031. * @param scale defines the overall scale of the skybox
  14032. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  14033. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  14034. * @returns a new mesh holding the sky box
  14035. */
  14036. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  14037. /**
  14038. * Creates a new environment
  14039. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  14040. * @param options defines the options you can use to configure the environment
  14041. * @returns the new EnvironmentHelper
  14042. */
  14043. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  14044. /**
  14045. * Creates a new VREXperienceHelper
  14046. * @see http://doc.babylonjs.com/how_to/webvr_helper
  14047. * @param webVROptions defines the options used to create the new VREXperienceHelper
  14048. * @returns a new VREXperienceHelper
  14049. */
  14050. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  14051. /**
  14052. * Creates a new XREXperienceHelper
  14053. * @see http://doc.babylonjs.com/how_to/webxr
  14054. * @returns a promise for a new XREXperienceHelper
  14055. */
  14056. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  14057. }
  14058. }
  14059. declare module BABYLON {
  14060. /**
  14061. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  14062. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  14063. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  14064. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  14065. */
  14066. class VideoDome extends TransformNode {
  14067. private _useDirectMapping;
  14068. /**
  14069. * The video texture being displayed on the sphere
  14070. */
  14071. protected _videoTexture: VideoTexture;
  14072. /**
  14073. * Gets the video texture being displayed on the sphere
  14074. */
  14075. readonly videoTexture: VideoTexture;
  14076. /**
  14077. * The skybox material
  14078. */
  14079. protected _material: BackgroundMaterial;
  14080. /**
  14081. * The surface used for the skybox
  14082. */
  14083. protected _mesh: Mesh;
  14084. /**
  14085. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  14086. * Also see the options.resolution property.
  14087. */
  14088. fovMultiplier: number;
  14089. /**
  14090. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  14091. * @param name Element's name, child elements will append suffixes for their own names.
  14092. * @param urlsOrVideo defines the url(s) or the video element to use
  14093. * @param options An object containing optional or exposed sub element properties
  14094. */
  14095. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  14096. resolution?: number;
  14097. clickToPlay?: boolean;
  14098. autoPlay?: boolean;
  14099. loop?: boolean;
  14100. size?: number;
  14101. poster?: string;
  14102. useDirectMapping?: boolean;
  14103. }, scene: Scene);
  14104. /**
  14105. * Releases resources associated with this node.
  14106. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14107. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14108. */
  14109. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14110. }
  14111. }
  14112. declare module BABYLON {
  14113. /**
  14114. * This class can be used to get instrumentation data from a Babylon engine
  14115. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14116. */
  14117. class EngineInstrumentation implements IDisposable {
  14118. /**
  14119. * Define the instrumented engine.
  14120. */
  14121. engine: Engine;
  14122. private _captureGPUFrameTime;
  14123. private _gpuFrameTimeToken;
  14124. private _gpuFrameTime;
  14125. private _captureShaderCompilationTime;
  14126. private _shaderCompilationTime;
  14127. private _onBeginFrameObserver;
  14128. private _onEndFrameObserver;
  14129. private _onBeforeShaderCompilationObserver;
  14130. private _onAfterShaderCompilationObserver;
  14131. /**
  14132. * Gets the perf counter used for GPU frame time
  14133. */
  14134. readonly gpuFrameTimeCounter: PerfCounter;
  14135. /**
  14136. * Gets the GPU frame time capture status
  14137. */
  14138. /**
  14139. * Enable or disable the GPU frame time capture
  14140. */
  14141. captureGPUFrameTime: boolean;
  14142. /**
  14143. * Gets the perf counter used for shader compilation time
  14144. */
  14145. readonly shaderCompilationTimeCounter: PerfCounter;
  14146. /**
  14147. * Gets the shader compilation time capture status
  14148. */
  14149. /**
  14150. * Enable or disable the shader compilation time capture
  14151. */
  14152. captureShaderCompilationTime: boolean;
  14153. /**
  14154. * Instantiates a new engine instrumentation.
  14155. * This class can be used to get instrumentation data from a Babylon engine
  14156. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14157. * @param engine Defines the engine to instrument
  14158. */
  14159. constructor(
  14160. /**
  14161. * Define the instrumented engine.
  14162. */
  14163. engine: Engine);
  14164. /**
  14165. * Dispose and release associated resources.
  14166. */
  14167. dispose(): void;
  14168. }
  14169. }
  14170. declare module BABYLON {
  14171. /**
  14172. * This class can be used to get instrumentation data from a Babylon engine
  14173. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14174. */
  14175. class SceneInstrumentation implements IDisposable {
  14176. /**
  14177. * Defines the scene to instrument
  14178. */
  14179. scene: Scene;
  14180. private _captureActiveMeshesEvaluationTime;
  14181. private _activeMeshesEvaluationTime;
  14182. private _captureRenderTargetsRenderTime;
  14183. private _renderTargetsRenderTime;
  14184. private _captureFrameTime;
  14185. private _frameTime;
  14186. private _captureRenderTime;
  14187. private _renderTime;
  14188. private _captureInterFrameTime;
  14189. private _interFrameTime;
  14190. private _captureParticlesRenderTime;
  14191. private _particlesRenderTime;
  14192. private _captureSpritesRenderTime;
  14193. private _spritesRenderTime;
  14194. private _capturePhysicsTime;
  14195. private _physicsTime;
  14196. private _captureAnimationsTime;
  14197. private _animationsTime;
  14198. private _captureCameraRenderTime;
  14199. private _cameraRenderTime;
  14200. private _onBeforeActiveMeshesEvaluationObserver;
  14201. private _onAfterActiveMeshesEvaluationObserver;
  14202. private _onBeforeRenderTargetsRenderObserver;
  14203. private _onAfterRenderTargetsRenderObserver;
  14204. private _onAfterRenderObserver;
  14205. private _onBeforeDrawPhaseObserver;
  14206. private _onAfterDrawPhaseObserver;
  14207. private _onBeforeAnimationsObserver;
  14208. private _onBeforeParticlesRenderingObserver;
  14209. private _onAfterParticlesRenderingObserver;
  14210. private _onBeforeSpritesRenderingObserver;
  14211. private _onAfterSpritesRenderingObserver;
  14212. private _onBeforePhysicsObserver;
  14213. private _onAfterPhysicsObserver;
  14214. private _onAfterAnimationsObserver;
  14215. private _onBeforeCameraRenderObserver;
  14216. private _onAfterCameraRenderObserver;
  14217. /**
  14218. * Gets the perf counter used for active meshes evaluation time
  14219. */
  14220. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  14221. /**
  14222. * Gets the active meshes evaluation time capture status
  14223. */
  14224. /**
  14225. * Enable or disable the active meshes evaluation time capture
  14226. */
  14227. captureActiveMeshesEvaluationTime: boolean;
  14228. /**
  14229. * Gets the perf counter used for render targets render time
  14230. */
  14231. readonly renderTargetsRenderTimeCounter: PerfCounter;
  14232. /**
  14233. * Gets the render targets render time capture status
  14234. */
  14235. /**
  14236. * Enable or disable the render targets render time capture
  14237. */
  14238. captureRenderTargetsRenderTime: boolean;
  14239. /**
  14240. * Gets the perf counter used for particles render time
  14241. */
  14242. readonly particlesRenderTimeCounter: PerfCounter;
  14243. /**
  14244. * Gets the particles render time capture status
  14245. */
  14246. /**
  14247. * Enable or disable the particles render time capture
  14248. */
  14249. captureParticlesRenderTime: boolean;
  14250. /**
  14251. * Gets the perf counter used for sprites render time
  14252. */
  14253. readonly spritesRenderTimeCounter: PerfCounter;
  14254. /**
  14255. * Gets the sprites render time capture status
  14256. */
  14257. /**
  14258. * Enable or disable the sprites render time capture
  14259. */
  14260. captureSpritesRenderTime: boolean;
  14261. /**
  14262. * Gets the perf counter used for physics time
  14263. */
  14264. readonly physicsTimeCounter: PerfCounter;
  14265. /**
  14266. * Gets the physics time capture status
  14267. */
  14268. /**
  14269. * Enable or disable the physics time capture
  14270. */
  14271. capturePhysicsTime: boolean;
  14272. /**
  14273. * Gets the perf counter used for animations time
  14274. */
  14275. readonly animationsTimeCounter: PerfCounter;
  14276. /**
  14277. * Gets the animations time capture status
  14278. */
  14279. /**
  14280. * Enable or disable the animations time capture
  14281. */
  14282. captureAnimationsTime: boolean;
  14283. /**
  14284. * Gets the perf counter used for frame time capture
  14285. */
  14286. readonly frameTimeCounter: PerfCounter;
  14287. /**
  14288. * Gets the frame time capture status
  14289. */
  14290. /**
  14291. * Enable or disable the frame time capture
  14292. */
  14293. captureFrameTime: boolean;
  14294. /**
  14295. * Gets the perf counter used for inter-frames time capture
  14296. */
  14297. readonly interFrameTimeCounter: PerfCounter;
  14298. /**
  14299. * Gets the inter-frames time capture status
  14300. */
  14301. /**
  14302. * Enable or disable the inter-frames time capture
  14303. */
  14304. captureInterFrameTime: boolean;
  14305. /**
  14306. * Gets the perf counter used for render time capture
  14307. */
  14308. readonly renderTimeCounter: PerfCounter;
  14309. /**
  14310. * Gets the render time capture status
  14311. */
  14312. /**
  14313. * Enable or disable the render time capture
  14314. */
  14315. captureRenderTime: boolean;
  14316. /**
  14317. * Gets the perf counter used for camera render time capture
  14318. */
  14319. readonly cameraRenderTimeCounter: PerfCounter;
  14320. /**
  14321. * Gets the camera render time capture status
  14322. */
  14323. /**
  14324. * Enable or disable the camera render time capture
  14325. */
  14326. captureCameraRenderTime: boolean;
  14327. /**
  14328. * Gets the perf counter used for draw calls
  14329. */
  14330. readonly drawCallsCounter: PerfCounter;
  14331. /**
  14332. * Gets the perf counter used for texture collisions
  14333. */
  14334. readonly textureCollisionsCounter: PerfCounter;
  14335. /**
  14336. * Instantiates a new scene instrumentation.
  14337. * This class can be used to get instrumentation data from a Babylon engine
  14338. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14339. * @param scene Defines the scene to instrument
  14340. */
  14341. constructor(
  14342. /**
  14343. * Defines the scene to instrument
  14344. */
  14345. scene: Scene);
  14346. /**
  14347. * Dispose and release associated resources.
  14348. */
  14349. dispose(): void;
  14350. }
  14351. }
  14352. declare module BABYLON {
  14353. /**
  14354. * @hidden
  14355. **/
  14356. class _TimeToken {
  14357. _startTimeQuery: Nullable<WebGLQuery>;
  14358. _endTimeQuery: Nullable<WebGLQuery>;
  14359. _timeElapsedQuery: Nullable<WebGLQuery>;
  14360. _timeElapsedQueryEnded: boolean;
  14361. }
  14362. }
  14363. declare module BABYLON {
  14364. /**
  14365. * Effect layer options. This helps customizing the behaviour
  14366. * of the effect layer.
  14367. */
  14368. interface IEffectLayerOptions {
  14369. /**
  14370. * Multiplication factor apply to the canvas size to compute the render target size
  14371. * used to generated the objects (the smaller the faster).
  14372. */
  14373. mainTextureRatio: number;
  14374. /**
  14375. * Enforces a fixed size texture to ensure effect stability across devices.
  14376. */
  14377. mainTextureFixedSize?: number;
  14378. /**
  14379. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  14380. */
  14381. alphaBlendingMode: number;
  14382. /**
  14383. * The camera attached to the layer.
  14384. */
  14385. camera: Nullable<Camera>;
  14386. /**
  14387. * The rendering group to draw the layer in.
  14388. */
  14389. renderingGroupId: number;
  14390. }
  14391. /**
  14392. * The effect layer Helps adding post process effect blended with the main pass.
  14393. *
  14394. * This can be for instance use to generate glow or higlight effects on the scene.
  14395. *
  14396. * The effect layer class can not be used directly and is intented to inherited from to be
  14397. * customized per effects.
  14398. */
  14399. abstract class EffectLayer {
  14400. private _vertexBuffers;
  14401. private _indexBuffer;
  14402. private _cachedDefines;
  14403. private _effectLayerMapGenerationEffect;
  14404. private _effectLayerOptions;
  14405. private _mergeEffect;
  14406. protected _scene: Scene;
  14407. protected _engine: Engine;
  14408. protected _maxSize: number;
  14409. protected _mainTextureDesiredSize: ISize;
  14410. protected _mainTexture: RenderTargetTexture;
  14411. protected _shouldRender: boolean;
  14412. protected _postProcesses: PostProcess[];
  14413. protected _textures: BaseTexture[];
  14414. protected _emissiveTextureAndColor: {
  14415. texture: Nullable<BaseTexture>;
  14416. color: Color4;
  14417. };
  14418. /**
  14419. * The name of the layer
  14420. */
  14421. name: string;
  14422. /**
  14423. * The clear color of the texture used to generate the glow map.
  14424. */
  14425. neutralColor: Color4;
  14426. /**
  14427. * Specifies wether the highlight layer is enabled or not.
  14428. */
  14429. isEnabled: boolean;
  14430. /**
  14431. * Gets the camera attached to the layer.
  14432. */
  14433. readonly camera: Nullable<Camera>;
  14434. /**
  14435. * Gets the rendering group id the layer should render in.
  14436. */
  14437. readonly renderingGroupId: number;
  14438. /**
  14439. * An event triggered when the effect layer has been disposed.
  14440. */
  14441. onDisposeObservable: Observable<EffectLayer>;
  14442. /**
  14443. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  14444. */
  14445. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  14446. /**
  14447. * An event triggered when the generated texture is being merged in the scene.
  14448. */
  14449. onBeforeComposeObservable: Observable<EffectLayer>;
  14450. /**
  14451. * An event triggered when the generated texture has been merged in the scene.
  14452. */
  14453. onAfterComposeObservable: Observable<EffectLayer>;
  14454. /**
  14455. * An event triggered when the efffect layer changes its size.
  14456. */
  14457. onSizeChangedObservable: Observable<EffectLayer>;
  14458. /**
  14459. * Instantiates a new effect Layer and references it in the scene.
  14460. * @param name The name of the layer
  14461. * @param scene The scene to use the layer in
  14462. */
  14463. constructor(
  14464. /** The Friendly of the effect in the scene */
  14465. name: string, scene: Scene);
  14466. /**
  14467. * Get the effect name of the layer.
  14468. * @return The effect name
  14469. */
  14470. abstract getEffectName(): string;
  14471. /**
  14472. * Checks for the readiness of the element composing the layer.
  14473. * @param subMesh the mesh to check for
  14474. * @param useInstances specify wether or not to use instances to render the mesh
  14475. * @return true if ready otherwise, false
  14476. */
  14477. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14478. /**
  14479. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14480. * @returns true if the effect requires stencil during the main canvas render pass.
  14481. */
  14482. abstract needStencil(): boolean;
  14483. /**
  14484. * Create the merge effect. This is the shader use to blit the information back
  14485. * to the main canvas at the end of the scene rendering.
  14486. * @returns The effect containing the shader used to merge the effect on the main canvas
  14487. */
  14488. protected abstract _createMergeEffect(): Effect;
  14489. /**
  14490. * Creates the render target textures and post processes used in the effect layer.
  14491. */
  14492. protected abstract _createTextureAndPostProcesses(): void;
  14493. /**
  14494. * Implementation specific of rendering the generating effect on the main canvas.
  14495. * @param effect The effect used to render through
  14496. */
  14497. protected abstract _internalRender(effect: Effect): void;
  14498. /**
  14499. * Sets the required values for both the emissive texture and and the main color.
  14500. */
  14501. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14502. /**
  14503. * Free any resources and references associated to a mesh.
  14504. * Internal use
  14505. * @param mesh The mesh to free.
  14506. */
  14507. abstract _disposeMesh(mesh: Mesh): void;
  14508. /**
  14509. * Serializes this layer (Glow or Highlight for example)
  14510. * @returns a serialized layer object
  14511. */
  14512. abstract serialize?(): any;
  14513. /**
  14514. * Initializes the effect layer with the required options.
  14515. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  14516. */
  14517. protected _init(options: Partial<IEffectLayerOptions>): void;
  14518. /**
  14519. * Generates the index buffer of the full screen quad blending to the main canvas.
  14520. */
  14521. private _generateIndexBuffer;
  14522. /**
  14523. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  14524. */
  14525. private _genrateVertexBuffer;
  14526. /**
  14527. * Sets the main texture desired size which is the closest power of two
  14528. * of the engine canvas size.
  14529. */
  14530. private _setMainTextureSize;
  14531. /**
  14532. * Creates the main texture for the effect layer.
  14533. */
  14534. protected _createMainTexture(): void;
  14535. /**
  14536. * Checks for the readiness of the element composing the layer.
  14537. * @param subMesh the mesh to check for
  14538. * @param useInstances specify wether or not to use instances to render the mesh
  14539. * @param emissiveTexture the associated emissive texture used to generate the glow
  14540. * @return true if ready otherwise, false
  14541. */
  14542. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  14543. /**
  14544. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  14545. */
  14546. render(): void;
  14547. /**
  14548. * Determine if a given mesh will be used in the current effect.
  14549. * @param mesh mesh to test
  14550. * @returns true if the mesh will be used
  14551. */
  14552. hasMesh(mesh: AbstractMesh): boolean;
  14553. /**
  14554. * Returns true if the layer contains information to display, otherwise false.
  14555. * @returns true if the glow layer should be rendered
  14556. */
  14557. shouldRender(): boolean;
  14558. /**
  14559. * Returns true if the mesh should render, otherwise false.
  14560. * @param mesh The mesh to render
  14561. * @returns true if it should render otherwise false
  14562. */
  14563. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14564. /**
  14565. * Returns true if the mesh should render, otherwise false.
  14566. * @param mesh The mesh to render
  14567. * @returns true if it should render otherwise false
  14568. */
  14569. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  14570. /**
  14571. * Renders the submesh passed in parameter to the generation map.
  14572. */
  14573. protected _renderSubMesh(subMesh: SubMesh): void;
  14574. /**
  14575. * Rebuild the required buffers.
  14576. * @hidden Internal use only.
  14577. */
  14578. _rebuild(): void;
  14579. /**
  14580. * Dispose only the render target textures and post process.
  14581. */
  14582. private _disposeTextureAndPostProcesses;
  14583. /**
  14584. * Dispose the highlight layer and free resources.
  14585. */
  14586. dispose(): void;
  14587. /**
  14588. * Gets the class name of the effect layer
  14589. * @returns the string with the class name of the effect layer
  14590. */
  14591. getClassName(): string;
  14592. /**
  14593. * Creates an effect layer from parsed effect layer data
  14594. * @param parsedEffectLayer defines effect layer data
  14595. * @param scene defines the current scene
  14596. * @param rootUrl defines the root URL containing the effect layer information
  14597. * @returns a parsed effect Layer
  14598. */
  14599. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  14600. }
  14601. }
  14602. declare module BABYLON {
  14603. interface AbstractScene {
  14604. /**
  14605. * The list of effect layers (highlights/glow) added to the scene
  14606. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14607. * @see http://doc.babylonjs.com/how_to/glow_layer
  14608. */
  14609. effectLayers: Array<EffectLayer>;
  14610. /**
  14611. * Removes the given effect layer from this scene.
  14612. * @param toRemove defines the effect layer to remove
  14613. * @returns the index of the removed effect layer
  14614. */
  14615. removeEffectLayer(toRemove: EffectLayer): number;
  14616. /**
  14617. * Adds the given effect layer to this scene
  14618. * @param newEffectLayer defines the effect layer to add
  14619. */
  14620. addEffectLayer(newEffectLayer: EffectLayer): void;
  14621. }
  14622. /**
  14623. * Defines the layer scene component responsible to manage any effect layers
  14624. * in a given scene.
  14625. */
  14626. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14627. /**
  14628. * The component name helpfull to identify the component in the list of scene components.
  14629. */
  14630. readonly name: string;
  14631. /**
  14632. * The scene the component belongs to.
  14633. */
  14634. scene: Scene;
  14635. private _engine;
  14636. private _renderEffects;
  14637. private _needStencil;
  14638. private _previousStencilState;
  14639. /**
  14640. * Creates a new instance of the component for the given scene
  14641. * @param scene Defines the scene to register the component in
  14642. */
  14643. constructor(scene: Scene);
  14644. /**
  14645. * Registers the component in a given scene
  14646. */
  14647. register(): void;
  14648. /**
  14649. * Rebuilds the elements related to this component in case of
  14650. * context lost for instance.
  14651. */
  14652. rebuild(): void;
  14653. /**
  14654. * Serializes the component data to the specified json object
  14655. * @param serializationObject The object to serialize to
  14656. */
  14657. serialize(serializationObject: any): void;
  14658. /**
  14659. * Adds all the element from the container to the scene
  14660. * @param container the container holding the elements
  14661. */
  14662. addFromContainer(container: AbstractScene): void;
  14663. /**
  14664. * Removes all the elements in the container from the scene
  14665. * @param container contains the elements to remove
  14666. */
  14667. removeFromContainer(container: AbstractScene): void;
  14668. /**
  14669. * Disposes the component and the associated ressources.
  14670. */
  14671. dispose(): void;
  14672. private _isReadyForMesh;
  14673. private _renderMainTexture;
  14674. private _setStencil;
  14675. private _setStencilBack;
  14676. private _draw;
  14677. private _drawCamera;
  14678. private _drawRenderingGroup;
  14679. }
  14680. }
  14681. declare module BABYLON {
  14682. interface AbstractScene {
  14683. /**
  14684. * Return a the first highlight layer of the scene with a given name.
  14685. * @param name The name of the highlight layer to look for.
  14686. * @return The highlight layer if found otherwise null.
  14687. */
  14688. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14689. }
  14690. /**
  14691. * Glow layer options. This helps customizing the behaviour
  14692. * of the glow layer.
  14693. */
  14694. interface IGlowLayerOptions {
  14695. /**
  14696. * Multiplication factor apply to the canvas size to compute the render target size
  14697. * used to generated the glowing objects (the smaller the faster).
  14698. */
  14699. mainTextureRatio: number;
  14700. /**
  14701. * Enforces a fixed size texture to ensure resize independant blur.
  14702. */
  14703. mainTextureFixedSize?: number;
  14704. /**
  14705. * How big is the kernel of the blur texture.
  14706. */
  14707. blurKernelSize: number;
  14708. /**
  14709. * The camera attached to the layer.
  14710. */
  14711. camera: Nullable<Camera>;
  14712. /**
  14713. * Enable MSAA by chosing the number of samples.
  14714. */
  14715. mainTextureSamples?: number;
  14716. /**
  14717. * The rendering group to draw the layer in.
  14718. */
  14719. renderingGroupId: number;
  14720. }
  14721. /**
  14722. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14723. *
  14724. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14725. * glowy meshes to your scene.
  14726. *
  14727. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14728. */
  14729. class GlowLayer extends EffectLayer {
  14730. /**
  14731. * Effect Name of the layer.
  14732. */
  14733. static readonly EffectName: string;
  14734. /**
  14735. * The default blur kernel size used for the glow.
  14736. */
  14737. static DefaultBlurKernelSize: number;
  14738. /**
  14739. * The default texture size ratio used for the glow.
  14740. */
  14741. static DefaultTextureRatio: number;
  14742. /**
  14743. * Sets the kernel size of the blur.
  14744. */
  14745. /**
  14746. * Gets the kernel size of the blur.
  14747. */
  14748. blurKernelSize: number;
  14749. /**
  14750. * Sets the glow intensity.
  14751. */
  14752. /**
  14753. * Gets the glow intensity.
  14754. */
  14755. intensity: number;
  14756. private _options;
  14757. private _intensity;
  14758. private _horizontalBlurPostprocess1;
  14759. private _verticalBlurPostprocess1;
  14760. private _horizontalBlurPostprocess2;
  14761. private _verticalBlurPostprocess2;
  14762. private _blurTexture1;
  14763. private _blurTexture2;
  14764. private _postProcesses1;
  14765. private _postProcesses2;
  14766. private _includedOnlyMeshes;
  14767. private _excludedMeshes;
  14768. /**
  14769. * Callback used to let the user override the color selection on a per mesh basis
  14770. */
  14771. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14772. /**
  14773. * Callback used to let the user override the texture selection on a per mesh basis
  14774. */
  14775. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14776. /**
  14777. * Instantiates a new glow Layer and references it to the scene.
  14778. * @param name The name of the layer
  14779. * @param scene The scene to use the layer in
  14780. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14781. */
  14782. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14783. /**
  14784. * Get the effect name of the layer.
  14785. * @return The effect name
  14786. */
  14787. getEffectName(): string;
  14788. /**
  14789. * Create the merge effect. This is the shader use to blit the information back
  14790. * to the main canvas at the end of the scene rendering.
  14791. */
  14792. protected _createMergeEffect(): Effect;
  14793. /**
  14794. * Creates the render target textures and post processes used in the glow layer.
  14795. */
  14796. protected _createTextureAndPostProcesses(): void;
  14797. /**
  14798. * Checks for the readiness of the element composing the layer.
  14799. * @param subMesh the mesh to check for
  14800. * @param useInstances specify wether or not to use instances to render the mesh
  14801. * @param emissiveTexture the associated emissive texture used to generate the glow
  14802. * @return true if ready otherwise, false
  14803. */
  14804. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14805. /**
  14806. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14807. */
  14808. needStencil(): boolean;
  14809. /**
  14810. * Implementation specific of rendering the generating effect on the main canvas.
  14811. * @param effect The effect used to render through
  14812. */
  14813. protected _internalRender(effect: Effect): void;
  14814. /**
  14815. * Sets the required values for both the emissive texture and and the main color.
  14816. */
  14817. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14818. /**
  14819. * Returns true if the mesh should render, otherwise false.
  14820. * @param mesh The mesh to render
  14821. * @returns true if it should render otherwise false
  14822. */
  14823. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14824. /**
  14825. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  14826. * @param mesh The mesh to exclude from the glow layer
  14827. */
  14828. addExcludedMesh(mesh: Mesh): void;
  14829. /**
  14830. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  14831. * @param mesh The mesh to remove
  14832. */
  14833. removeExcludedMesh(mesh: Mesh): void;
  14834. /**
  14835. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  14836. * @param mesh The mesh to include in the glow layer
  14837. */
  14838. addIncludedOnlyMesh(mesh: Mesh): void;
  14839. /**
  14840. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  14841. * @param mesh The mesh to remove
  14842. */
  14843. removeIncludedOnlyMesh(mesh: Mesh): void;
  14844. /**
  14845. * Determine if a given mesh will be used in the glow layer
  14846. * @param mesh The mesh to test
  14847. * @returns true if the mesh will be highlighted by the current glow layer
  14848. */
  14849. hasMesh(mesh: AbstractMesh): boolean;
  14850. /**
  14851. * Free any resources and references associated to a mesh.
  14852. * Internal use
  14853. * @param mesh The mesh to free.
  14854. * @hidden
  14855. */
  14856. _disposeMesh(mesh: Mesh): void;
  14857. /**
  14858. * Gets the class name of the effect layer
  14859. * @returns the string with the class name of the effect layer
  14860. */
  14861. getClassName(): string;
  14862. /**
  14863. * Serializes this glow layer
  14864. * @returns a serialized glow layer object
  14865. */
  14866. serialize(): any;
  14867. /**
  14868. * Creates a Glow Layer from parsed glow layer data
  14869. * @param parsedGlowLayer defines glow layer data
  14870. * @param scene defines the current scene
  14871. * @param rootUrl defines the root URL containing the glow layer information
  14872. * @returns a parsed Glow Layer
  14873. */
  14874. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  14875. }
  14876. }
  14877. declare module BABYLON {
  14878. interface AbstractScene {
  14879. /**
  14880. * Return a the first highlight layer of the scene with a given name.
  14881. * @param name The name of the highlight layer to look for.
  14882. * @return The highlight layer if found otherwise null.
  14883. */
  14884. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  14885. }
  14886. /**
  14887. * Highlight layer options. This helps customizing the behaviour
  14888. * of the highlight layer.
  14889. */
  14890. interface IHighlightLayerOptions {
  14891. /**
  14892. * Multiplication factor apply to the canvas size to compute the render target size
  14893. * used to generated the glowing objects (the smaller the faster).
  14894. */
  14895. mainTextureRatio: number;
  14896. /**
  14897. * Enforces a fixed size texture to ensure resize independant blur.
  14898. */
  14899. mainTextureFixedSize?: number;
  14900. /**
  14901. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14902. * of the picture to blur (the smaller the faster).
  14903. */
  14904. blurTextureSizeRatio: number;
  14905. /**
  14906. * How big in texel of the blur texture is the vertical blur.
  14907. */
  14908. blurVerticalSize: number;
  14909. /**
  14910. * How big in texel of the blur texture is the horizontal blur.
  14911. */
  14912. blurHorizontalSize: number;
  14913. /**
  14914. * Alpha blending mode used to apply the blur. Default is combine.
  14915. */
  14916. alphaBlendingMode: number;
  14917. /**
  14918. * The camera attached to the layer.
  14919. */
  14920. camera: Nullable<Camera>;
  14921. /**
  14922. * Should we display highlight as a solid stroke?
  14923. */
  14924. isStroke?: boolean;
  14925. /**
  14926. * The rendering group to draw the layer in.
  14927. */
  14928. renderingGroupId: number;
  14929. }
  14930. /**
  14931. * The highlight layer Helps adding a glow effect around a mesh.
  14932. *
  14933. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14934. * glowy meshes to your scene.
  14935. *
  14936. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14937. */
  14938. class HighlightLayer extends EffectLayer {
  14939. name: string;
  14940. /**
  14941. * Effect Name of the highlight layer.
  14942. */
  14943. static readonly EffectName: string;
  14944. /**
  14945. * The neutral color used during the preparation of the glow effect.
  14946. * This is black by default as the blend operation is a blend operation.
  14947. */
  14948. static NeutralColor: Color4;
  14949. /**
  14950. * Stencil value used for glowing meshes.
  14951. */
  14952. static GlowingMeshStencilReference: number;
  14953. /**
  14954. * Stencil value used for the other meshes in the scene.
  14955. */
  14956. static NormalMeshStencilReference: number;
  14957. /**
  14958. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14959. */
  14960. innerGlow: boolean;
  14961. /**
  14962. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14963. */
  14964. outerGlow: boolean;
  14965. /**
  14966. * Specifies the horizontal size of the blur.
  14967. */
  14968. /**
  14969. * Gets the horizontal size of the blur.
  14970. */
  14971. blurHorizontalSize: number;
  14972. /**
  14973. * Specifies the vertical size of the blur.
  14974. */
  14975. /**
  14976. * Gets the vertical size of the blur.
  14977. */
  14978. blurVerticalSize: number;
  14979. /**
  14980. * An event triggered when the highlight layer is being blurred.
  14981. */
  14982. onBeforeBlurObservable: Observable<HighlightLayer>;
  14983. /**
  14984. * An event triggered when the highlight layer has been blurred.
  14985. */
  14986. onAfterBlurObservable: Observable<HighlightLayer>;
  14987. private _instanceGlowingMeshStencilReference;
  14988. private _options;
  14989. private _downSamplePostprocess;
  14990. private _horizontalBlurPostprocess;
  14991. private _verticalBlurPostprocess;
  14992. private _blurTexture;
  14993. private _meshes;
  14994. private _excludedMeshes;
  14995. /**
  14996. * Instantiates a new highlight Layer and references it to the scene..
  14997. * @param name The name of the layer
  14998. * @param scene The scene to use the layer in
  14999. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  15000. */
  15001. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  15002. /**
  15003. * Get the effect name of the layer.
  15004. * @return The effect name
  15005. */
  15006. getEffectName(): string;
  15007. /**
  15008. * Create the merge effect. This is the shader use to blit the information back
  15009. * to the main canvas at the end of the scene rendering.
  15010. */
  15011. protected _createMergeEffect(): Effect;
  15012. /**
  15013. * Creates the render target textures and post processes used in the highlight layer.
  15014. */
  15015. protected _createTextureAndPostProcesses(): void;
  15016. /**
  15017. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  15018. */
  15019. needStencil(): boolean;
  15020. /**
  15021. * Checks for the readiness of the element composing the layer.
  15022. * @param subMesh the mesh to check for
  15023. * @param useInstances specify wether or not to use instances to render the mesh
  15024. * @param emissiveTexture the associated emissive texture used to generate the glow
  15025. * @return true if ready otherwise, false
  15026. */
  15027. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  15028. /**
  15029. * Implementation specific of rendering the generating effect on the main canvas.
  15030. * @param effect The effect used to render through
  15031. */
  15032. protected _internalRender(effect: Effect): void;
  15033. /**
  15034. * Returns true if the layer contains information to display, otherwise false.
  15035. */
  15036. shouldRender(): boolean;
  15037. /**
  15038. * Returns true if the mesh should render, otherwise false.
  15039. * @param mesh The mesh to render
  15040. * @returns true if it should render otherwise false
  15041. */
  15042. protected _shouldRenderMesh(mesh: Mesh): boolean;
  15043. /**
  15044. * Sets the required values for both the emissive texture and and the main color.
  15045. */
  15046. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  15047. /**
  15048. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  15049. * @param mesh The mesh to exclude from the highlight layer
  15050. */
  15051. addExcludedMesh(mesh: Mesh): void;
  15052. /**
  15053. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  15054. * @param mesh The mesh to highlight
  15055. */
  15056. removeExcludedMesh(mesh: Mesh): void;
  15057. /**
  15058. * Determine if a given mesh will be highlighted by the current HighlightLayer
  15059. * @param mesh mesh to test
  15060. * @returns true if the mesh will be highlighted by the current HighlightLayer
  15061. */
  15062. hasMesh(mesh: AbstractMesh): boolean;
  15063. /**
  15064. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  15065. * @param mesh The mesh to highlight
  15066. * @param color The color of the highlight
  15067. * @param glowEmissiveOnly Extract the glow from the emissive texture
  15068. */
  15069. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  15070. /**
  15071. * Remove a mesh from the highlight layer in order to make it stop glowing.
  15072. * @param mesh The mesh to highlight
  15073. */
  15074. removeMesh(mesh: Mesh): void;
  15075. /**
  15076. * Force the stencil to the normal expected value for none glowing parts
  15077. */
  15078. private _defaultStencilReference;
  15079. /**
  15080. * Free any resources and references associated to a mesh.
  15081. * Internal use
  15082. * @param mesh The mesh to free.
  15083. * @hidden
  15084. */
  15085. _disposeMesh(mesh: Mesh): void;
  15086. /**
  15087. * Dispose the highlight layer and free resources.
  15088. */
  15089. dispose(): void;
  15090. /**
  15091. * Gets the class name of the effect layer
  15092. * @returns the string with the class name of the effect layer
  15093. */
  15094. getClassName(): string;
  15095. /**
  15096. * Serializes this Highlight layer
  15097. * @returns a serialized Highlight layer object
  15098. */
  15099. serialize(): any;
  15100. /**
  15101. * Creates a Highlight layer from parsed Highlight layer data
  15102. * @param parsedHightlightLayer defines the Highlight layer data
  15103. * @param scene defines the current scene
  15104. * @param rootUrl defines the root URL containing the Highlight layer information
  15105. * @returns a parsed Highlight layer
  15106. */
  15107. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  15108. }
  15109. }
  15110. declare module BABYLON {
  15111. /**
  15112. * This represents a full screen 2d layer.
  15113. * This can be useful to display a picture in the background of your scene for instance.
  15114. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15115. */
  15116. class Layer {
  15117. /**
  15118. * Define the name of the layer.
  15119. */
  15120. name: string;
  15121. /**
  15122. * Define the texture the layer should display.
  15123. */
  15124. texture: Nullable<Texture>;
  15125. /**
  15126. * Is the layer in background or foreground.
  15127. */
  15128. isBackground: boolean;
  15129. /**
  15130. * Define the color of the layer (instead of texture).
  15131. */
  15132. color: Color4;
  15133. /**
  15134. * Define the scale of the layer in order to zoom in out of the texture.
  15135. */
  15136. scale: Vector2;
  15137. /**
  15138. * Define an offset for the layer in order to shift the texture.
  15139. */
  15140. offset: Vector2;
  15141. /**
  15142. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  15143. */
  15144. alphaBlendingMode: number;
  15145. /**
  15146. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  15147. * Alpha test will not mix with the background color in case of transparency.
  15148. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  15149. */
  15150. alphaTest: boolean;
  15151. /**
  15152. * Define a mask to restrict the layer to only some of the scene cameras.
  15153. */
  15154. layerMask: number;
  15155. /**
  15156. * Define the list of render target the layer is visible into.
  15157. */
  15158. renderTargetTextures: RenderTargetTexture[];
  15159. /**
  15160. * Define if the layer is only used in renderTarget or if it also
  15161. * renders in the main frame buffer of the canvas.
  15162. */
  15163. renderOnlyInRenderTargetTextures: boolean;
  15164. private _scene;
  15165. private _vertexBuffers;
  15166. private _indexBuffer;
  15167. private _effect;
  15168. private _alphaTestEffect;
  15169. /**
  15170. * An event triggered when the layer is disposed.
  15171. */
  15172. onDisposeObservable: Observable<Layer>;
  15173. private _onDisposeObserver;
  15174. /**
  15175. * Back compatibility with callback before the onDisposeObservable existed.
  15176. * The set callback will be triggered when the layer has been disposed.
  15177. */
  15178. onDispose: () => void;
  15179. /**
  15180. * An event triggered before rendering the scene
  15181. */
  15182. onBeforeRenderObservable: Observable<Layer>;
  15183. private _onBeforeRenderObserver;
  15184. /**
  15185. * Back compatibility with callback before the onBeforeRenderObservable existed.
  15186. * The set callback will be triggered just before rendering the layer.
  15187. */
  15188. onBeforeRender: () => void;
  15189. /**
  15190. * An event triggered after rendering the scene
  15191. */
  15192. onAfterRenderObservable: Observable<Layer>;
  15193. private _onAfterRenderObserver;
  15194. /**
  15195. * Back compatibility with callback before the onAfterRenderObservable existed.
  15196. * The set callback will be triggered just after rendering the layer.
  15197. */
  15198. onAfterRender: () => void;
  15199. /**
  15200. * Instantiates a new layer.
  15201. * This represents a full screen 2d layer.
  15202. * This can be useful to display a picture in the background of your scene for instance.
  15203. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15204. * @param name Define the name of the layer in the scene
  15205. * @param imgUrl Define the url of the texture to display in the layer
  15206. * @param scene Define the scene the layer belongs to
  15207. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  15208. * @param color Defines a color for the layer
  15209. */
  15210. constructor(
  15211. /**
  15212. * Define the name of the layer.
  15213. */
  15214. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  15215. private _createIndexBuffer;
  15216. /** @hidden */
  15217. _rebuild(): void;
  15218. /**
  15219. * Renders the layer in the scene.
  15220. */
  15221. render(): void;
  15222. /**
  15223. * Disposes and releases the associated ressources.
  15224. */
  15225. dispose(): void;
  15226. }
  15227. }
  15228. declare module BABYLON {
  15229. interface AbstractScene {
  15230. /**
  15231. * The list of layers (background and foreground) of the scene
  15232. */
  15233. layers: Array<Layer>;
  15234. }
  15235. /**
  15236. * Defines the layer scene component responsible to manage any layers
  15237. * in a given scene.
  15238. */
  15239. class LayerSceneComponent implements ISceneComponent {
  15240. /**
  15241. * The component name helpfull to identify the component in the list of scene components.
  15242. */
  15243. readonly name: string;
  15244. /**
  15245. * The scene the component belongs to.
  15246. */
  15247. scene: Scene;
  15248. private _engine;
  15249. /**
  15250. * Creates a new instance of the component for the given scene
  15251. * @param scene Defines the scene to register the component in
  15252. */
  15253. constructor(scene: Scene);
  15254. /**
  15255. * Registers the component in a given scene
  15256. */
  15257. register(): void;
  15258. /**
  15259. * Rebuilds the elements related to this component in case of
  15260. * context lost for instance.
  15261. */
  15262. rebuild(): void;
  15263. /**
  15264. * Disposes the component and the associated ressources.
  15265. */
  15266. dispose(): void;
  15267. private _draw;
  15268. private _drawCameraPredicate;
  15269. private _drawCameraBackground;
  15270. private _drawCameraForeground;
  15271. private _drawRenderTargetPredicate;
  15272. private _drawRenderTargetBackground;
  15273. private _drawRenderTargetForeground;
  15274. }
  15275. }
  15276. declare module BABYLON {
  15277. /**
  15278. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15279. * It controls one of the indiviual texture used in the effect.
  15280. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15281. */
  15282. class LensFlare {
  15283. /**
  15284. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15285. */
  15286. size: number;
  15287. /**
  15288. * 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.
  15289. */
  15290. position: number;
  15291. /**
  15292. * Define the lens color.
  15293. */
  15294. color: Color3;
  15295. /**
  15296. * Define the lens texture.
  15297. */
  15298. texture: Nullable<Texture>;
  15299. /**
  15300. * Define the alpha mode to render this particular lens.
  15301. */
  15302. alphaMode: number;
  15303. private _system;
  15304. /**
  15305. * Creates a new Lens Flare.
  15306. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15307. * It controls one of the indiviual texture used in the effect.
  15308. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15309. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  15310. * @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.
  15311. * @param color Define the lens color
  15312. * @param imgUrl Define the lens texture url
  15313. * @param system Define the `lensFlareSystem` this flare is part of
  15314. * @returns The newly created Lens Flare
  15315. */
  15316. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  15317. /**
  15318. * Instantiates a new Lens Flare.
  15319. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15320. * It controls one of the indiviual texture used in the effect.
  15321. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15322. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  15323. * @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.
  15324. * @param color Define the lens color
  15325. * @param imgUrl Define the lens texture url
  15326. * @param system Define the `lensFlareSystem` this flare is part of
  15327. */
  15328. constructor(
  15329. /**
  15330. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15331. */
  15332. size: number,
  15333. /**
  15334. * 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.
  15335. */
  15336. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  15337. /**
  15338. * Dispose and release the lens flare with its associated resources.
  15339. */
  15340. dispose(): void;
  15341. }
  15342. }
  15343. declare module BABYLON {
  15344. /**
  15345. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15346. * It is usually composed of several `BABYLON.lensFlare`.
  15347. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15348. */
  15349. class LensFlareSystem {
  15350. /**
  15351. * Define the name of the lens flare system
  15352. */
  15353. name: string;
  15354. /**
  15355. * List of lens flares used in this system.
  15356. */
  15357. lensFlares: LensFlare[];
  15358. /**
  15359. * Define a limit from the border the lens flare can be visible.
  15360. */
  15361. borderLimit: number;
  15362. /**
  15363. * Define a viewport border we do not want to see the lens flare in.
  15364. */
  15365. viewportBorder: number;
  15366. /**
  15367. * Define a predicate which could limit the list of meshes able to occlude the effect.
  15368. */
  15369. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  15370. /**
  15371. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  15372. */
  15373. layerMask: number;
  15374. /**
  15375. * Define the id of the lens flare system in the scene.
  15376. * (equal to name by default)
  15377. */
  15378. id: string;
  15379. private _scene;
  15380. private _emitter;
  15381. private _vertexBuffers;
  15382. private _indexBuffer;
  15383. private _effect;
  15384. private _positionX;
  15385. private _positionY;
  15386. private _isEnabled;
  15387. /**
  15388. * Instantiates a lens flare system.
  15389. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15390. * It is usually composed of several `BABYLON.lensFlare`.
  15391. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15392. * @param name Define the name of the lens flare system in the scene
  15393. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  15394. * @param scene Define the scene the lens flare system belongs to
  15395. */
  15396. constructor(
  15397. /**
  15398. * Define the name of the lens flare system
  15399. */
  15400. name: string, emitter: any, scene: Scene);
  15401. /**
  15402. * Define if the lens flare system is enabled.
  15403. */
  15404. isEnabled: boolean;
  15405. /**
  15406. * Get the scene the effects belongs to.
  15407. * @returns the scene holding the lens flare system
  15408. */
  15409. getScene(): Scene;
  15410. /**
  15411. * Get the emitter of the lens flare system.
  15412. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15413. * @returns the emitter of the lens flare system
  15414. */
  15415. getEmitter(): any;
  15416. /**
  15417. * Set the emitter of the lens flare system.
  15418. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15419. * @param newEmitter Define the new emitter of the system
  15420. */
  15421. setEmitter(newEmitter: any): void;
  15422. /**
  15423. * Get the lens flare system emitter position.
  15424. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  15425. * @returns the position
  15426. */
  15427. getEmitterPosition(): Vector3;
  15428. /**
  15429. * @hidden
  15430. */
  15431. computeEffectivePosition(globalViewport: Viewport): boolean;
  15432. /** @hidden */
  15433. _isVisible(): boolean;
  15434. /**
  15435. * @hidden
  15436. */
  15437. render(): boolean;
  15438. /**
  15439. * Dispose and release the lens flare with its associated resources.
  15440. */
  15441. dispose(): void;
  15442. /**
  15443. * Parse a lens flare system from a JSON repressentation
  15444. * @param parsedLensFlareSystem Define the JSON to parse
  15445. * @param scene Define the scene the parsed system should be instantiated in
  15446. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  15447. * @returns the parsed system
  15448. */
  15449. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  15450. /**
  15451. * Serialize the current Lens Flare System into a JSON representation.
  15452. * @returns the serialized JSON
  15453. */
  15454. serialize(): any;
  15455. }
  15456. }
  15457. declare module BABYLON {
  15458. interface AbstractScene {
  15459. /**
  15460. * The list of lens flare system added to the scene
  15461. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15462. */
  15463. lensFlareSystems: Array<LensFlareSystem>;
  15464. /**
  15465. * Removes the given lens flare system from this scene.
  15466. * @param toRemove The lens flare system to remove
  15467. * @returns The index of the removed lens flare system
  15468. */
  15469. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  15470. /**
  15471. * Adds the given lens flare system to this scene
  15472. * @param newLensFlareSystem The lens flare system to add
  15473. */
  15474. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  15475. /**
  15476. * Gets a lens flare system using its name
  15477. * @param name defines the name to look for
  15478. * @returns the lens flare system or null if not found
  15479. */
  15480. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  15481. /**
  15482. * Gets a lens flare system using its id
  15483. * @param id defines the id to look for
  15484. * @returns the lens flare system or null if not found
  15485. */
  15486. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  15487. }
  15488. /**
  15489. * Defines the lens flare scene component responsible to manage any lens flares
  15490. * in a given scene.
  15491. */
  15492. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  15493. /**
  15494. * The component name helpfull to identify the component in the list of scene components.
  15495. */
  15496. readonly name: string;
  15497. /**
  15498. * The scene the component belongs to.
  15499. */
  15500. scene: Scene;
  15501. /**
  15502. * Creates a new instance of the component for the given scene
  15503. * @param scene Defines the scene to register the component in
  15504. */
  15505. constructor(scene: Scene);
  15506. /**
  15507. * Registers the component in a given scene
  15508. */
  15509. register(): void;
  15510. /**
  15511. * Rebuilds the elements related to this component in case of
  15512. * context lost for instance.
  15513. */
  15514. rebuild(): void;
  15515. /**
  15516. * Adds all the element from the container to the scene
  15517. * @param container the container holding the elements
  15518. */
  15519. addFromContainer(container: AbstractScene): void;
  15520. /**
  15521. * Removes all the elements in the container from the scene
  15522. * @param container contains the elements to remove
  15523. */
  15524. removeFromContainer(container: AbstractScene): void;
  15525. /**
  15526. * Serializes the component data to the specified json object
  15527. * @param serializationObject The object to serialize to
  15528. */
  15529. serialize(serializationObject: any): void;
  15530. /**
  15531. * Disposes the component and the associated ressources.
  15532. */
  15533. dispose(): void;
  15534. private _draw;
  15535. }
  15536. }
  15537. declare module BABYLON {
  15538. /**
  15539. * A directional light is defined by a direction (what a surprise!).
  15540. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  15541. * 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.
  15542. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15543. */
  15544. class DirectionalLight extends ShadowLight {
  15545. private _shadowFrustumSize;
  15546. /**
  15547. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  15548. */
  15549. /**
  15550. * Specifies a fix frustum size for the shadow generation.
  15551. */
  15552. shadowFrustumSize: number;
  15553. private _shadowOrthoScale;
  15554. /**
  15555. * Gets the shadow projection scale against the optimal computed one.
  15556. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15557. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15558. */
  15559. /**
  15560. * Sets the shadow projection scale against the optimal computed one.
  15561. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15562. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15563. */
  15564. shadowOrthoScale: number;
  15565. /**
  15566. * Automatically compute the projection matrix to best fit (including all the casters)
  15567. * on each frame.
  15568. */
  15569. autoUpdateExtends: boolean;
  15570. private _orthoLeft;
  15571. private _orthoRight;
  15572. private _orthoTop;
  15573. private _orthoBottom;
  15574. /**
  15575. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  15576. * The directional light is emitted from everywhere in the given direction.
  15577. * It can cast shadows.
  15578. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15579. * @param name The friendly name of the light
  15580. * @param direction The direction of the light
  15581. * @param scene The scene the light belongs to
  15582. */
  15583. constructor(name: string, direction: Vector3, scene: Scene);
  15584. /**
  15585. * Returns the string "DirectionalLight".
  15586. * @return The class name
  15587. */
  15588. getClassName(): string;
  15589. /**
  15590. * Returns the integer 1.
  15591. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15592. */
  15593. getTypeID(): number;
  15594. /**
  15595. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  15596. * Returns the DirectionalLight Shadow projection matrix.
  15597. */
  15598. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15599. /**
  15600. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  15601. * Returns the DirectionalLight Shadow projection matrix.
  15602. */
  15603. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  15604. /**
  15605. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  15606. * Returns the DirectionalLight Shadow projection matrix.
  15607. */
  15608. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15609. protected _buildUniformLayout(): void;
  15610. /**
  15611. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  15612. * @param effect The effect to update
  15613. * @param lightIndex The index of the light in the effect to update
  15614. * @returns The directional light
  15615. */
  15616. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  15617. /**
  15618. * Gets the minZ used for shadow according to both the scene and the light.
  15619. *
  15620. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15621. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15622. * @param activeCamera The camera we are returning the min for
  15623. * @returns the depth min z
  15624. */
  15625. getDepthMinZ(activeCamera: Camera): number;
  15626. /**
  15627. * Gets the maxZ used for shadow according to both the scene and the light.
  15628. *
  15629. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15630. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15631. * @param activeCamera The camera we are returning the max for
  15632. * @returns the depth max z
  15633. */
  15634. getDepthMaxZ(activeCamera: Camera): number;
  15635. /**
  15636. * Prepares the list of defines specific to the light type.
  15637. * @param defines the list of defines
  15638. * @param lightIndex defines the index of the light for the effect
  15639. */
  15640. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15641. }
  15642. }
  15643. declare module BABYLON {
  15644. /**
  15645. * The HemisphericLight simulates the ambient environment light,
  15646. * so the passed direction is the light reflection direction, not the incoming direction.
  15647. */
  15648. class HemisphericLight extends Light {
  15649. /**
  15650. * The groundColor is the light in the opposite direction to the one specified during creation.
  15651. * 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.
  15652. */
  15653. groundColor: Color3;
  15654. /**
  15655. * The light reflection direction, not the incoming direction.
  15656. */
  15657. direction: Vector3;
  15658. /**
  15659. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15660. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15661. * The HemisphericLight can't cast shadows.
  15662. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15663. * @param name The friendly name of the light
  15664. * @param direction The direction of the light reflection
  15665. * @param scene The scene the light belongs to
  15666. */
  15667. constructor(name: string, direction: Vector3, scene: Scene);
  15668. protected _buildUniformLayout(): void;
  15669. /**
  15670. * Returns the string "HemisphericLight".
  15671. * @return The class name
  15672. */
  15673. getClassName(): string;
  15674. /**
  15675. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15676. * Returns the updated direction.
  15677. * @param target The target the direction should point to
  15678. * @return The computed direction
  15679. */
  15680. setDirectionToTarget(target: Vector3): Vector3;
  15681. /**
  15682. * Returns the shadow generator associated to the light.
  15683. * @returns Always null for hemispheric lights because it does not support shadows.
  15684. */
  15685. getShadowGenerator(): Nullable<IShadowGenerator>;
  15686. /**
  15687. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15688. * @param effect The effect to update
  15689. * @param lightIndex The index of the light in the effect to update
  15690. * @returns The hemispheric light
  15691. */
  15692. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15693. /**
  15694. * Computes the world matrix of the node
  15695. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15696. * @param useWasUpdatedFlag defines a reserved property
  15697. * @returns the world matrix
  15698. */
  15699. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  15700. /**
  15701. * Returns the integer 3.
  15702. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15703. */
  15704. getTypeID(): number;
  15705. /**
  15706. * Prepares the list of defines specific to the light type.
  15707. * @param defines the list of defines
  15708. * @param lightIndex defines the index of the light for the effect
  15709. */
  15710. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15711. }
  15712. }
  15713. declare module BABYLON {
  15714. /**
  15715. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  15716. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  15717. * 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.
  15718. */
  15719. abstract class Light extends Node {
  15720. /**
  15721. * Falloff Default: light is falling off following the material specification:
  15722. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  15723. */
  15724. static readonly FALLOFF_DEFAULT: number;
  15725. /**
  15726. * Falloff Physical: light is falling off following the inverse squared distance law.
  15727. */
  15728. static readonly FALLOFF_PHYSICAL: number;
  15729. /**
  15730. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  15731. * to enhance interoperability with other engines.
  15732. */
  15733. static readonly FALLOFF_GLTF: number;
  15734. /**
  15735. * Falloff Standard: light is falling off like in the standard material
  15736. * to enhance interoperability with other materials.
  15737. */
  15738. static readonly FALLOFF_STANDARD: number;
  15739. /**
  15740. * If every light affecting the material is in this lightmapMode,
  15741. * material.lightmapTexture adds or multiplies
  15742. * (depends on material.useLightmapAsShadowmap)
  15743. * after every other light calculations.
  15744. */
  15745. static readonly LIGHTMAP_DEFAULT: number;
  15746. /**
  15747. * material.lightmapTexture as only diffuse lighting from this light
  15748. * adds only specular lighting from this light
  15749. * adds dynamic shadows
  15750. */
  15751. static readonly LIGHTMAP_SPECULAR: number;
  15752. /**
  15753. * material.lightmapTexture as only lighting
  15754. * no light calculation from this light
  15755. * only adds dynamic shadows from this light
  15756. */
  15757. static readonly LIGHTMAP_SHADOWSONLY: number;
  15758. /**
  15759. * Each light type uses the default quantity according to its type:
  15760. * point/spot lights use luminous intensity
  15761. * directional lights use illuminance
  15762. */
  15763. static readonly INTENSITYMODE_AUTOMATIC: number;
  15764. /**
  15765. * lumen (lm)
  15766. */
  15767. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  15768. /**
  15769. * candela (lm/sr)
  15770. */
  15771. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  15772. /**
  15773. * lux (lm/m^2)
  15774. */
  15775. static readonly INTENSITYMODE_ILLUMINANCE: number;
  15776. /**
  15777. * nit (cd/m^2)
  15778. */
  15779. static readonly INTENSITYMODE_LUMINANCE: number;
  15780. /**
  15781. * Light type const id of the point light.
  15782. */
  15783. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15784. /**
  15785. * Light type const id of the directional light.
  15786. */
  15787. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15788. /**
  15789. * Light type const id of the spot light.
  15790. */
  15791. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15792. /**
  15793. * Light type const id of the hemispheric light.
  15794. */
  15795. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15796. /**
  15797. * Diffuse gives the basic color to an object.
  15798. */
  15799. diffuse: Color3;
  15800. /**
  15801. * Specular produces a highlight color on an object.
  15802. * Note: This is note affecting PBR materials.
  15803. */
  15804. specular: Color3;
  15805. /**
  15806. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15807. * falling off base on range or angle.
  15808. * This can be set to any values in Light.FALLOFF_x.
  15809. *
  15810. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  15811. * other types of materials.
  15812. */
  15813. falloffType: number;
  15814. /**
  15815. * Strength of the light.
  15816. * Note: By default it is define in the framework own unit.
  15817. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15818. */
  15819. intensity: number;
  15820. private _range;
  15821. protected _inverseSquaredRange: number;
  15822. /**
  15823. * Defines how far from the source the light is impacting in scene units.
  15824. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15825. */
  15826. /**
  15827. * Defines how far from the source the light is impacting in scene units.
  15828. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15829. */
  15830. range: number;
  15831. /**
  15832. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15833. * of light.
  15834. */
  15835. private _photometricScale;
  15836. private _intensityMode;
  15837. /**
  15838. * Gets the photometric scale used to interpret the intensity.
  15839. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15840. */
  15841. /**
  15842. * Sets the photometric scale used to interpret the intensity.
  15843. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15844. */
  15845. intensityMode: number;
  15846. private _radius;
  15847. /**
  15848. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15849. */
  15850. /**
  15851. * sets the light radius used by PBR Materials to simulate soft area lights.
  15852. */
  15853. radius: number;
  15854. private _renderPriority;
  15855. /**
  15856. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15857. * exceeding the number allowed of the materials.
  15858. */
  15859. renderPriority: number;
  15860. private _shadowEnabled;
  15861. /**
  15862. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15863. * the current shadow generator.
  15864. */
  15865. /**
  15866. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15867. * the current shadow generator.
  15868. */
  15869. shadowEnabled: boolean;
  15870. private _includedOnlyMeshes;
  15871. /**
  15872. * Gets the only meshes impacted by this light.
  15873. */
  15874. /**
  15875. * Sets the only meshes impacted by this light.
  15876. */
  15877. includedOnlyMeshes: AbstractMesh[];
  15878. private _excludedMeshes;
  15879. /**
  15880. * Gets the meshes not impacted by this light.
  15881. */
  15882. /**
  15883. * Sets the meshes not impacted by this light.
  15884. */
  15885. excludedMeshes: AbstractMesh[];
  15886. private _excludeWithLayerMask;
  15887. /**
  15888. * Gets the layer id use to find what meshes are not impacted by the light.
  15889. * Inactive if 0
  15890. */
  15891. /**
  15892. * Sets the layer id use to find what meshes are not impacted by the light.
  15893. * Inactive if 0
  15894. */
  15895. excludeWithLayerMask: number;
  15896. private _includeOnlyWithLayerMask;
  15897. /**
  15898. * Gets the layer id use to find what meshes are impacted by the light.
  15899. * Inactive if 0
  15900. */
  15901. /**
  15902. * Sets the layer id use to find what meshes are impacted by the light.
  15903. * Inactive if 0
  15904. */
  15905. includeOnlyWithLayerMask: number;
  15906. private _lightmapMode;
  15907. /**
  15908. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15909. */
  15910. /**
  15911. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15912. */
  15913. lightmapMode: number;
  15914. /**
  15915. * Shadow generator associted to the light.
  15916. * @hidden Internal use only.
  15917. */
  15918. _shadowGenerator: Nullable<IShadowGenerator>;
  15919. /**
  15920. * @hidden Internal use only.
  15921. */
  15922. _excludedMeshesIds: string[];
  15923. /**
  15924. * @hidden Internal use only.
  15925. */
  15926. _includedOnlyMeshesIds: string[];
  15927. /**
  15928. * The current light unifom buffer.
  15929. * @hidden Internal use only.
  15930. */
  15931. _uniformBuffer: UniformBuffer;
  15932. /**
  15933. * Creates a Light object in the scene.
  15934. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15935. * @param name The firendly name of the light
  15936. * @param scene The scene the light belongs too
  15937. */
  15938. constructor(name: string, scene: Scene);
  15939. protected abstract _buildUniformLayout(): void;
  15940. /**
  15941. * Sets the passed Effect "effect" with the Light information.
  15942. * @param effect The effect to update
  15943. * @param lightIndex The index of the light in the effect to update
  15944. * @returns The light
  15945. */
  15946. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15947. /**
  15948. * Returns the string "Light".
  15949. * @returns the class name
  15950. */
  15951. getClassName(): string;
  15952. /**
  15953. * Converts the light information to a readable string for debug purpose.
  15954. * @param fullDetails Supports for multiple levels of logging within scene loading
  15955. * @returns the human readable light info
  15956. */
  15957. toString(fullDetails?: boolean): string;
  15958. /** @hidden */
  15959. protected _syncParentEnabledState(): void;
  15960. /**
  15961. * Set the enabled state of this node.
  15962. * @param value - the new enabled state
  15963. */
  15964. setEnabled(value: boolean): void;
  15965. /**
  15966. * Returns the Light associated shadow generator if any.
  15967. * @return the associated shadow generator.
  15968. */
  15969. getShadowGenerator(): Nullable<IShadowGenerator>;
  15970. /**
  15971. * Returns a Vector3, the absolute light position in the World.
  15972. * @returns the world space position of the light
  15973. */
  15974. getAbsolutePosition(): Vector3;
  15975. /**
  15976. * Specifies if the light will affect the passed mesh.
  15977. * @param mesh The mesh to test against the light
  15978. * @return true the mesh is affected otherwise, false.
  15979. */
  15980. canAffectMesh(mesh: AbstractMesh): boolean;
  15981. /**
  15982. * Sort function to order lights for rendering.
  15983. * @param a First Light object to compare to second.
  15984. * @param b Second Light object to compare first.
  15985. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  15986. */
  15987. static CompareLightsPriority(a: Light, b: Light): number;
  15988. /**
  15989. * Releases resources associated with this node.
  15990. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15991. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15992. */
  15993. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15994. /**
  15995. * Returns the light type ID (integer).
  15996. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15997. */
  15998. getTypeID(): number;
  15999. /**
  16000. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  16001. * @returns the scaled intensity in intensity mode unit
  16002. */
  16003. getScaledIntensity(): number;
  16004. /**
  16005. * Returns a new Light object, named "name", from the current one.
  16006. * @param name The name of the cloned light
  16007. * @returns the new created light
  16008. */
  16009. clone(name: string): Nullable<Light>;
  16010. /**
  16011. * Serializes the current light into a Serialization object.
  16012. * @returns the serialized object.
  16013. */
  16014. serialize(): any;
  16015. /**
  16016. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  16017. * This new light is named "name" and added to the passed scene.
  16018. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  16019. * @param name The friendly name of the light
  16020. * @param scene The scene the new light will belong to
  16021. * @returns the constructor function
  16022. */
  16023. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  16024. /**
  16025. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  16026. * @param parsedLight The JSON representation of the light
  16027. * @param scene The scene to create the parsed light in
  16028. * @returns the created light after parsing
  16029. */
  16030. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  16031. private _hookArrayForExcluded;
  16032. private _hookArrayForIncludedOnly;
  16033. private _resyncMeshes;
  16034. /**
  16035. * Forces the meshes to update their light related information in their rendering used effects
  16036. * @hidden Internal Use Only
  16037. */
  16038. _markMeshesAsLightDirty(): void;
  16039. /**
  16040. * Recomputes the cached photometric scale if needed.
  16041. */
  16042. private _computePhotometricScale;
  16043. /**
  16044. * Returns the Photometric Scale according to the light type and intensity mode.
  16045. */
  16046. private _getPhotometricScale;
  16047. /**
  16048. * Reorder the light in the scene according to their defined priority.
  16049. * @hidden Internal Use Only
  16050. */
  16051. _reorderLightsInScene(): void;
  16052. /**
  16053. * Prepares the list of defines specific to the light type.
  16054. * @param defines the list of defines
  16055. * @param lightIndex defines the index of the light for the effect
  16056. */
  16057. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16058. }
  16059. }
  16060. declare module BABYLON {
  16061. /**
  16062. * A point light is a light defined by an unique point in world space.
  16063. * The light is emitted in every direction from this point.
  16064. * A good example of a point light is a standard light bulb.
  16065. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16066. */
  16067. class PointLight extends ShadowLight {
  16068. private _shadowAngle;
  16069. /**
  16070. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16071. * This specifies what angle the shadow will use to be created.
  16072. *
  16073. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  16074. */
  16075. /**
  16076. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16077. * This specifies what angle the shadow will use to be created.
  16078. *
  16079. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  16080. */
  16081. shadowAngle: number;
  16082. /**
  16083. * Gets the direction if it has been set.
  16084. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16085. */
  16086. /**
  16087. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  16088. */
  16089. direction: Vector3;
  16090. /**
  16091. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  16092. * A PointLight emits the light in every direction.
  16093. * It can cast shadows.
  16094. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  16095. * ```javascript
  16096. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  16097. * ```
  16098. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16099. * @param name The light friendly name
  16100. * @param position The position of the point light in the scene
  16101. * @param scene The scene the lights belongs to
  16102. */
  16103. constructor(name: string, position: Vector3, scene: Scene);
  16104. /**
  16105. * Returns the string "PointLight"
  16106. * @returns the class name
  16107. */
  16108. getClassName(): string;
  16109. /**
  16110. * Returns the integer 0.
  16111. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16112. */
  16113. getTypeID(): number;
  16114. /**
  16115. * Specifies wether or not the shadowmap should be a cube texture.
  16116. * @returns true if the shadowmap needs to be a cube texture.
  16117. */
  16118. needCube(): boolean;
  16119. /**
  16120. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  16121. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16122. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16123. */
  16124. getShadowDirection(faceIndex?: number): Vector3;
  16125. /**
  16126. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  16127. * - fov = PI / 2
  16128. * - aspect ratio : 1.0
  16129. * - z-near and far equal to the active camera minZ and maxZ.
  16130. * Returns the PointLight.
  16131. */
  16132. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16133. protected _buildUniformLayout(): void;
  16134. /**
  16135. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  16136. * @param effect The effect to update
  16137. * @param lightIndex The index of the light in the effect to update
  16138. * @returns The point light
  16139. */
  16140. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  16141. /**
  16142. * Prepares the list of defines specific to the light type.
  16143. * @param defines the list of defines
  16144. * @param lightIndex defines the index of the light for the effect
  16145. */
  16146. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16147. }
  16148. }
  16149. declare module BABYLON {
  16150. /**
  16151. * Interface describing all the common properties and methods a shadow light needs to implement.
  16152. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  16153. * as well as binding the different shadow properties to the effects.
  16154. */
  16155. interface IShadowLight extends Light {
  16156. /**
  16157. * The light id in the scene (used in scene.findLighById for instance)
  16158. */
  16159. id: string;
  16160. /**
  16161. * The position the shdow will be casted from.
  16162. */
  16163. position: Vector3;
  16164. /**
  16165. * In 2d mode (needCube being false), the direction used to cast the shadow.
  16166. */
  16167. direction: Vector3;
  16168. /**
  16169. * The transformed position. Position of the light in world space taking parenting in account.
  16170. */
  16171. transformedPosition: Vector3;
  16172. /**
  16173. * The transformed direction. Direction of the light in world space taking parenting in account.
  16174. */
  16175. transformedDirection: Vector3;
  16176. /**
  16177. * The friendly name of the light in the scene.
  16178. */
  16179. name: string;
  16180. /**
  16181. * Defines the shadow projection clipping minimum z value.
  16182. */
  16183. shadowMinZ: number;
  16184. /**
  16185. * Defines the shadow projection clipping maximum z value.
  16186. */
  16187. shadowMaxZ: number;
  16188. /**
  16189. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16190. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16191. */
  16192. computeTransformedInformation(): boolean;
  16193. /**
  16194. * Gets the scene the light belongs to.
  16195. * @returns The scene
  16196. */
  16197. getScene(): Scene;
  16198. /**
  16199. * Callback defining a custom Projection Matrix Builder.
  16200. * This can be used to override the default projection matrix computation.
  16201. */
  16202. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16203. /**
  16204. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16205. * @param matrix The materix to updated with the projection information
  16206. * @param viewMatrix The transform matrix of the light
  16207. * @param renderList The list of mesh to render in the map
  16208. * @returns The current light
  16209. */
  16210. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16211. /**
  16212. * Gets the current depth scale used in ESM.
  16213. * @returns The scale
  16214. */
  16215. getDepthScale(): number;
  16216. /**
  16217. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16218. * @returns true if a cube texture needs to be use
  16219. */
  16220. needCube(): boolean;
  16221. /**
  16222. * Detects if the projection matrix requires to be recomputed this frame.
  16223. * @returns true if it requires to be recomputed otherwise, false.
  16224. */
  16225. needProjectionMatrixCompute(): boolean;
  16226. /**
  16227. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16228. */
  16229. forceProjectionMatrixCompute(): void;
  16230. /**
  16231. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16232. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16233. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16234. */
  16235. getShadowDirection(faceIndex?: number): Vector3;
  16236. /**
  16237. * Gets the minZ used for shadow according to both the scene and the light.
  16238. * @param activeCamera The camera we are returning the min for
  16239. * @returns the depth min z
  16240. */
  16241. getDepthMinZ(activeCamera: Camera): number;
  16242. /**
  16243. * Gets the maxZ used for shadow according to both the scene and the light.
  16244. * @param activeCamera The camera we are returning the max for
  16245. * @returns the depth max z
  16246. */
  16247. getDepthMaxZ(activeCamera: Camera): number;
  16248. }
  16249. /**
  16250. * Base implementation IShadowLight
  16251. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  16252. */
  16253. abstract class ShadowLight extends Light implements IShadowLight {
  16254. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16255. protected _position: Vector3;
  16256. protected _setPosition(value: Vector3): void;
  16257. /**
  16258. * Sets the position the shadow will be casted from. Also use as the light position for both
  16259. * point and spot lights.
  16260. */
  16261. /**
  16262. * Sets the position the shadow will be casted from. Also use as the light position for both
  16263. * point and spot lights.
  16264. */
  16265. position: Vector3;
  16266. protected _direction: Vector3;
  16267. protected _setDirection(value: Vector3): void;
  16268. /**
  16269. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  16270. * Also use as the light direction on spot and directional lights.
  16271. */
  16272. /**
  16273. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  16274. * Also use as the light direction on spot and directional lights.
  16275. */
  16276. direction: Vector3;
  16277. private _shadowMinZ;
  16278. /**
  16279. * Gets the shadow projection clipping minimum z value.
  16280. */
  16281. /**
  16282. * Sets the shadow projection clipping minimum z value.
  16283. */
  16284. shadowMinZ: number;
  16285. private _shadowMaxZ;
  16286. /**
  16287. * Sets the shadow projection clipping maximum z value.
  16288. */
  16289. /**
  16290. * Gets the shadow projection clipping maximum z value.
  16291. */
  16292. shadowMaxZ: number;
  16293. /**
  16294. * Callback defining a custom Projection Matrix Builder.
  16295. * This can be used to override the default projection matrix computation.
  16296. */
  16297. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16298. /**
  16299. * The transformed position. Position of the light in world space taking parenting in account.
  16300. */
  16301. transformedPosition: Vector3;
  16302. /**
  16303. * The transformed direction. Direction of the light in world space taking parenting in account.
  16304. */
  16305. transformedDirection: Vector3;
  16306. private _needProjectionMatrixCompute;
  16307. /**
  16308. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16309. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16310. */
  16311. computeTransformedInformation(): boolean;
  16312. /**
  16313. * Return the depth scale used for the shadow map.
  16314. * @returns the depth scale.
  16315. */
  16316. getDepthScale(): number;
  16317. /**
  16318. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16319. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16320. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16321. */
  16322. getShadowDirection(faceIndex?: number): Vector3;
  16323. /**
  16324. * Returns the ShadowLight absolute position in the World.
  16325. * @returns the position vector in world space
  16326. */
  16327. getAbsolutePosition(): Vector3;
  16328. /**
  16329. * Sets the ShadowLight direction toward the passed target.
  16330. * @param target The point tot target in local space
  16331. * @returns the updated ShadowLight direction
  16332. */
  16333. setDirectionToTarget(target: Vector3): Vector3;
  16334. /**
  16335. * Returns the light rotation in euler definition.
  16336. * @returns the x y z rotation in local space.
  16337. */
  16338. getRotation(): Vector3;
  16339. /**
  16340. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16341. * @returns true if a cube texture needs to be use
  16342. */
  16343. needCube(): boolean;
  16344. /**
  16345. * Detects if the projection matrix requires to be recomputed this frame.
  16346. * @returns true if it requires to be recomputed otherwise, false.
  16347. */
  16348. needProjectionMatrixCompute(): boolean;
  16349. /**
  16350. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16351. */
  16352. forceProjectionMatrixCompute(): void;
  16353. /** @hidden */
  16354. _initCache(): void;
  16355. /** @hidden */
  16356. _isSynchronized(): boolean;
  16357. /**
  16358. * Computes the world matrix of the node
  16359. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  16360. * @returns the world matrix
  16361. */
  16362. computeWorldMatrix(force?: boolean): Matrix;
  16363. /**
  16364. * Gets the minZ used for shadow according to both the scene and the light.
  16365. * @param activeCamera The camera we are returning the min for
  16366. * @returns the depth min z
  16367. */
  16368. getDepthMinZ(activeCamera: Camera): number;
  16369. /**
  16370. * Gets the maxZ used for shadow according to both the scene and the light.
  16371. * @param activeCamera The camera we are returning the max for
  16372. * @returns the depth max z
  16373. */
  16374. getDepthMaxZ(activeCamera: Camera): number;
  16375. /**
  16376. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16377. * @param matrix The materix to updated with the projection information
  16378. * @param viewMatrix The transform matrix of the light
  16379. * @param renderList The list of mesh to render in the map
  16380. * @returns The current light
  16381. */
  16382. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16383. }
  16384. }
  16385. declare module BABYLON {
  16386. /**
  16387. * A spot light is defined by a position, a direction, an angle, and an exponent.
  16388. * These values define a cone of light starting from the position, emitting toward the direction.
  16389. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  16390. * and the exponent defines the speed of the decay of the light with distance (reach).
  16391. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16392. */
  16393. class SpotLight extends ShadowLight {
  16394. private _angle;
  16395. private _innerAngle;
  16396. private _cosHalfAngle;
  16397. private _lightAngleScale;
  16398. private _lightAngleOffset;
  16399. /**
  16400. * Gets the cone angle of the spot light in Radians.
  16401. */
  16402. /**
  16403. * Sets the cone angle of the spot light in Radians.
  16404. */
  16405. angle: number;
  16406. /**
  16407. * Only used in gltf falloff mode, this defines the angle where
  16408. * the directional falloff will start before cutting at angle which could be seen
  16409. * as outer angle.
  16410. */
  16411. /**
  16412. * Only used in gltf falloff mode, this defines the angle where
  16413. * the directional falloff will start before cutting at angle which could be seen
  16414. * as outer angle.
  16415. */
  16416. innerAngle: number;
  16417. private _shadowAngleScale;
  16418. /**
  16419. * Allows scaling the angle of the light for shadow generation only.
  16420. */
  16421. /**
  16422. * Allows scaling the angle of the light for shadow generation only.
  16423. */
  16424. shadowAngleScale: number;
  16425. /**
  16426. * The light decay speed with the distance from the emission spot.
  16427. */
  16428. exponent: number;
  16429. private _projectionTextureMatrix;
  16430. /**
  16431. * Allows reading the projecton texture
  16432. */
  16433. readonly projectionTextureMatrix: Matrix;
  16434. protected _projectionTextureLightNear: number;
  16435. /**
  16436. * Gets the near clip of the Spotlight for texture projection.
  16437. */
  16438. /**
  16439. * Sets the near clip of the Spotlight for texture projection.
  16440. */
  16441. projectionTextureLightNear: number;
  16442. protected _projectionTextureLightFar: number;
  16443. /**
  16444. * Gets the far clip of the Spotlight for texture projection.
  16445. */
  16446. /**
  16447. * Sets the far clip of the Spotlight for texture projection.
  16448. */
  16449. projectionTextureLightFar: number;
  16450. protected _projectionTextureUpDirection: Vector3;
  16451. /**
  16452. * Gets the Up vector of the Spotlight for texture projection.
  16453. */
  16454. /**
  16455. * Sets the Up vector of the Spotlight for texture projection.
  16456. */
  16457. projectionTextureUpDirection: Vector3;
  16458. private _projectionTexture;
  16459. /**
  16460. * Gets the projection texture of the light.
  16461. */
  16462. /**
  16463. * Sets the projection texture of the light.
  16464. */
  16465. projectionTexture: Nullable<BaseTexture>;
  16466. private _projectionTextureViewLightDirty;
  16467. private _projectionTextureProjectionLightDirty;
  16468. private _projectionTextureDirty;
  16469. private _projectionTextureViewTargetVector;
  16470. private _projectionTextureViewLightMatrix;
  16471. private _projectionTextureProjectionLightMatrix;
  16472. private _projectionTextureScalingMatrix;
  16473. /**
  16474. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  16475. * It can cast shadows.
  16476. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16477. * @param name The light friendly name
  16478. * @param position The position of the spot light in the scene
  16479. * @param direction The direction of the light in the scene
  16480. * @param angle The cone angle of the light in Radians
  16481. * @param exponent The light decay speed with the distance from the emission spot
  16482. * @param scene The scene the lights belongs to
  16483. */
  16484. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  16485. /**
  16486. * Returns the string "SpotLight".
  16487. * @returns the class name
  16488. */
  16489. getClassName(): string;
  16490. /**
  16491. * Returns the integer 2.
  16492. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16493. */
  16494. getTypeID(): number;
  16495. /**
  16496. * Overrides the direction setter to recompute the projection texture view light Matrix.
  16497. */
  16498. protected _setDirection(value: Vector3): void;
  16499. /**
  16500. * Overrides the position setter to recompute the projection texture view light Matrix.
  16501. */
  16502. protected _setPosition(value: Vector3): void;
  16503. /**
  16504. * 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.
  16505. * Returns the SpotLight.
  16506. */
  16507. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16508. protected _computeProjectionTextureViewLightMatrix(): void;
  16509. protected _computeProjectionTextureProjectionLightMatrix(): void;
  16510. /**
  16511. * Main function for light texture projection matrix computing.
  16512. */
  16513. protected _computeProjectionTextureMatrix(): void;
  16514. protected _buildUniformLayout(): void;
  16515. private _computeAngleValues;
  16516. /**
  16517. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  16518. * @param effect The effect to update
  16519. * @param lightIndex The index of the light in the effect to update
  16520. * @returns The spot light
  16521. */
  16522. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  16523. /**
  16524. * Disposes the light and the associated resources.
  16525. */
  16526. dispose(): void;
  16527. /**
  16528. * Prepares the list of defines specific to the light type.
  16529. * @param defines the list of defines
  16530. * @param lightIndex defines the index of the light for the effect
  16531. */
  16532. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16533. }
  16534. }
  16535. declare module BABYLON {
  16536. /**
  16537. * Interface used to present a loading screen while loading a scene
  16538. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16539. */
  16540. interface ILoadingScreen {
  16541. /**
  16542. * Function called to display the loading screen
  16543. */
  16544. displayLoadingUI: () => void;
  16545. /**
  16546. * Function called to hide the loading screen
  16547. */
  16548. hideLoadingUI: () => void;
  16549. /**
  16550. * Gets or sets the color to use for the background
  16551. */
  16552. loadingUIBackgroundColor: string;
  16553. /**
  16554. * Gets or sets the text to display while loading
  16555. */
  16556. loadingUIText: string;
  16557. }
  16558. /**
  16559. * Class used for the default loading screen
  16560. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16561. */
  16562. class DefaultLoadingScreen implements ILoadingScreen {
  16563. private _renderingCanvas;
  16564. private _loadingText;
  16565. private _loadingDivBackgroundColor;
  16566. private _loadingDiv;
  16567. private _loadingTextDiv;
  16568. /**
  16569. * Creates a new default loading screen
  16570. * @param _renderingCanvas defines the canvas used to render the scene
  16571. * @param _loadingText defines the default text to display
  16572. * @param _loadingDivBackgroundColor defines the default background color
  16573. */
  16574. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  16575. /**
  16576. * Function called to display the loading screen
  16577. */
  16578. displayLoadingUI(): void;
  16579. /**
  16580. * Function called to hide the loading screen
  16581. */
  16582. hideLoadingUI(): void;
  16583. /**
  16584. * Gets or sets the text to display while loading
  16585. */
  16586. loadingUIText: string;
  16587. /**
  16588. * Gets or sets the color to use for the background
  16589. */
  16590. loadingUIBackgroundColor: string;
  16591. private _resizeLoadingUI;
  16592. }
  16593. }
  16594. declare module BABYLON {
  16595. /**
  16596. * Class used to represent data loading progression
  16597. */
  16598. class SceneLoaderProgressEvent {
  16599. /** defines if data length to load can be evaluated */
  16600. readonly lengthComputable: boolean;
  16601. /** defines the loaded data length */
  16602. readonly loaded: number;
  16603. /** defines the data length to load */
  16604. readonly total: number;
  16605. /**
  16606. * Create a new progress event
  16607. * @param lengthComputable defines if data length to load can be evaluated
  16608. * @param loaded defines the loaded data length
  16609. * @param total defines the data length to load
  16610. */
  16611. constructor(
  16612. /** defines if data length to load can be evaluated */
  16613. lengthComputable: boolean,
  16614. /** defines the loaded data length */
  16615. loaded: number,
  16616. /** defines the data length to load */
  16617. total: number);
  16618. /**
  16619. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  16620. * @param event defines the source event
  16621. * @returns a new SceneLoaderProgressEvent
  16622. */
  16623. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  16624. }
  16625. /**
  16626. * Interface used by SceneLoader plugins to define supported file extensions
  16627. */
  16628. interface ISceneLoaderPluginExtensions {
  16629. /**
  16630. * Defines the list of supported extensions
  16631. */
  16632. [extension: string]: {
  16633. isBinary: boolean;
  16634. };
  16635. }
  16636. /**
  16637. * Interface used by SceneLoader plugin factory
  16638. */
  16639. interface ISceneLoaderPluginFactory {
  16640. /**
  16641. * Defines the name of the factory
  16642. */
  16643. name: string;
  16644. /**
  16645. * Function called to create a new plugin
  16646. * @return the new plugin
  16647. */
  16648. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  16649. /**
  16650. * Boolean indicating if the plugin can direct load specific data
  16651. */
  16652. canDirectLoad?: (data: string) => boolean;
  16653. }
  16654. /**
  16655. * Interface used to define a SceneLoader plugin
  16656. */
  16657. interface ISceneLoaderPlugin {
  16658. /**
  16659. * The friendly name of this plugin.
  16660. */
  16661. name: string;
  16662. /**
  16663. * The file extensions supported by this plugin.
  16664. */
  16665. extensions: string | ISceneLoaderPluginExtensions;
  16666. /**
  16667. * Import meshes into a scene.
  16668. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16669. * @param scene The scene to import into
  16670. * @param data The data to import
  16671. * @param rootUrl The root url for scene and resources
  16672. * @param meshes The meshes array to import into
  16673. * @param particleSystems The particle systems array to import into
  16674. * @param skeletons The skeletons array to import into
  16675. * @param onError The callback when import fails
  16676. * @returns True if successful or false otherwise
  16677. */
  16678. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  16679. /**
  16680. * Load into a scene.
  16681. * @param scene The scene to load into
  16682. * @param data The data to import
  16683. * @param rootUrl The root url for scene and resources
  16684. * @param onError The callback when import fails
  16685. * @returns true if successful or false otherwise
  16686. */
  16687. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  16688. /**
  16689. * The callback that returns true if the data can be directly loaded.
  16690. */
  16691. canDirectLoad?: (data: string) => boolean;
  16692. /**
  16693. * The callback that allows custom handling of the root url based on the response url.
  16694. */
  16695. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16696. /**
  16697. * Load into an asset container.
  16698. * @param scene The scene to load into
  16699. * @param data The data to import
  16700. * @param rootUrl The root url for scene and resources
  16701. * @param onError The callback when import fails
  16702. * @returns The loaded asset container
  16703. */
  16704. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  16705. }
  16706. /**
  16707. * Interface used to define an async SceneLoader plugin
  16708. */
  16709. interface ISceneLoaderPluginAsync {
  16710. /**
  16711. * The friendly name of this plugin.
  16712. */
  16713. name: string;
  16714. /**
  16715. * The file extensions supported by this plugin.
  16716. */
  16717. extensions: string | ISceneLoaderPluginExtensions;
  16718. /**
  16719. * Import meshes into a scene.
  16720. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16721. * @param scene The scene to import into
  16722. * @param data The data to import
  16723. * @param rootUrl The root url for scene and resources
  16724. * @param onProgress The callback when the load progresses
  16725. * @param fileName Defines the name of the file to load
  16726. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  16727. */
  16728. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  16729. meshes: AbstractMesh[];
  16730. particleSystems: IParticleSystem[];
  16731. skeletons: Skeleton[];
  16732. animationGroups: AnimationGroup[];
  16733. }>;
  16734. /**
  16735. * Load into a scene.
  16736. * @param scene The scene to load into
  16737. * @param data The data to import
  16738. * @param rootUrl The root url for scene and resources
  16739. * @param onProgress The callback when the load progresses
  16740. * @param fileName Defines the name of the file to load
  16741. * @returns Nothing
  16742. */
  16743. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  16744. /**
  16745. * The callback that returns true if the data can be directly loaded.
  16746. */
  16747. canDirectLoad?: (data: string) => boolean;
  16748. /**
  16749. * The callback that allows custom handling of the root url based on the response url.
  16750. */
  16751. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16752. /**
  16753. * Load into an asset container.
  16754. * @param scene The scene to load into
  16755. * @param data The data to import
  16756. * @param rootUrl The root url for scene and resources
  16757. * @param onProgress The callback when the load progresses
  16758. * @param fileName Defines the name of the file to load
  16759. * @returns The loaded asset container
  16760. */
  16761. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  16762. }
  16763. /**
  16764. * Class used to load scene from various file formats using registered plugins
  16765. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  16766. */
  16767. class SceneLoader {
  16768. private static _ForceFullSceneLoadingForIncremental;
  16769. private static _ShowLoadingScreen;
  16770. private static _CleanBoneMatrixWeights;
  16771. /**
  16772. * No logging while loading
  16773. */
  16774. static readonly NO_LOGGING: number;
  16775. /**
  16776. * Minimal logging while loading
  16777. */
  16778. static readonly MINIMAL_LOGGING: number;
  16779. /**
  16780. * Summary logging while loading
  16781. */
  16782. static readonly SUMMARY_LOGGING: number;
  16783. /**
  16784. * Detailled logging while loading
  16785. */
  16786. static readonly DETAILED_LOGGING: number;
  16787. private static _loggingLevel;
  16788. /**
  16789. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  16790. */
  16791. static ForceFullSceneLoadingForIncremental: boolean;
  16792. /**
  16793. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  16794. */
  16795. static ShowLoadingScreen: boolean;
  16796. /**
  16797. * Defines the current logging level (while loading the scene)
  16798. * @ignorenaming
  16799. */
  16800. static loggingLevel: number;
  16801. /**
  16802. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  16803. */
  16804. static CleanBoneMatrixWeights: boolean;
  16805. /**
  16806. * Event raised when a plugin is used to load a scene
  16807. */
  16808. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16809. private static _registeredPlugins;
  16810. private static _getDefaultPlugin;
  16811. private static _getPluginForExtension;
  16812. private static _getPluginForDirectLoad;
  16813. private static _getPluginForFilename;
  16814. private static _getDirectLoad;
  16815. private static _loadData;
  16816. private static _getFileInfo;
  16817. /**
  16818. * Gets a plugin that can load the given extension
  16819. * @param extension defines the extension to load
  16820. * @returns a plugin or null if none works
  16821. */
  16822. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  16823. /**
  16824. * Gets a boolean indicating that the given extension can be loaded
  16825. * @param extension defines the extension to load
  16826. * @returns true if the extension is supported
  16827. */
  16828. static IsPluginForExtensionAvailable(extension: string): boolean;
  16829. /**
  16830. * Adds a new plugin to the list of registered plugins
  16831. * @param plugin defines the plugin to add
  16832. */
  16833. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  16834. /**
  16835. * Import meshes into a scene
  16836. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16837. * @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)
  16838. * @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)
  16839. * @param scene the instance of BABYLON.Scene to append to
  16840. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  16841. * @param onProgress a callback with a progress event for each file being loaded
  16842. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16843. * @param pluginExtension the extension used to determine the plugin
  16844. * @returns The loaded plugin
  16845. */
  16846. 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>;
  16847. /**
  16848. * Import meshes into a scene
  16849. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16850. * @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)
  16851. * @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)
  16852. * @param scene the instance of BABYLON.Scene to append to
  16853. * @param onProgress a callback with a progress event for each file being loaded
  16854. * @param pluginExtension the extension used to determine the plugin
  16855. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  16856. */
  16857. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  16858. meshes: AbstractMesh[];
  16859. particleSystems: IParticleSystem[];
  16860. skeletons: Skeleton[];
  16861. animationGroups: AnimationGroup[];
  16862. }>;
  16863. /**
  16864. * Load a scene
  16865. * @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)
  16866. * @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)
  16867. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16868. * @param onSuccess a callback with the scene when import succeeds
  16869. * @param onProgress a callback with a progress event for each file being loaded
  16870. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16871. * @param pluginExtension the extension used to determine the plugin
  16872. * @returns The loaded plugin
  16873. */
  16874. 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>;
  16875. /**
  16876. * Load a scene
  16877. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  16878. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16879. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16880. * @param onProgress a callback with a progress event for each file being loaded
  16881. * @param pluginExtension the extension used to determine the plugin
  16882. * @returns The loaded scene
  16883. */
  16884. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16885. /**
  16886. * Append a scene
  16887. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  16888. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16889. * @param scene is the instance of BABYLON.Scene to append to
  16890. * @param onSuccess a callback with the scene when import succeeds
  16891. * @param onProgress a callback with a progress event for each file being loaded
  16892. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16893. * @param pluginExtension the extension used to determine the plugin
  16894. * @returns The loaded plugin
  16895. */
  16896. static 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>;
  16897. /**
  16898. * Append a scene
  16899. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  16900. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16901. * @param scene is the instance of BABYLON.Scene to append to
  16902. * @param onProgress a callback with a progress event for each file being loaded
  16903. * @param pluginExtension the extension used to determine the plugin
  16904. * @returns The given scene
  16905. */
  16906. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16907. /**
  16908. * Load a scene into an asset container
  16909. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  16910. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  16911. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  16912. * @param onSuccess a callback with the scene when import succeeds
  16913. * @param onProgress a callback with a progress event for each file being loaded
  16914. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16915. * @param pluginExtension the extension used to determine the plugin
  16916. * @returns The loaded plugin
  16917. */
  16918. static 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>;
  16919. /**
  16920. * Load a scene into an asset container
  16921. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  16922. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  16923. * @param scene is the instance of BABYLON.Scene to append to
  16924. * @param onProgress a callback with a progress event for each file being loaded
  16925. * @param pluginExtension the extension used to determine the plugin
  16926. * @returns The loaded asset container
  16927. */
  16928. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  16929. }
  16930. }
  16931. declare module BABYLON {
  16932. /**
  16933. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  16934. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  16935. * 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;
  16936. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  16937. */
  16938. class ColorCurves {
  16939. private _dirty;
  16940. private _tempColor;
  16941. private _globalCurve;
  16942. private _highlightsCurve;
  16943. private _midtonesCurve;
  16944. private _shadowsCurve;
  16945. private _positiveCurve;
  16946. private _negativeCurve;
  16947. private _globalHue;
  16948. private _globalDensity;
  16949. private _globalSaturation;
  16950. private _globalExposure;
  16951. /**
  16952. * Gets the global Hue value.
  16953. * 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).
  16954. */
  16955. /**
  16956. * Sets the global Hue value.
  16957. * 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).
  16958. */
  16959. globalHue: number;
  16960. /**
  16961. * Gets the global Density value.
  16962. * 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.
  16963. * Values less than zero provide a filter of opposite hue.
  16964. */
  16965. /**
  16966. * Sets the global Density value.
  16967. * 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.
  16968. * Values less than zero provide a filter of opposite hue.
  16969. */
  16970. globalDensity: number;
  16971. /**
  16972. * Gets the global Saturation value.
  16973. * 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.
  16974. */
  16975. /**
  16976. * Sets the global Saturation value.
  16977. * 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.
  16978. */
  16979. globalSaturation: number;
  16980. /**
  16981. * Gets the global Exposure value.
  16982. * 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.
  16983. */
  16984. /**
  16985. * Sets the global Exposure value.
  16986. * 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.
  16987. */
  16988. globalExposure: number;
  16989. private _highlightsHue;
  16990. private _highlightsDensity;
  16991. private _highlightsSaturation;
  16992. private _highlightsExposure;
  16993. /**
  16994. * Gets the highlights Hue value.
  16995. * 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).
  16996. */
  16997. /**
  16998. * Sets the highlights Hue value.
  16999. * 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).
  17000. */
  17001. highlightsHue: number;
  17002. /**
  17003. * Gets the highlights Density value.
  17004. * 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.
  17005. * Values less than zero provide a filter of opposite hue.
  17006. */
  17007. /**
  17008. * Sets the highlights Density value.
  17009. * 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.
  17010. * Values less than zero provide a filter of opposite hue.
  17011. */
  17012. highlightsDensity: number;
  17013. /**
  17014. * Gets the highlights Saturation value.
  17015. * 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.
  17016. */
  17017. /**
  17018. * Sets the highlights Saturation value.
  17019. * 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.
  17020. */
  17021. highlightsSaturation: number;
  17022. /**
  17023. * Gets the highlights Exposure value.
  17024. * 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.
  17025. */
  17026. /**
  17027. * Sets the highlights Exposure value.
  17028. * 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.
  17029. */
  17030. highlightsExposure: number;
  17031. private _midtonesHue;
  17032. private _midtonesDensity;
  17033. private _midtonesSaturation;
  17034. private _midtonesExposure;
  17035. /**
  17036. * Gets the midtones Hue value.
  17037. * 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).
  17038. */
  17039. /**
  17040. * Sets the midtones Hue value.
  17041. * 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).
  17042. */
  17043. midtonesHue: number;
  17044. /**
  17045. * Gets the midtones Density value.
  17046. * 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.
  17047. * Values less than zero provide a filter of opposite hue.
  17048. */
  17049. /**
  17050. * Sets the midtones Density value.
  17051. * 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.
  17052. * Values less than zero provide a filter of opposite hue.
  17053. */
  17054. midtonesDensity: number;
  17055. /**
  17056. * Gets the midtones Saturation value.
  17057. * 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.
  17058. */
  17059. /**
  17060. * Sets the midtones Saturation value.
  17061. * 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.
  17062. */
  17063. midtonesSaturation: number;
  17064. /**
  17065. * Gets the midtones Exposure value.
  17066. * 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.
  17067. */
  17068. /**
  17069. * Sets the midtones Exposure value.
  17070. * 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.
  17071. */
  17072. midtonesExposure: number;
  17073. private _shadowsHue;
  17074. private _shadowsDensity;
  17075. private _shadowsSaturation;
  17076. private _shadowsExposure;
  17077. /**
  17078. * Gets the shadows Hue value.
  17079. * 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).
  17080. */
  17081. /**
  17082. * Sets the shadows Hue value.
  17083. * 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).
  17084. */
  17085. shadowsHue: number;
  17086. /**
  17087. * Gets the shadows Density value.
  17088. * 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.
  17089. * Values less than zero provide a filter of opposite hue.
  17090. */
  17091. /**
  17092. * Sets the shadows Density value.
  17093. * 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.
  17094. * Values less than zero provide a filter of opposite hue.
  17095. */
  17096. shadowsDensity: number;
  17097. /**
  17098. * Gets the shadows Saturation value.
  17099. * 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.
  17100. */
  17101. /**
  17102. * Sets the shadows Saturation value.
  17103. * 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.
  17104. */
  17105. shadowsSaturation: number;
  17106. /**
  17107. * Gets the shadows Exposure value.
  17108. * 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.
  17109. */
  17110. /**
  17111. * Sets the shadows Exposure value.
  17112. * 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.
  17113. */
  17114. shadowsExposure: number;
  17115. /**
  17116. * Returns the class name
  17117. * @returns The class name
  17118. */
  17119. getClassName(): string;
  17120. /**
  17121. * Binds the color curves to the shader.
  17122. * @param colorCurves The color curve to bind
  17123. * @param effect The effect to bind to
  17124. * @param positiveUniform The positive uniform shader parameter
  17125. * @param neutralUniform The neutral uniform shader parameter
  17126. * @param negativeUniform The negative uniform shader parameter
  17127. */
  17128. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  17129. /**
  17130. * Prepare the list of uniforms associated with the ColorCurves effects.
  17131. * @param uniformsList The list of uniforms used in the effect
  17132. */
  17133. static PrepareUniforms(uniformsList: string[]): void;
  17134. /**
  17135. * Returns color grading data based on a hue, density, saturation and exposure value.
  17136. * @param filterHue The hue of the color filter.
  17137. * @param filterDensity The density of the color filter.
  17138. * @param saturation The saturation.
  17139. * @param exposure The exposure.
  17140. * @param result The result data container.
  17141. */
  17142. private getColorGradingDataToRef;
  17143. /**
  17144. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  17145. * @param value The input slider value in range [-100,100].
  17146. * @returns Adjusted value.
  17147. */
  17148. private static applyColorGradingSliderNonlinear;
  17149. /**
  17150. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  17151. * @param hue The hue (H) input.
  17152. * @param saturation The saturation (S) input.
  17153. * @param brightness The brightness (B) input.
  17154. * @result An RGBA color represented as Vector4.
  17155. */
  17156. private static fromHSBToRef;
  17157. /**
  17158. * Returns a value clamped between min and max
  17159. * @param value The value to clamp
  17160. * @param min The minimum of value
  17161. * @param max The maximum of value
  17162. * @returns The clamped value.
  17163. */
  17164. private static clamp;
  17165. /**
  17166. * Clones the current color curve instance.
  17167. * @return The cloned curves
  17168. */
  17169. clone(): ColorCurves;
  17170. /**
  17171. * Serializes the current color curve instance to a json representation.
  17172. * @return a JSON representation
  17173. */
  17174. serialize(): any;
  17175. /**
  17176. * Parses the color curve from a json representation.
  17177. * @param source the JSON source to parse
  17178. * @return The parsed curves
  17179. */
  17180. static Parse(source: any): ColorCurves;
  17181. }
  17182. }
  17183. declare module BABYLON {
  17184. /**
  17185. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  17186. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  17187. */
  17188. class EffectFallbacks {
  17189. private _defines;
  17190. private _currentRank;
  17191. private _maxRank;
  17192. private _mesh;
  17193. /**
  17194. * Removes the fallback from the bound mesh.
  17195. */
  17196. unBindMesh(): void;
  17197. /**
  17198. * Adds a fallback on the specified property.
  17199. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  17200. * @param define The name of the define in the shader
  17201. */
  17202. addFallback(rank: number, define: string): void;
  17203. /**
  17204. * Sets the mesh to use CPU skinning when needing to fallback.
  17205. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  17206. * @param mesh The mesh to use the fallbacks.
  17207. */
  17208. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  17209. /**
  17210. * Checks to see if more fallbacks are still availible.
  17211. */
  17212. readonly isMoreFallbacks: boolean;
  17213. /**
  17214. * Removes the defines that shoould be removed when falling back.
  17215. * @param currentDefines defines the current define statements for the shader.
  17216. * @param effect defines the current effect we try to compile
  17217. * @returns The resulting defines with defines of the current rank removed.
  17218. */
  17219. reduce(currentDefines: string, effect: Effect): string;
  17220. }
  17221. /**
  17222. * Options to be used when creating an effect.
  17223. */
  17224. class EffectCreationOptions {
  17225. /**
  17226. * Atrributes that will be used in the shader.
  17227. */
  17228. attributes: string[];
  17229. /**
  17230. * Uniform varible names that will be set in the shader.
  17231. */
  17232. uniformsNames: string[];
  17233. /**
  17234. * Uniform buffer varible names that will be set in the shader.
  17235. */
  17236. uniformBuffersNames: string[];
  17237. /**
  17238. * Sampler texture variable names that will be set in the shader.
  17239. */
  17240. samplers: string[];
  17241. /**
  17242. * Define statements that will be set in the shader.
  17243. */
  17244. defines: any;
  17245. /**
  17246. * Possible fallbacks for this effect to improve performance when needed.
  17247. */
  17248. fallbacks: Nullable<EffectFallbacks>;
  17249. /**
  17250. * Callback that will be called when the shader is compiled.
  17251. */
  17252. onCompiled: Nullable<(effect: Effect) => void>;
  17253. /**
  17254. * Callback that will be called if an error occurs during shader compilation.
  17255. */
  17256. onError: Nullable<(effect: Effect, errors: string) => void>;
  17257. /**
  17258. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17259. */
  17260. indexParameters: any;
  17261. /**
  17262. * Max number of lights that can be used in the shader.
  17263. */
  17264. maxSimultaneousLights: number;
  17265. /**
  17266. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  17267. */
  17268. transformFeedbackVaryings: Nullable<string[]>;
  17269. }
  17270. /**
  17271. * Effect containing vertex and fragment shader that can be executed on an object.
  17272. */
  17273. class Effect {
  17274. /**
  17275. * Name of the effect.
  17276. */
  17277. name: any;
  17278. /**
  17279. * String container all the define statements that should be set on the shader.
  17280. */
  17281. defines: string;
  17282. /**
  17283. * Callback that will be called when the shader is compiled.
  17284. */
  17285. onCompiled: Nullable<(effect: Effect) => void>;
  17286. /**
  17287. * Callback that will be called if an error occurs during shader compilation.
  17288. */
  17289. onError: Nullable<(effect: Effect, errors: string) => void>;
  17290. /**
  17291. * Callback that will be called when effect is bound.
  17292. */
  17293. onBind: Nullable<(effect: Effect) => void>;
  17294. /**
  17295. * Unique ID of the effect.
  17296. */
  17297. uniqueId: number;
  17298. /**
  17299. * Observable that will be called when the shader is compiled.
  17300. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  17301. */
  17302. onCompileObservable: Observable<Effect>;
  17303. /**
  17304. * Observable that will be called if an error occurs during shader compilation.
  17305. */
  17306. onErrorObservable: Observable<Effect>;
  17307. /** @hidden */
  17308. _onBindObservable: Nullable<Observable<Effect>>;
  17309. /**
  17310. * Observable that will be called when effect is bound.
  17311. */
  17312. readonly onBindObservable: Observable<Effect>;
  17313. /** @hidden */
  17314. _bonesComputationForcedToCPU: boolean;
  17315. private static _uniqueIdSeed;
  17316. private _engine;
  17317. private _uniformBuffersNames;
  17318. private _uniformsNames;
  17319. private _samplers;
  17320. private _isReady;
  17321. private _compilationError;
  17322. private _attributesNames;
  17323. private _attributes;
  17324. private _uniforms;
  17325. /**
  17326. * Key for the effect.
  17327. * @hidden
  17328. */
  17329. _key: string;
  17330. private _indexParameters;
  17331. private _fallbacks;
  17332. private _vertexSourceCode;
  17333. private _fragmentSourceCode;
  17334. private _vertexSourceCodeOverride;
  17335. private _fragmentSourceCodeOverride;
  17336. private _transformFeedbackVaryings;
  17337. /**
  17338. * Compiled shader to webGL program.
  17339. * @hidden
  17340. */
  17341. _program: WebGLProgram;
  17342. private _valueCache;
  17343. private static _baseCache;
  17344. /**
  17345. * Instantiates an effect.
  17346. * An effect can be used to create/manage/execute vertex and fragment shaders.
  17347. * @param baseName Name of the effect.
  17348. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  17349. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  17350. * @param samplers List of sampler variables that will be passed to the shader.
  17351. * @param engine Engine to be used to render the effect
  17352. * @param defines Define statements to be added to the shader.
  17353. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  17354. * @param onCompiled Callback that will be called when the shader is compiled.
  17355. * @param onError Callback that will be called if an error occurs during shader compilation.
  17356. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17357. */
  17358. 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);
  17359. /**
  17360. * Unique key for this effect
  17361. */
  17362. readonly key: string;
  17363. /**
  17364. * If the effect has been compiled and prepared.
  17365. * @returns if the effect is compiled and prepared.
  17366. */
  17367. isReady(): boolean;
  17368. /**
  17369. * The engine the effect was initialized with.
  17370. * @returns the engine.
  17371. */
  17372. getEngine(): Engine;
  17373. /**
  17374. * The compiled webGL program for the effect
  17375. * @returns the webGL program.
  17376. */
  17377. getProgram(): WebGLProgram;
  17378. /**
  17379. * The set of names of attribute variables for the shader.
  17380. * @returns An array of attribute names.
  17381. */
  17382. getAttributesNames(): string[];
  17383. /**
  17384. * Returns the attribute at the given index.
  17385. * @param index The index of the attribute.
  17386. * @returns The location of the attribute.
  17387. */
  17388. getAttributeLocation(index: number): number;
  17389. /**
  17390. * Returns the attribute based on the name of the variable.
  17391. * @param name of the attribute to look up.
  17392. * @returns the attribute location.
  17393. */
  17394. getAttributeLocationByName(name: string): number;
  17395. /**
  17396. * The number of attributes.
  17397. * @returns the numnber of attributes.
  17398. */
  17399. getAttributesCount(): number;
  17400. /**
  17401. * Gets the index of a uniform variable.
  17402. * @param uniformName of the uniform to look up.
  17403. * @returns the index.
  17404. */
  17405. getUniformIndex(uniformName: string): number;
  17406. /**
  17407. * Returns the attribute based on the name of the variable.
  17408. * @param uniformName of the uniform to look up.
  17409. * @returns the location of the uniform.
  17410. */
  17411. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  17412. /**
  17413. * Returns an array of sampler variable names
  17414. * @returns The array of sampler variable neames.
  17415. */
  17416. getSamplers(): string[];
  17417. /**
  17418. * The error from the last compilation.
  17419. * @returns the error string.
  17420. */
  17421. getCompilationError(): string;
  17422. /**
  17423. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  17424. * @param func The callback to be used.
  17425. */
  17426. executeWhenCompiled(func: (effect: Effect) => void): void;
  17427. private _checkIsReady;
  17428. /** @hidden */
  17429. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  17430. /** @hidden */
  17431. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  17432. /** @hidden */
  17433. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  17434. private _processShaderConversion;
  17435. private _processIncludes;
  17436. private _processPrecision;
  17437. /**
  17438. * Recompiles the webGL program
  17439. * @param vertexSourceCode The source code for the vertex shader.
  17440. * @param fragmentSourceCode The source code for the fragment shader.
  17441. * @param onCompiled Callback called when completed.
  17442. * @param onError Callback called on error.
  17443. * @hidden
  17444. */
  17445. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  17446. /**
  17447. * Gets the uniform locations of the the specified variable names
  17448. * @param names THe names of the variables to lookup.
  17449. * @returns Array of locations in the same order as variable names.
  17450. */
  17451. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  17452. /**
  17453. * Prepares the effect
  17454. * @hidden
  17455. */
  17456. _prepareEffect(): void;
  17457. /**
  17458. * Checks if the effect is supported. (Must be called after compilation)
  17459. */
  17460. readonly isSupported: boolean;
  17461. /**
  17462. * Binds a texture to the engine to be used as output of the shader.
  17463. * @param channel Name of the output variable.
  17464. * @param texture Texture to bind.
  17465. * @hidden
  17466. */
  17467. _bindTexture(channel: string, texture: InternalTexture): void;
  17468. /**
  17469. * Sets a texture on the engine to be used in the shader.
  17470. * @param channel Name of the sampler variable.
  17471. * @param texture Texture to set.
  17472. */
  17473. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  17474. /**
  17475. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  17476. * @param channel Name of the sampler variable.
  17477. * @param texture Texture to set.
  17478. */
  17479. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  17480. /**
  17481. * Sets an array of textures on the engine to be used in the shader.
  17482. * @param channel Name of the variable.
  17483. * @param textures Textures to set.
  17484. */
  17485. setTextureArray(channel: string, textures: BaseTexture[]): void;
  17486. /**
  17487. * 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)
  17488. * @param channel Name of the sampler variable.
  17489. * @param postProcess Post process to get the input texture from.
  17490. */
  17491. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  17492. /**
  17493. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  17494. * 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)
  17495. * @param channel Name of the sampler variable.
  17496. * @param postProcess Post process to get the output texture from.
  17497. */
  17498. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  17499. /** @hidden */
  17500. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  17501. /** @hidden */
  17502. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  17503. /** @hidden */
  17504. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  17505. /** @hidden */
  17506. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  17507. /**
  17508. * Binds a buffer to a uniform.
  17509. * @param buffer Buffer to bind.
  17510. * @param name Name of the uniform variable to bind to.
  17511. */
  17512. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  17513. /**
  17514. * Binds block to a uniform.
  17515. * @param blockName Name of the block to bind.
  17516. * @param index Index to bind.
  17517. */
  17518. bindUniformBlock(blockName: string, index: number): void;
  17519. /**
  17520. * Sets an interger value on a uniform variable.
  17521. * @param uniformName Name of the variable.
  17522. * @param value Value to be set.
  17523. * @returns this effect.
  17524. */
  17525. setInt(uniformName: string, value: number): Effect;
  17526. /**
  17527. * Sets an int array on a uniform variable.
  17528. * @param uniformName Name of the variable.
  17529. * @param array array to be set.
  17530. * @returns this effect.
  17531. */
  17532. setIntArray(uniformName: string, array: Int32Array): Effect;
  17533. /**
  17534. * 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)
  17535. * @param uniformName Name of the variable.
  17536. * @param array array to be set.
  17537. * @returns this effect.
  17538. */
  17539. setIntArray2(uniformName: string, array: Int32Array): Effect;
  17540. /**
  17541. * 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)
  17542. * @param uniformName Name of the variable.
  17543. * @param array array to be set.
  17544. * @returns this effect.
  17545. */
  17546. setIntArray3(uniformName: string, array: Int32Array): Effect;
  17547. /**
  17548. * 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)
  17549. * @param uniformName Name of the variable.
  17550. * @param array array to be set.
  17551. * @returns this effect.
  17552. */
  17553. setIntArray4(uniformName: string, array: Int32Array): Effect;
  17554. /**
  17555. * Sets an float array on a uniform variable.
  17556. * @param uniformName Name of the variable.
  17557. * @param array array to be set.
  17558. * @returns this effect.
  17559. */
  17560. setFloatArray(uniformName: string, array: Float32Array): Effect;
  17561. /**
  17562. * 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)
  17563. * @param uniformName Name of the variable.
  17564. * @param array array to be set.
  17565. * @returns this effect.
  17566. */
  17567. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  17568. /**
  17569. * 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)
  17570. * @param uniformName Name of the variable.
  17571. * @param array array to be set.
  17572. * @returns this effect.
  17573. */
  17574. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  17575. /**
  17576. * 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)
  17577. * @param uniformName Name of the variable.
  17578. * @param array array to be set.
  17579. * @returns this effect.
  17580. */
  17581. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  17582. /**
  17583. * Sets an array on a uniform variable.
  17584. * @param uniformName Name of the variable.
  17585. * @param array array to be set.
  17586. * @returns this effect.
  17587. */
  17588. setArray(uniformName: string, array: number[]): Effect;
  17589. /**
  17590. * 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)
  17591. * @param uniformName Name of the variable.
  17592. * @param array array to be set.
  17593. * @returns this effect.
  17594. */
  17595. setArray2(uniformName: string, array: number[]): Effect;
  17596. /**
  17597. * 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)
  17598. * @param uniformName Name of the variable.
  17599. * @param array array to be set.
  17600. * @returns this effect.
  17601. */
  17602. setArray3(uniformName: string, array: number[]): Effect;
  17603. /**
  17604. * 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)
  17605. * @param uniformName Name of the variable.
  17606. * @param array array to be set.
  17607. * @returns this effect.
  17608. */
  17609. setArray4(uniformName: string, array: number[]): Effect;
  17610. /**
  17611. * Sets matrices on a uniform variable.
  17612. * @param uniformName Name of the variable.
  17613. * @param matrices matrices to be set.
  17614. * @returns this effect.
  17615. */
  17616. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  17617. /**
  17618. * Sets matrix on a uniform variable.
  17619. * @param uniformName Name of the variable.
  17620. * @param matrix matrix to be set.
  17621. * @returns this effect.
  17622. */
  17623. setMatrix(uniformName: string, matrix: Matrix): Effect;
  17624. /**
  17625. * 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)
  17626. * @param uniformName Name of the variable.
  17627. * @param matrix matrix to be set.
  17628. * @returns this effect.
  17629. */
  17630. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  17631. /**
  17632. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  17633. * @param uniformName Name of the variable.
  17634. * @param matrix matrix to be set.
  17635. * @returns this effect.
  17636. */
  17637. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  17638. /**
  17639. * Sets a float on a uniform variable.
  17640. * @param uniformName Name of the variable.
  17641. * @param value value to be set.
  17642. * @returns this effect.
  17643. */
  17644. setFloat(uniformName: string, value: number): Effect;
  17645. /**
  17646. * Sets a boolean on a uniform variable.
  17647. * @param uniformName Name of the variable.
  17648. * @param bool value to be set.
  17649. * @returns this effect.
  17650. */
  17651. setBool(uniformName: string, bool: boolean): Effect;
  17652. /**
  17653. * Sets a Vector2 on a uniform variable.
  17654. * @param uniformName Name of the variable.
  17655. * @param vector2 vector2 to be set.
  17656. * @returns this effect.
  17657. */
  17658. setVector2(uniformName: string, vector2: Vector2): Effect;
  17659. /**
  17660. * Sets a float2 on a uniform variable.
  17661. * @param uniformName Name of the variable.
  17662. * @param x First float in float2.
  17663. * @param y Second float in float2.
  17664. * @returns this effect.
  17665. */
  17666. setFloat2(uniformName: string, x: number, y: number): Effect;
  17667. /**
  17668. * Sets a Vector3 on a uniform variable.
  17669. * @param uniformName Name of the variable.
  17670. * @param vector3 Value to be set.
  17671. * @returns this effect.
  17672. */
  17673. setVector3(uniformName: string, vector3: Vector3): Effect;
  17674. /**
  17675. * Sets a float3 on a uniform variable.
  17676. * @param uniformName Name of the variable.
  17677. * @param x First float in float3.
  17678. * @param y Second float in float3.
  17679. * @param z Third float in float3.
  17680. * @returns this effect.
  17681. */
  17682. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  17683. /**
  17684. * Sets a Vector4 on a uniform variable.
  17685. * @param uniformName Name of the variable.
  17686. * @param vector4 Value to be set.
  17687. * @returns this effect.
  17688. */
  17689. setVector4(uniformName: string, vector4: Vector4): Effect;
  17690. /**
  17691. * Sets a float4 on a uniform variable.
  17692. * @param uniformName Name of the variable.
  17693. * @param x First float in float4.
  17694. * @param y Second float in float4.
  17695. * @param z Third float in float4.
  17696. * @param w Fourth float in float4.
  17697. * @returns this effect.
  17698. */
  17699. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  17700. /**
  17701. * Sets a Color3 on a uniform variable.
  17702. * @param uniformName Name of the variable.
  17703. * @param color3 Value to be set.
  17704. * @returns this effect.
  17705. */
  17706. setColor3(uniformName: string, color3: Color3): Effect;
  17707. /**
  17708. * Sets a Color4 on a uniform variable.
  17709. * @param uniformName Name of the variable.
  17710. * @param color3 Value to be set.
  17711. * @param alpha Alpha value to be set.
  17712. * @returns this effect.
  17713. */
  17714. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  17715. /**
  17716. * Sets a Color4 on a uniform variable
  17717. * @param uniformName defines the name of the variable
  17718. * @param color4 defines the value to be set
  17719. * @returns this effect.
  17720. */
  17721. setDirectColor4(uniformName: string, color4: Color4): Effect;
  17722. /**
  17723. * This function will add a new shader to the shader store
  17724. * @param name the name of the shader
  17725. * @param pixelShader optional pixel shader content
  17726. * @param vertexShader optional vertex shader content
  17727. */
  17728. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  17729. /**
  17730. * Store of each shader (The can be looked up using effect.key)
  17731. */
  17732. static ShadersStore: {
  17733. [key: string]: string;
  17734. };
  17735. /**
  17736. * Store of each included file for a shader (The can be looked up using effect.key)
  17737. */
  17738. static IncludesShadersStore: {
  17739. [key: string]: string;
  17740. };
  17741. /**
  17742. * Resets the cache of effects.
  17743. */
  17744. static ResetCache(): void;
  17745. }
  17746. }
  17747. declare module BABYLON {
  17748. /**
  17749. * This represents all the required information to add a fresnel effect on a material:
  17750. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  17751. */
  17752. class FresnelParameters {
  17753. private _isEnabled;
  17754. /**
  17755. * Define if the fresnel effect is enable or not.
  17756. */
  17757. isEnabled: boolean;
  17758. /**
  17759. * Define the color used on edges (grazing angle)
  17760. */
  17761. leftColor: Color3;
  17762. /**
  17763. * Define the color used on center
  17764. */
  17765. rightColor: Color3;
  17766. /**
  17767. * Define bias applied to computed fresnel term
  17768. */
  17769. bias: number;
  17770. /**
  17771. * Defined the power exponent applied to fresnel term
  17772. */
  17773. power: number;
  17774. /**
  17775. * Clones the current fresnel and its valuues
  17776. * @returns a clone fresnel configuration
  17777. */
  17778. clone(): FresnelParameters;
  17779. /**
  17780. * Serializes the current fresnel parameters to a JSON representation.
  17781. * @return the JSON serialization
  17782. */
  17783. serialize(): any;
  17784. /**
  17785. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  17786. * @param parsedFresnelParameters Define the JSON representation
  17787. * @returns the parsed parameters
  17788. */
  17789. static Parse(parsedFresnelParameters: any): FresnelParameters;
  17790. }
  17791. }
  17792. declare module BABYLON {
  17793. /**
  17794. * Interface to follow in your material defines to integrate easily the
  17795. * Image proccessing functions.
  17796. * @hidden
  17797. */
  17798. interface IImageProcessingConfigurationDefines {
  17799. IMAGEPROCESSING: boolean;
  17800. VIGNETTE: boolean;
  17801. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17802. VIGNETTEBLENDMODEOPAQUE: boolean;
  17803. TONEMAPPING: boolean;
  17804. TONEMAPPING_ACES: boolean;
  17805. CONTRAST: boolean;
  17806. EXPOSURE: boolean;
  17807. COLORCURVES: boolean;
  17808. COLORGRADING: boolean;
  17809. COLORGRADING3D: boolean;
  17810. SAMPLER3DGREENDEPTH: boolean;
  17811. SAMPLER3DBGRMAP: boolean;
  17812. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17813. }
  17814. /**
  17815. * @hidden
  17816. */
  17817. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17818. IMAGEPROCESSING: boolean;
  17819. VIGNETTE: boolean;
  17820. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17821. VIGNETTEBLENDMODEOPAQUE: boolean;
  17822. TONEMAPPING: boolean;
  17823. TONEMAPPING_ACES: boolean;
  17824. CONTRAST: boolean;
  17825. COLORCURVES: boolean;
  17826. COLORGRADING: boolean;
  17827. COLORGRADING3D: boolean;
  17828. SAMPLER3DGREENDEPTH: boolean;
  17829. SAMPLER3DBGRMAP: boolean;
  17830. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17831. EXPOSURE: boolean;
  17832. constructor();
  17833. }
  17834. /**
  17835. * This groups together the common properties used for image processing either in direct forward pass
  17836. * or through post processing effect depending on the use of the image processing pipeline in your scene
  17837. * or not.
  17838. */
  17839. class ImageProcessingConfiguration {
  17840. /**
  17841. * Default tone mapping applied in BabylonJS.
  17842. */
  17843. static readonly TONEMAPPING_STANDARD: number;
  17844. /**
  17845. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  17846. * to other engines rendering to increase portability.
  17847. */
  17848. static readonly TONEMAPPING_ACES: number;
  17849. /**
  17850. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  17851. */
  17852. colorCurves: Nullable<ColorCurves>;
  17853. private _colorCurvesEnabled;
  17854. /**
  17855. * Gets wether the color curves effect is enabled.
  17856. */
  17857. /**
  17858. * Sets wether the color curves effect is enabled.
  17859. */
  17860. colorCurvesEnabled: boolean;
  17861. private _colorGradingTexture;
  17862. /**
  17863. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17864. */
  17865. /**
  17866. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17867. */
  17868. colorGradingTexture: Nullable<BaseTexture>;
  17869. private _colorGradingEnabled;
  17870. /**
  17871. * Gets wether the color grading effect is enabled.
  17872. */
  17873. /**
  17874. * Sets wether the color grading effect is enabled.
  17875. */
  17876. colorGradingEnabled: boolean;
  17877. private _colorGradingWithGreenDepth;
  17878. /**
  17879. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  17880. */
  17881. /**
  17882. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  17883. */
  17884. colorGradingWithGreenDepth: boolean;
  17885. private _colorGradingBGR;
  17886. /**
  17887. * Gets wether the color grading texture contains BGR values.
  17888. */
  17889. /**
  17890. * Sets wether the color grading texture contains BGR values.
  17891. */
  17892. colorGradingBGR: boolean;
  17893. /** @hidden */
  17894. _exposure: number;
  17895. /**
  17896. * Gets the Exposure used in the effect.
  17897. */
  17898. /**
  17899. * Sets the Exposure used in the effect.
  17900. */
  17901. exposure: number;
  17902. private _toneMappingEnabled;
  17903. /**
  17904. * Gets wether the tone mapping effect is enabled.
  17905. */
  17906. /**
  17907. * Sets wether the tone mapping effect is enabled.
  17908. */
  17909. toneMappingEnabled: boolean;
  17910. private _toneMappingType;
  17911. /**
  17912. * Gets the type of tone mapping effect.
  17913. */
  17914. /**
  17915. * Sets the type of tone mapping effect used in BabylonJS.
  17916. */
  17917. toneMappingType: number;
  17918. protected _contrast: number;
  17919. /**
  17920. * Gets the contrast used in the effect.
  17921. */
  17922. /**
  17923. * Sets the contrast used in the effect.
  17924. */
  17925. contrast: number;
  17926. /**
  17927. * Vignette stretch size.
  17928. */
  17929. vignetteStretch: number;
  17930. /**
  17931. * Vignette centre X Offset.
  17932. */
  17933. vignetteCentreX: number;
  17934. /**
  17935. * Vignette centre Y Offset.
  17936. */
  17937. vignetteCentreY: number;
  17938. /**
  17939. * Vignette weight or intensity of the vignette effect.
  17940. */
  17941. vignetteWeight: number;
  17942. /**
  17943. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17944. * if vignetteEnabled is set to true.
  17945. */
  17946. vignetteColor: Color4;
  17947. /**
  17948. * Camera field of view used by the Vignette effect.
  17949. */
  17950. vignetteCameraFov: number;
  17951. private _vignetteBlendMode;
  17952. /**
  17953. * Gets the vignette blend mode allowing different kind of effect.
  17954. */
  17955. /**
  17956. * Sets the vignette blend mode allowing different kind of effect.
  17957. */
  17958. vignetteBlendMode: number;
  17959. private _vignetteEnabled;
  17960. /**
  17961. * Gets wether the vignette effect is enabled.
  17962. */
  17963. /**
  17964. * Sets wether the vignette effect is enabled.
  17965. */
  17966. vignetteEnabled: boolean;
  17967. private _applyByPostProcess;
  17968. /**
  17969. * Gets wether the image processing is applied through a post process or not.
  17970. */
  17971. /**
  17972. * Sets wether the image processing is applied through a post process or not.
  17973. */
  17974. applyByPostProcess: boolean;
  17975. private _isEnabled;
  17976. /**
  17977. * Gets wether the image processing is enabled or not.
  17978. */
  17979. /**
  17980. * Sets wether the image processing is enabled or not.
  17981. */
  17982. isEnabled: boolean;
  17983. /**
  17984. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  17985. */
  17986. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  17987. /**
  17988. * Method called each time the image processing information changes requires to recompile the effect.
  17989. */
  17990. protected _updateParameters(): void;
  17991. /**
  17992. * Gets the current class name.
  17993. * @return "ImageProcessingConfiguration"
  17994. */
  17995. getClassName(): string;
  17996. /**
  17997. * Prepare the list of uniforms associated with the Image Processing effects.
  17998. * @param uniforms The list of uniforms used in the effect
  17999. * @param defines the list of defines currently in use
  18000. */
  18001. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  18002. /**
  18003. * Prepare the list of samplers associated with the Image Processing effects.
  18004. * @param samplersList The list of uniforms used in the effect
  18005. * @param defines the list of defines currently in use
  18006. */
  18007. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  18008. /**
  18009. * Prepare the list of defines associated to the shader.
  18010. * @param defines the list of defines to complete
  18011. * @param forPostProcess Define if we are currently in post process mode or not
  18012. */
  18013. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  18014. /**
  18015. * Returns true if all the image processing information are ready.
  18016. * @returns True if ready, otherwise, false
  18017. */
  18018. isReady(): boolean;
  18019. /**
  18020. * Binds the image processing to the shader.
  18021. * @param effect The effect to bind to
  18022. * @param aspectRatio Define the current aspect ratio of the effect
  18023. */
  18024. bind(effect: Effect, aspectRatio?: number): void;
  18025. /**
  18026. * Clones the current image processing instance.
  18027. * @return The cloned image processing
  18028. */
  18029. clone(): ImageProcessingConfiguration;
  18030. /**
  18031. * Serializes the current image processing instance to a json representation.
  18032. * @return a JSON representation
  18033. */
  18034. serialize(): any;
  18035. /**
  18036. * Parses the image processing from a json representation.
  18037. * @param source the JSON source to parse
  18038. * @return The parsed image processing
  18039. */
  18040. static Parse(source: any): ImageProcessingConfiguration;
  18041. private static _VIGNETTEMODE_MULTIPLY;
  18042. private static _VIGNETTEMODE_OPAQUE;
  18043. /**
  18044. * Used to apply the vignette as a mix with the pixel color.
  18045. */
  18046. static readonly VIGNETTEMODE_MULTIPLY: number;
  18047. /**
  18048. * Used to apply the vignette as a replacement of the pixel color.
  18049. */
  18050. static readonly VIGNETTEMODE_OPAQUE: number;
  18051. }
  18052. }
  18053. declare module BABYLON {
  18054. /**
  18055. * Manages the defines for the Material
  18056. */
  18057. class MaterialDefines {
  18058. private _keys;
  18059. private _isDirty;
  18060. /** @hidden */
  18061. _renderId: number;
  18062. /** @hidden */
  18063. _areLightsDirty: boolean;
  18064. /** @hidden */
  18065. _areAttributesDirty: boolean;
  18066. /** @hidden */
  18067. _areTexturesDirty: boolean;
  18068. /** @hidden */
  18069. _areFresnelDirty: boolean;
  18070. /** @hidden */
  18071. _areMiscDirty: boolean;
  18072. /** @hidden */
  18073. _areImageProcessingDirty: boolean;
  18074. /** @hidden */
  18075. _normals: boolean;
  18076. /** @hidden */
  18077. _uvs: boolean;
  18078. /** @hidden */
  18079. _needNormals: boolean;
  18080. /** @hidden */
  18081. _needUVs: boolean;
  18082. /**
  18083. * Specifies if the material needs to be re-calculated
  18084. */
  18085. readonly isDirty: boolean;
  18086. /**
  18087. * Marks the material to indicate that it has been re-calculated
  18088. */
  18089. markAsProcessed(): void;
  18090. /**
  18091. * Marks the material to indicate that it needs to be re-calculated
  18092. */
  18093. markAsUnprocessed(): void;
  18094. /**
  18095. * Marks the material to indicate all of its defines need to be re-calculated
  18096. */
  18097. markAllAsDirty(): void;
  18098. /**
  18099. * Marks the material to indicate that image processing needs to be re-calculated
  18100. */
  18101. markAsImageProcessingDirty(): void;
  18102. /**
  18103. * Marks the material to indicate the lights need to be re-calculated
  18104. */
  18105. markAsLightDirty(): void;
  18106. /**
  18107. * Marks the attribute state as changed
  18108. */
  18109. markAsAttributesDirty(): void;
  18110. /**
  18111. * Marks the texture state as changed
  18112. */
  18113. markAsTexturesDirty(): void;
  18114. /**
  18115. * Marks the fresnel state as changed
  18116. */
  18117. markAsFresnelDirty(): void;
  18118. /**
  18119. * Marks the misc state as changed
  18120. */
  18121. markAsMiscDirty(): void;
  18122. /**
  18123. * Rebuilds the material defines
  18124. */
  18125. rebuild(): void;
  18126. /**
  18127. * Specifies if two material defines are equal
  18128. * @param other - A material define instance to compare to
  18129. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  18130. */
  18131. isEqual(other: MaterialDefines): boolean;
  18132. /**
  18133. * Clones this instance's defines to another instance
  18134. * @param other - material defines to clone values to
  18135. */
  18136. cloneTo(other: MaterialDefines): void;
  18137. /**
  18138. * Resets the material define values
  18139. */
  18140. reset(): void;
  18141. /**
  18142. * Converts the material define values to a string
  18143. * @returns - String of material define information
  18144. */
  18145. toString(): string;
  18146. }
  18147. /**
  18148. * Base class for the main features of a material in Babylon.js
  18149. */
  18150. class Material implements IAnimatable {
  18151. private static _TriangleFillMode;
  18152. private static _WireFrameFillMode;
  18153. private static _PointFillMode;
  18154. private static _PointListDrawMode;
  18155. private static _LineListDrawMode;
  18156. private static _LineLoopDrawMode;
  18157. private static _LineStripDrawMode;
  18158. private static _TriangleStripDrawMode;
  18159. private static _TriangleFanDrawMode;
  18160. /**
  18161. * Returns the triangle fill mode
  18162. */
  18163. static readonly TriangleFillMode: number;
  18164. /**
  18165. * Returns the wireframe mode
  18166. */
  18167. static readonly WireFrameFillMode: number;
  18168. /**
  18169. * Returns the point fill mode
  18170. */
  18171. static readonly PointFillMode: number;
  18172. /**
  18173. * Returns the point list draw mode
  18174. */
  18175. static readonly PointListDrawMode: number;
  18176. /**
  18177. * Returns the line list draw mode
  18178. */
  18179. static readonly LineListDrawMode: number;
  18180. /**
  18181. * Returns the line loop draw mode
  18182. */
  18183. static readonly LineLoopDrawMode: number;
  18184. /**
  18185. * Returns the line strip draw mode
  18186. */
  18187. static readonly LineStripDrawMode: number;
  18188. /**
  18189. * Returns the triangle strip draw mode
  18190. */
  18191. static readonly TriangleStripDrawMode: number;
  18192. /**
  18193. * Returns the triangle fan draw mode
  18194. */
  18195. static readonly TriangleFanDrawMode: number;
  18196. /**
  18197. * Stores the clock-wise side orientation
  18198. */
  18199. private static _ClockWiseSideOrientation;
  18200. /**
  18201. * Stores the counter clock-wise side orientation
  18202. */
  18203. private static _CounterClockWiseSideOrientation;
  18204. /**
  18205. * Returns the clock-wise side orientation
  18206. */
  18207. static readonly ClockWiseSideOrientation: number;
  18208. /**
  18209. * Returns the counter clock-wise side orientation
  18210. */
  18211. static readonly CounterClockWiseSideOrientation: number;
  18212. /**
  18213. * The dirty texture flag value
  18214. */
  18215. static readonly TextureDirtyFlag: number;
  18216. /**
  18217. * The dirty light flag value
  18218. */
  18219. static readonly LightDirtyFlag: number;
  18220. /**
  18221. * The dirty fresnel flag value
  18222. */
  18223. static readonly FresnelDirtyFlag: number;
  18224. /**
  18225. * The dirty attribute flag value
  18226. */
  18227. static readonly AttributesDirtyFlag: number;
  18228. /**
  18229. * The dirty misc flag value
  18230. */
  18231. static readonly MiscDirtyFlag: number;
  18232. /**
  18233. * The all dirty flag value
  18234. */
  18235. static readonly AllDirtyFlag: number;
  18236. /**
  18237. * The ID of the material
  18238. */
  18239. id: string;
  18240. /**
  18241. * Gets or sets the unique id of the material
  18242. */
  18243. uniqueId: number;
  18244. /**
  18245. * The name of the material
  18246. */
  18247. name: string;
  18248. /**
  18249. * Gets or sets user defined metadata
  18250. */
  18251. metadata: any;
  18252. /**
  18253. * For internal use only. Please do not use.
  18254. */
  18255. reservedDataStore: any;
  18256. /**
  18257. * Specifies if the ready state should be checked on each call
  18258. */
  18259. checkReadyOnEveryCall: boolean;
  18260. /**
  18261. * Specifies if the ready state should be checked once
  18262. */
  18263. checkReadyOnlyOnce: boolean;
  18264. /**
  18265. * The state of the material
  18266. */
  18267. state: string;
  18268. /**
  18269. * The alpha value of the material
  18270. */
  18271. protected _alpha: number;
  18272. /**
  18273. * Sets the alpha value of the material
  18274. */
  18275. /**
  18276. * Gets the alpha value of the material
  18277. */
  18278. alpha: number;
  18279. /**
  18280. * Specifies if back face culling is enabled
  18281. */
  18282. protected _backFaceCulling: boolean;
  18283. /**
  18284. * Sets the back-face culling state
  18285. */
  18286. /**
  18287. * Gets the back-face culling state
  18288. */
  18289. backFaceCulling: boolean;
  18290. /**
  18291. * Stores the value for side orientation
  18292. */
  18293. sideOrientation: number;
  18294. /**
  18295. * Callback triggered when the material is compiled
  18296. */
  18297. onCompiled: (effect: Effect) => void;
  18298. /**
  18299. * Callback triggered when an error occurs
  18300. */
  18301. onError: (effect: Effect, errors: string) => void;
  18302. /**
  18303. * Callback triggered to get the render target textures
  18304. */
  18305. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  18306. /**
  18307. * Gets a boolean indicating that current material needs to register RTT
  18308. */
  18309. readonly hasRenderTargetTextures: boolean;
  18310. /**
  18311. * Specifies if the material should be serialized
  18312. */
  18313. doNotSerialize: boolean;
  18314. /**
  18315. * @hidden
  18316. */
  18317. _storeEffectOnSubMeshes: boolean;
  18318. /**
  18319. * Stores the animations for the material
  18320. */
  18321. animations: Array<Animation>;
  18322. /**
  18323. * An event triggered when the material is disposed
  18324. */
  18325. onDisposeObservable: Observable<Material>;
  18326. /**
  18327. * An observer which watches for dispose events
  18328. */
  18329. private _onDisposeObserver;
  18330. private _onUnBindObservable;
  18331. /**
  18332. * Called during a dispose event
  18333. */
  18334. onDispose: () => void;
  18335. private _onBindObservable;
  18336. /**
  18337. * An event triggered when the material is bound
  18338. */
  18339. readonly onBindObservable: Observable<AbstractMesh>;
  18340. /**
  18341. * An observer which watches for bind events
  18342. */
  18343. private _onBindObserver;
  18344. /**
  18345. * Called during a bind event
  18346. */
  18347. onBind: (Mesh: AbstractMesh) => void;
  18348. /**
  18349. * An event triggered when the material is unbound
  18350. */
  18351. readonly onUnBindObservable: Observable<Material>;
  18352. /**
  18353. * Stores the value of the alpha mode
  18354. */
  18355. private _alphaMode;
  18356. /**
  18357. * Sets the value of the alpha mode.
  18358. *
  18359. * | Value | Type | Description |
  18360. * | --- | --- | --- |
  18361. * | 0 | ALPHA_DISABLE | |
  18362. * | 1 | ALPHA_ADD | |
  18363. * | 2 | ALPHA_COMBINE | |
  18364. * | 3 | ALPHA_SUBTRACT | |
  18365. * | 4 | ALPHA_MULTIPLY | |
  18366. * | 5 | ALPHA_MAXIMIZED | |
  18367. * | 6 | ALPHA_ONEONE | |
  18368. * | 7 | ALPHA_PREMULTIPLIED | |
  18369. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  18370. * | 9 | ALPHA_INTERPOLATE | |
  18371. * | 10 | ALPHA_SCREENMODE | |
  18372. *
  18373. */
  18374. /**
  18375. * Gets the value of the alpha mode
  18376. */
  18377. alphaMode: number;
  18378. /**
  18379. * Stores the state of the need depth pre-pass value
  18380. */
  18381. private _needDepthPrePass;
  18382. /**
  18383. * Sets the need depth pre-pass value
  18384. */
  18385. /**
  18386. * Gets the depth pre-pass value
  18387. */
  18388. needDepthPrePass: boolean;
  18389. /**
  18390. * Specifies if depth writing should be disabled
  18391. */
  18392. disableDepthWrite: boolean;
  18393. /**
  18394. * Specifies if depth writing should be forced
  18395. */
  18396. forceDepthWrite: boolean;
  18397. /**
  18398. * Specifies if there should be a separate pass for culling
  18399. */
  18400. separateCullingPass: boolean;
  18401. /**
  18402. * Stores the state specifing if fog should be enabled
  18403. */
  18404. private _fogEnabled;
  18405. /**
  18406. * Sets the state for enabling fog
  18407. */
  18408. /**
  18409. * Gets the value of the fog enabled state
  18410. */
  18411. fogEnabled: boolean;
  18412. /**
  18413. * Stores the size of points
  18414. */
  18415. pointSize: number;
  18416. /**
  18417. * Stores the z offset value
  18418. */
  18419. zOffset: number;
  18420. /**
  18421. * Gets a value specifying if wireframe mode is enabled
  18422. */
  18423. /**
  18424. * Sets the state of wireframe mode
  18425. */
  18426. wireframe: boolean;
  18427. /**
  18428. * Gets the value specifying if point clouds are enabled
  18429. */
  18430. /**
  18431. * Sets the state of point cloud mode
  18432. */
  18433. pointsCloud: boolean;
  18434. /**
  18435. * Gets the material fill mode
  18436. */
  18437. /**
  18438. * Sets the material fill mode
  18439. */
  18440. fillMode: number;
  18441. /**
  18442. * @hidden
  18443. * Stores the effects for the material
  18444. */
  18445. _effect: Nullable<Effect>;
  18446. /**
  18447. * @hidden
  18448. * Specifies if the material was previously ready
  18449. */
  18450. _wasPreviouslyReady: boolean;
  18451. /**
  18452. * Specifies if uniform buffers should be used
  18453. */
  18454. private _useUBO;
  18455. /**
  18456. * Stores a reference to the scene
  18457. */
  18458. private _scene;
  18459. /**
  18460. * Stores the fill mode state
  18461. */
  18462. private _fillMode;
  18463. /**
  18464. * Specifies if the depth write state should be cached
  18465. */
  18466. private _cachedDepthWriteState;
  18467. /**
  18468. * Stores the uniform buffer
  18469. */
  18470. protected _uniformBuffer: UniformBuffer;
  18471. /** @hidden */
  18472. _indexInSceneMaterialArray: number;
  18473. /** @hidden */
  18474. meshMap: Nullable<{
  18475. [id: string]: AbstractMesh | undefined;
  18476. }>;
  18477. /**
  18478. * Creates a material instance
  18479. * @param name defines the name of the material
  18480. * @param scene defines the scene to reference
  18481. * @param doNotAdd specifies if the material should be added to the scene
  18482. */
  18483. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  18484. /**
  18485. * Returns a string representation of the current material
  18486. * @param fullDetails defines a boolean indicating which levels of logging is desired
  18487. * @returns a string with material information
  18488. */
  18489. toString(fullDetails?: boolean): string;
  18490. /**
  18491. * Gets the class name of the material
  18492. * @returns a string with the class name of the material
  18493. */
  18494. getClassName(): string;
  18495. /**
  18496. * Specifies if updates for the material been locked
  18497. */
  18498. readonly isFrozen: boolean;
  18499. /**
  18500. * Locks updates for the material
  18501. */
  18502. freeze(): void;
  18503. /**
  18504. * Unlocks updates for the material
  18505. */
  18506. unfreeze(): void;
  18507. /**
  18508. * Specifies if the material is ready to be used
  18509. * @param mesh defines the mesh to check
  18510. * @param useInstances specifies if instances should be used
  18511. * @returns a boolean indicating if the material is ready to be used
  18512. */
  18513. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18514. /**
  18515. * Specifies that the submesh is ready to be used
  18516. * @param mesh defines the mesh to check
  18517. * @param subMesh defines which submesh to check
  18518. * @param useInstances specifies that instances should be used
  18519. * @returns a boolean indicating that the submesh is ready or not
  18520. */
  18521. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18522. /**
  18523. * Returns the material effect
  18524. * @returns the effect associated with the material
  18525. */
  18526. getEffect(): Nullable<Effect>;
  18527. /**
  18528. * Returns the current scene
  18529. * @returns a Scene
  18530. */
  18531. getScene(): Scene;
  18532. /**
  18533. * Specifies if the material will require alpha blending
  18534. * @returns a boolean specifying if alpha blending is needed
  18535. */
  18536. needAlphaBlending(): boolean;
  18537. /**
  18538. * Specifies if the mesh will require alpha blending
  18539. * @param mesh defines the mesh to check
  18540. * @returns a boolean specifying if alpha blending is needed for the mesh
  18541. */
  18542. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  18543. /**
  18544. * Specifies if this material should be rendered in alpha test mode
  18545. * @returns a boolean specifying if an alpha test is needed.
  18546. */
  18547. needAlphaTesting(): boolean;
  18548. /**
  18549. * Gets the texture used for the alpha test
  18550. * @returns the texture to use for alpha testing
  18551. */
  18552. getAlphaTestTexture(): Nullable<BaseTexture>;
  18553. /**
  18554. * Marks the material to indicate that it needs to be re-calculated
  18555. */
  18556. markDirty(): void;
  18557. /** @hidden */
  18558. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  18559. /**
  18560. * Binds the material to the mesh
  18561. * @param world defines the world transformation matrix
  18562. * @param mesh defines the mesh to bind the material to
  18563. */
  18564. bind(world: Matrix, mesh?: Mesh): void;
  18565. /**
  18566. * Binds the submesh to the material
  18567. * @param world defines the world transformation matrix
  18568. * @param mesh defines the mesh containing the submesh
  18569. * @param subMesh defines the submesh to bind the material to
  18570. */
  18571. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18572. /**
  18573. * Binds the world matrix to the material
  18574. * @param world defines the world transformation matrix
  18575. */
  18576. bindOnlyWorldMatrix(world: Matrix): void;
  18577. /**
  18578. * Binds the scene's uniform buffer to the effect.
  18579. * @param effect defines the effect to bind to the scene uniform buffer
  18580. * @param sceneUbo defines the uniform buffer storing scene data
  18581. */
  18582. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  18583. /**
  18584. * Binds the view matrix to the effect
  18585. * @param effect defines the effect to bind the view matrix to
  18586. */
  18587. bindView(effect: Effect): void;
  18588. /**
  18589. * Binds the view projection matrix to the effect
  18590. * @param effect defines the effect to bind the view projection matrix to
  18591. */
  18592. bindViewProjection(effect: Effect): void;
  18593. /**
  18594. * Specifies if material alpha testing should be turned on for the mesh
  18595. * @param mesh defines the mesh to check
  18596. */
  18597. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  18598. /**
  18599. * Processes to execute after binding the material to a mesh
  18600. * @param mesh defines the rendered mesh
  18601. */
  18602. protected _afterBind(mesh?: Mesh): void;
  18603. /**
  18604. * Unbinds the material from the mesh
  18605. */
  18606. unbind(): void;
  18607. /**
  18608. * Gets the active textures from the material
  18609. * @returns an array of textures
  18610. */
  18611. getActiveTextures(): BaseTexture[];
  18612. /**
  18613. * Specifies if the material uses a texture
  18614. * @param texture defines the texture to check against the material
  18615. * @returns a boolean specifying if the material uses the texture
  18616. */
  18617. hasTexture(texture: BaseTexture): boolean;
  18618. /**
  18619. * Makes a duplicate of the material, and gives it a new name
  18620. * @param name defines the new name for the duplicated material
  18621. * @returns the cloned material
  18622. */
  18623. clone(name: string): Nullable<Material>;
  18624. /**
  18625. * Gets the meshes bound to the material
  18626. * @returns an array of meshes bound to the material
  18627. */
  18628. getBindedMeshes(): AbstractMesh[];
  18629. /**
  18630. * Force shader compilation
  18631. * @param mesh defines the mesh associated with this material
  18632. * @param onCompiled defines a function to execute once the material is compiled
  18633. * @param options defines the options to configure the compilation
  18634. */
  18635. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  18636. clipPlane: boolean;
  18637. }>): void;
  18638. /**
  18639. * Force shader compilation
  18640. * @param mesh defines the mesh that will use this material
  18641. * @param options defines additional options for compiling the shaders
  18642. * @returns a promise that resolves when the compilation completes
  18643. */
  18644. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  18645. clipPlane: boolean;
  18646. }>): Promise<void>;
  18647. private static readonly _ImageProcessingDirtyCallBack;
  18648. private static readonly _TextureDirtyCallBack;
  18649. private static readonly _FresnelDirtyCallBack;
  18650. private static readonly _MiscDirtyCallBack;
  18651. private static readonly _LightsDirtyCallBack;
  18652. private static readonly _AttributeDirtyCallBack;
  18653. private static _FresnelAndMiscDirtyCallBack;
  18654. private static _TextureAndMiscDirtyCallBack;
  18655. private static readonly _DirtyCallbackArray;
  18656. private static readonly _RunDirtyCallBacks;
  18657. /**
  18658. * Marks a define in the material to indicate that it needs to be re-computed
  18659. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  18660. */
  18661. markAsDirty(flag: number): void;
  18662. /**
  18663. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  18664. * @param func defines a function which checks material defines against the submeshes
  18665. */
  18666. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  18667. /**
  18668. * Indicates that image processing needs to be re-calculated for all submeshes
  18669. */
  18670. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  18671. /**
  18672. * Indicates that textures need to be re-calculated for all submeshes
  18673. */
  18674. protected _markAllSubMeshesAsTexturesDirty(): void;
  18675. /**
  18676. * Indicates that fresnel needs to be re-calculated for all submeshes
  18677. */
  18678. protected _markAllSubMeshesAsFresnelDirty(): void;
  18679. /**
  18680. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  18681. */
  18682. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  18683. /**
  18684. * Indicates that lights need to be re-calculated for all submeshes
  18685. */
  18686. protected _markAllSubMeshesAsLightsDirty(): void;
  18687. /**
  18688. * Indicates that attributes need to be re-calculated for all submeshes
  18689. */
  18690. protected _markAllSubMeshesAsAttributesDirty(): void;
  18691. /**
  18692. * Indicates that misc needs to be re-calculated for all submeshes
  18693. */
  18694. protected _markAllSubMeshesAsMiscDirty(): void;
  18695. /**
  18696. * Indicates that textures and misc need to be re-calculated for all submeshes
  18697. */
  18698. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  18699. /**
  18700. * Disposes the material
  18701. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18702. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18703. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18704. */
  18705. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18706. /** @hidden */
  18707. private releaseVertexArrayObject;
  18708. /**
  18709. * Serializes this material
  18710. * @returns the serialized material object
  18711. */
  18712. serialize(): any;
  18713. /**
  18714. * Creates a MultiMaterial from parsed MultiMaterial data.
  18715. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  18716. * @param scene defines the hosting scene
  18717. * @returns a new MultiMaterial
  18718. */
  18719. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  18720. /**
  18721. * Creates a material from parsed material data
  18722. * @param parsedMaterial defines parsed material data
  18723. * @param scene defines the hosting scene
  18724. * @param rootUrl defines the root URL to use to load textures
  18725. * @returns a new material
  18726. */
  18727. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  18728. }
  18729. }
  18730. declare module BABYLON {
  18731. /**
  18732. * "Static Class" containing the most commonly used helper while dealing with material for
  18733. * rendering purpose.
  18734. *
  18735. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  18736. *
  18737. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  18738. */
  18739. class MaterialHelper {
  18740. /**
  18741. * Bind the current view position to an effect.
  18742. * @param effect The effect to be bound
  18743. * @param scene The scene the eyes position is used from
  18744. */
  18745. static BindEyePosition(effect: Effect, scene: Scene): void;
  18746. /**
  18747. * Helps preparing the defines values about the UVs in used in the effect.
  18748. * UVs are shared as much as we can accross channels in the shaders.
  18749. * @param texture The texture we are preparing the UVs for
  18750. * @param defines The defines to update
  18751. * @param key The channel key "diffuse", "specular"... used in the shader
  18752. */
  18753. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  18754. /**
  18755. * Binds a texture matrix value to its corrsponding uniform
  18756. * @param texture The texture to bind the matrix for
  18757. * @param uniformBuffer The uniform buffer receivin the data
  18758. * @param key The channel key "diffuse", "specular"... used in the shader
  18759. */
  18760. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  18761. /**
  18762. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  18763. * @param mesh defines the current mesh
  18764. * @param scene defines the current scene
  18765. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  18766. * @param pointsCloud defines if point cloud rendering has to be turned on
  18767. * @param fogEnabled defines if fog has to be turned on
  18768. * @param alphaTest defines if alpha testing has to be turned on
  18769. * @param defines defines the current list of defines
  18770. */
  18771. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  18772. /**
  18773. * Helper used to prepare the list of defines associated with frame values for shader compilation
  18774. * @param scene defines the current scene
  18775. * @param engine defines the current engine
  18776. * @param defines specifies the list of active defines
  18777. * @param useInstances defines if instances have to be turned on
  18778. * @param useClipPlane defines if clip plane have to be turned on
  18779. */
  18780. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  18781. /**
  18782. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  18783. * @param mesh The mesh containing the geometry data we will draw
  18784. * @param defines The defines to update
  18785. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  18786. * @param useBones Precise whether bones should be used or not (override mesh info)
  18787. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  18788. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  18789. * @returns false if defines are considered not dirty and have not been checked
  18790. */
  18791. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  18792. /**
  18793. * Prepares the defines related to the light information passed in parameter
  18794. * @param scene The scene we are intending to draw
  18795. * @param mesh The mesh the effect is compiling for
  18796. * @param defines The defines to update
  18797. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  18798. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  18799. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  18800. * @returns true if normals will be required for the rest of the effect
  18801. */
  18802. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  18803. /**
  18804. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  18805. * that won t be acctive due to defines being turned off.
  18806. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  18807. * @param samplersList The samplers list
  18808. * @param defines The defines helping in the list generation
  18809. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  18810. */
  18811. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  18812. /**
  18813. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  18814. * @param defines The defines to update while falling back
  18815. * @param fallbacks The authorized effect fallbacks
  18816. * @param maxSimultaneousLights The maximum number of lights allowed
  18817. * @param rank the current rank of the Effect
  18818. * @returns The newly affected rank
  18819. */
  18820. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  18821. /**
  18822. * Prepares the list of attributes required for morph targets according to the effect defines.
  18823. * @param attribs The current list of supported attribs
  18824. * @param mesh The mesh to prepare the morph targets attributes for
  18825. * @param defines The current Defines of the effect
  18826. */
  18827. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  18828. /**
  18829. * Prepares the list of attributes required for bones according to the effect defines.
  18830. * @param attribs The current list of supported attribs
  18831. * @param mesh The mesh to prepare the bones attributes for
  18832. * @param defines The current Defines of the effect
  18833. * @param fallbacks The current efffect fallback strategy
  18834. */
  18835. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  18836. /**
  18837. * Prepares the list of attributes required for instances according to the effect defines.
  18838. * @param attribs The current list of supported attribs
  18839. * @param defines The current Defines of the effect
  18840. */
  18841. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  18842. /**
  18843. * Binds the light shadow information to the effect for the given mesh.
  18844. * @param light The light containing the generator
  18845. * @param scene The scene the lights belongs to
  18846. * @param mesh The mesh we are binding the information to render
  18847. * @param lightIndex The light index in the effect used to render the mesh
  18848. * @param effect The effect we are binding the data to
  18849. */
  18850. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  18851. /**
  18852. * Binds the light information to the effect.
  18853. * @param light The light containing the generator
  18854. * @param effect The effect we are binding the data to
  18855. * @param lightIndex The light index in the effect used to render
  18856. */
  18857. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  18858. /**
  18859. * Binds the lights information from the scene to the effect for the given mesh.
  18860. * @param scene The scene the lights belongs to
  18861. * @param mesh The mesh we are binding the information to render
  18862. * @param effect The effect we are binding the data to
  18863. * @param defines The generated defines for the effect
  18864. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  18865. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  18866. */
  18867. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  18868. private static _tempFogColor;
  18869. /**
  18870. * Binds the fog information from the scene to the effect for the given mesh.
  18871. * @param scene The scene the lights belongs to
  18872. * @param mesh The mesh we are binding the information to render
  18873. * @param effect The effect we are binding the data to
  18874. * @param linearSpace Defines if the fog effect is applied in linear space
  18875. */
  18876. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  18877. /**
  18878. * Binds the bones information from the mesh to the effect.
  18879. * @param mesh The mesh we are binding the information to render
  18880. * @param effect The effect we are binding the data to
  18881. */
  18882. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  18883. /**
  18884. * Binds the morph targets information from the mesh to the effect.
  18885. * @param abstractMesh The mesh we are binding the information to render
  18886. * @param effect The effect we are binding the data to
  18887. */
  18888. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  18889. /**
  18890. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  18891. * @param defines The generated defines used in the effect
  18892. * @param effect The effect we are binding the data to
  18893. * @param scene The scene we are willing to render with logarithmic scale for
  18894. */
  18895. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  18896. /**
  18897. * Binds the clip plane information from the scene to the effect.
  18898. * @param scene The scene the clip plane information are extracted from
  18899. * @param effect The effect we are binding the data to
  18900. */
  18901. static BindClipPlane(effect: Effect, scene: Scene): void;
  18902. }
  18903. }
  18904. declare module BABYLON {
  18905. /**
  18906. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18907. * separate meshes. This can be use to improve performances.
  18908. * @see http://doc.babylonjs.com/how_to/multi_materials
  18909. */
  18910. class MultiMaterial extends Material {
  18911. private _subMaterials;
  18912. /**
  18913. * Gets or Sets the list of Materials used within the multi material.
  18914. * They need to be ordered according to the submeshes order in the associated mesh
  18915. */
  18916. subMaterials: Nullable<Material>[];
  18917. /**
  18918. * Function used to align with Node.getChildren()
  18919. * @returns the list of Materials used within the multi material
  18920. */
  18921. getChildren(): Nullable<Material>[];
  18922. /**
  18923. * Instantiates a new Multi Material
  18924. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18925. * separate meshes. This can be use to improve performances.
  18926. * @see http://doc.babylonjs.com/how_to/multi_materials
  18927. * @param name Define the name in the scene
  18928. * @param scene Define the scene the material belongs to
  18929. */
  18930. constructor(name: string, scene: Scene);
  18931. private _hookArray;
  18932. /**
  18933. * Get one of the submaterial by its index in the submaterials array
  18934. * @param index The index to look the sub material at
  18935. * @returns The Material if the index has been defined
  18936. */
  18937. getSubMaterial(index: number): Nullable<Material>;
  18938. /**
  18939. * Get the list of active textures for the whole sub materials list.
  18940. * @returns All the textures that will be used during the rendering
  18941. */
  18942. getActiveTextures(): BaseTexture[];
  18943. /**
  18944. * Gets the current class name of the material e.g. "MultiMaterial"
  18945. * Mainly use in serialization.
  18946. * @returns the class name
  18947. */
  18948. getClassName(): string;
  18949. /**
  18950. * Checks if the material is ready to render the requested sub mesh
  18951. * @param mesh Define the mesh the submesh belongs to
  18952. * @param subMesh Define the sub mesh to look readyness for
  18953. * @param useInstances Define whether or not the material is used with instances
  18954. * @returns true if ready, otherwise false
  18955. */
  18956. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18957. /**
  18958. * Clones the current material and its related sub materials
  18959. * @param name Define the name of the newly cloned material
  18960. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  18961. * @returns the cloned material
  18962. */
  18963. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  18964. /**
  18965. * Serializes the materials into a JSON representation.
  18966. * @returns the JSON representation
  18967. */
  18968. serialize(): any;
  18969. /**
  18970. * Dispose the material and release its associated resources
  18971. * @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)
  18972. * @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)
  18973. */
  18974. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18975. }
  18976. }
  18977. declare module BABYLON {
  18978. /**
  18979. * Base class of materials working in push mode in babylon JS
  18980. * @hidden
  18981. */
  18982. class PushMaterial extends Material {
  18983. protected _activeEffect: Effect;
  18984. protected _normalMatrix: Matrix;
  18985. /**
  18986. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  18987. * This means that the material can keep using a previous shader while a new one is being compiled.
  18988. * This is mostly used when shader parallel compilation is supported (true by default)
  18989. */
  18990. allowShaderHotSwapping: boolean;
  18991. constructor(name: string, scene: Scene);
  18992. getEffect(): Effect;
  18993. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18994. /**
  18995. * Binds the given world matrix to the active effect
  18996. *
  18997. * @param world the matrix to bind
  18998. */
  18999. bindOnlyWorldMatrix(world: Matrix): void;
  19000. /**
  19001. * Binds the given normal matrix to the active effect
  19002. *
  19003. * @param normalMatrix the matrix to bind
  19004. */
  19005. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  19006. bind(world: Matrix, mesh?: Mesh): void;
  19007. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  19008. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  19009. }
  19010. }
  19011. declare module BABYLON {
  19012. /**
  19013. * Defines the options associated with the creation of a shader material.
  19014. */
  19015. interface IShaderMaterialOptions {
  19016. /**
  19017. * Does the material work in alpha blend mode
  19018. */
  19019. needAlphaBlending: boolean;
  19020. /**
  19021. * Does the material work in alpha test mode
  19022. */
  19023. needAlphaTesting: boolean;
  19024. /**
  19025. * The list of attribute names used in the shader
  19026. */
  19027. attributes: string[];
  19028. /**
  19029. * The list of unifrom names used in the shader
  19030. */
  19031. uniforms: string[];
  19032. /**
  19033. * The list of UBO names used in the shader
  19034. */
  19035. uniformBuffers: string[];
  19036. /**
  19037. * The list of sampler names used in the shader
  19038. */
  19039. samplers: string[];
  19040. /**
  19041. * The list of defines used in the shader
  19042. */
  19043. defines: string[];
  19044. }
  19045. /**
  19046. * 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.
  19047. *
  19048. * This returned material effects how the mesh will look based on the code in the shaders.
  19049. *
  19050. * @see http://doc.babylonjs.com/how_to/shader_material
  19051. */
  19052. class ShaderMaterial extends Material {
  19053. private _shaderPath;
  19054. private _options;
  19055. private _textures;
  19056. private _textureArrays;
  19057. private _floats;
  19058. private _ints;
  19059. private _floatsArrays;
  19060. private _colors3;
  19061. private _colors3Arrays;
  19062. private _colors4;
  19063. private _vectors2;
  19064. private _vectors3;
  19065. private _vectors4;
  19066. private _matrices;
  19067. private _matrices3x3;
  19068. private _matrices2x2;
  19069. private _vectors2Arrays;
  19070. private _vectors3Arrays;
  19071. private _cachedWorldViewMatrix;
  19072. private _renderId;
  19073. /**
  19074. * Instantiate a new shader material.
  19075. * 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.
  19076. * This returned material effects how the mesh will look based on the code in the shaders.
  19077. * @see http://doc.babylonjs.com/how_to/shader_material
  19078. * @param name Define the name of the material in the scene
  19079. * @param scene Define the scene the material belongs to
  19080. * @param shaderPath Defines the route to the shader code in one of three ways:
  19081. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  19082. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  19083. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19084. * @param options Define the options used to create the shader
  19085. */
  19086. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19087. /**
  19088. * Gets the current class name of the material e.g. "ShaderMaterial"
  19089. * Mainly use in serialization.
  19090. * @returns the class name
  19091. */
  19092. getClassName(): string;
  19093. /**
  19094. * Specifies if the material will require alpha blending
  19095. * @returns a boolean specifying if alpha blending is needed
  19096. */
  19097. needAlphaBlending(): boolean;
  19098. /**
  19099. * Specifies if this material should be rendered in alpha test mode
  19100. * @returns a boolean specifying if an alpha test is needed.
  19101. */
  19102. needAlphaTesting(): boolean;
  19103. private _checkUniform;
  19104. /**
  19105. * Set a texture in the shader.
  19106. * @param name Define the name of the uniform samplers as defined in the shader
  19107. * @param texture Define the texture to bind to this sampler
  19108. * @return the material itself allowing "fluent" like uniform updates
  19109. */
  19110. setTexture(name: string, texture: Texture): ShaderMaterial;
  19111. /**
  19112. * Set a texture array in the shader.
  19113. * @param name Define the name of the uniform sampler array as defined in the shader
  19114. * @param textures Define the list of textures to bind to this sampler
  19115. * @return the material itself allowing "fluent" like uniform updates
  19116. */
  19117. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19118. /**
  19119. * Set a float in the shader.
  19120. * @param name Define the name of the uniform as defined in the shader
  19121. * @param value Define the value to give to the uniform
  19122. * @return the material itself allowing "fluent" like uniform updates
  19123. */
  19124. setFloat(name: string, value: number): ShaderMaterial;
  19125. /**
  19126. * Set a int in the shader.
  19127. * @param name Define the name of the uniform as defined in the shader
  19128. * @param value Define the value to give to the uniform
  19129. * @return the material itself allowing "fluent" like uniform updates
  19130. */
  19131. setInt(name: string, value: number): ShaderMaterial;
  19132. /**
  19133. * Set an array of floats in the shader.
  19134. * @param name Define the name of the uniform as defined in the shader
  19135. * @param value Define the value to give to the uniform
  19136. * @return the material itself allowing "fluent" like uniform updates
  19137. */
  19138. setFloats(name: string, value: number[]): ShaderMaterial;
  19139. /**
  19140. * Set a vec3 in the shader from a Color3.
  19141. * @param name Define the name of the uniform as defined in the shader
  19142. * @param value Define the value to give to the uniform
  19143. * @return the material itself allowing "fluent" like uniform updates
  19144. */
  19145. setColor3(name: string, value: Color3): ShaderMaterial;
  19146. /**
  19147. * Set a vec3 array in the shader from a Color3 array.
  19148. * @param name Define the name of the uniform as defined in the shader
  19149. * @param value Define the value to give to the uniform
  19150. * @return the material itself allowing "fluent" like uniform updates
  19151. */
  19152. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19153. /**
  19154. * Set a vec4 in the shader from a Color4.
  19155. * @param name Define the name of the uniform as defined in the shader
  19156. * @param value Define the value to give to the uniform
  19157. * @return the material itself allowing "fluent" like uniform updates
  19158. */
  19159. setColor4(name: string, value: Color4): ShaderMaterial;
  19160. /**
  19161. * Set a vec2 in the shader from a Vector2.
  19162. * @param name Define the name of the uniform as defined in the shader
  19163. * @param value Define the value to give to the uniform
  19164. * @return the material itself allowing "fluent" like uniform updates
  19165. */
  19166. setVector2(name: string, value: Vector2): ShaderMaterial;
  19167. /**
  19168. * Set a vec3 in the shader from a Vector3.
  19169. * @param name Define the name of the uniform as defined in the shader
  19170. * @param value Define the value to give to the uniform
  19171. * @return the material itself allowing "fluent" like uniform updates
  19172. */
  19173. setVector3(name: string, value: Vector3): ShaderMaterial;
  19174. /**
  19175. * Set a vec4 in the shader from a Vector4.
  19176. * @param name Define the name of the uniform as defined in the shader
  19177. * @param value Define the value to give to the uniform
  19178. * @return the material itself allowing "fluent" like uniform updates
  19179. */
  19180. setVector4(name: string, value: Vector4): ShaderMaterial;
  19181. /**
  19182. * Set a mat4 in the shader from a Matrix.
  19183. * @param name Define the name of the uniform as defined in the shader
  19184. * @param value Define the value to give to the uniform
  19185. * @return the material itself allowing "fluent" like uniform updates
  19186. */
  19187. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19188. /**
  19189. * Set a mat3 in the shader from a Float32Array.
  19190. * @param name Define the name of the uniform as defined in the shader
  19191. * @param value Define the value to give to the uniform
  19192. * @return the material itself allowing "fluent" like uniform updates
  19193. */
  19194. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19195. /**
  19196. * Set a mat2 in the shader from a Float32Array.
  19197. * @param name Define the name of the uniform as defined in the shader
  19198. * @param value Define the value to give to the uniform
  19199. * @return the material itself allowing "fluent" like uniform updates
  19200. */
  19201. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19202. /**
  19203. * Set a vec2 array in the shader from a number array.
  19204. * @param name Define the name of the uniform as defined in the shader
  19205. * @param value Define the value to give to the uniform
  19206. * @return the material itself allowing "fluent" like uniform updates
  19207. */
  19208. setArray2(name: string, value: number[]): ShaderMaterial;
  19209. /**
  19210. * Set a vec3 array in the shader from a number array.
  19211. * @param name Define the name of the uniform as defined in the shader
  19212. * @param value Define the value to give to the uniform
  19213. * @return the material itself allowing "fluent" like uniform updates
  19214. */
  19215. setArray3(name: string, value: number[]): ShaderMaterial;
  19216. private _checkCache;
  19217. /**
  19218. * Checks if the material is ready to render the requested mesh
  19219. * @param mesh Define the mesh to render
  19220. * @param useInstances Define whether or not the material is used with instances
  19221. * @returns true if ready, otherwise false
  19222. */
  19223. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19224. /**
  19225. * Binds the world matrix to the material
  19226. * @param world defines the world transformation matrix
  19227. */
  19228. bindOnlyWorldMatrix(world: Matrix): void;
  19229. /**
  19230. * Binds the material to the mesh
  19231. * @param world defines the world transformation matrix
  19232. * @param mesh defines the mesh to bind the material to
  19233. */
  19234. bind(world: Matrix, mesh?: Mesh): void;
  19235. /**
  19236. * Gets the active textures from the material
  19237. * @returns an array of textures
  19238. */
  19239. getActiveTextures(): BaseTexture[];
  19240. /**
  19241. * Specifies if the material uses a texture
  19242. * @param texture defines the texture to check against the material
  19243. * @returns a boolean specifying if the material uses the texture
  19244. */
  19245. hasTexture(texture: BaseTexture): boolean;
  19246. /**
  19247. * Makes a duplicate of the material, and gives it a new name
  19248. * @param name defines the new name for the duplicated material
  19249. * @returns the cloned material
  19250. */
  19251. clone(name: string): ShaderMaterial;
  19252. /**
  19253. * Disposes the material
  19254. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19255. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19256. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19257. */
  19258. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19259. /**
  19260. * Serializes this material in a JSON representation
  19261. * @returns the serialized material object
  19262. */
  19263. serialize(): any;
  19264. /**
  19265. * Creates a shader material from parsed shader material data
  19266. * @param source defines the JSON represnetation of the material
  19267. * @param scene defines the hosting scene
  19268. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19269. * @returns a new material
  19270. */
  19271. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19272. }
  19273. }
  19274. declare module BABYLON {
  19275. /** @hidden */
  19276. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  19277. MAINUV1: boolean;
  19278. MAINUV2: boolean;
  19279. DIFFUSE: boolean;
  19280. DIFFUSEDIRECTUV: number;
  19281. AMBIENT: boolean;
  19282. AMBIENTDIRECTUV: number;
  19283. OPACITY: boolean;
  19284. OPACITYDIRECTUV: number;
  19285. OPACITYRGB: boolean;
  19286. REFLECTION: boolean;
  19287. EMISSIVE: boolean;
  19288. EMISSIVEDIRECTUV: number;
  19289. SPECULAR: boolean;
  19290. SPECULARDIRECTUV: number;
  19291. BUMP: boolean;
  19292. BUMPDIRECTUV: number;
  19293. PARALLAX: boolean;
  19294. PARALLAXOCCLUSION: boolean;
  19295. SPECULAROVERALPHA: boolean;
  19296. CLIPPLANE: boolean;
  19297. CLIPPLANE2: boolean;
  19298. CLIPPLANE3: boolean;
  19299. CLIPPLANE4: boolean;
  19300. ALPHATEST: boolean;
  19301. DEPTHPREPASS: boolean;
  19302. ALPHAFROMDIFFUSE: boolean;
  19303. POINTSIZE: boolean;
  19304. FOG: boolean;
  19305. SPECULARTERM: boolean;
  19306. DIFFUSEFRESNEL: boolean;
  19307. OPACITYFRESNEL: boolean;
  19308. REFLECTIONFRESNEL: boolean;
  19309. REFRACTIONFRESNEL: boolean;
  19310. EMISSIVEFRESNEL: boolean;
  19311. FRESNEL: boolean;
  19312. NORMAL: boolean;
  19313. UV1: boolean;
  19314. UV2: boolean;
  19315. VERTEXCOLOR: boolean;
  19316. VERTEXALPHA: boolean;
  19317. NUM_BONE_INFLUENCERS: number;
  19318. BonesPerMesh: number;
  19319. BONETEXTURE: boolean;
  19320. INSTANCES: boolean;
  19321. GLOSSINESS: boolean;
  19322. ROUGHNESS: boolean;
  19323. EMISSIVEASILLUMINATION: boolean;
  19324. LINKEMISSIVEWITHDIFFUSE: boolean;
  19325. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19326. LIGHTMAP: boolean;
  19327. LIGHTMAPDIRECTUV: number;
  19328. OBJECTSPACE_NORMALMAP: boolean;
  19329. USELIGHTMAPASSHADOWMAP: boolean;
  19330. REFLECTIONMAP_3D: boolean;
  19331. REFLECTIONMAP_SPHERICAL: boolean;
  19332. REFLECTIONMAP_PLANAR: boolean;
  19333. REFLECTIONMAP_CUBIC: boolean;
  19334. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19335. REFLECTIONMAP_PROJECTION: boolean;
  19336. REFLECTIONMAP_SKYBOX: boolean;
  19337. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  19338. REFLECTIONMAP_EXPLICIT: boolean;
  19339. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19340. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19341. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19342. INVERTCUBICMAP: boolean;
  19343. LOGARITHMICDEPTH: boolean;
  19344. REFRACTION: boolean;
  19345. REFRACTIONMAP_3D: boolean;
  19346. REFLECTIONOVERALPHA: boolean;
  19347. TWOSIDEDLIGHTING: boolean;
  19348. SHADOWFLOAT: boolean;
  19349. MORPHTARGETS: boolean;
  19350. MORPHTARGETS_NORMAL: boolean;
  19351. MORPHTARGETS_TANGENT: boolean;
  19352. NUM_MORPH_INFLUENCERS: number;
  19353. NONUNIFORMSCALING: boolean;
  19354. PREMULTIPLYALPHA: boolean;
  19355. IMAGEPROCESSING: boolean;
  19356. VIGNETTE: boolean;
  19357. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19358. VIGNETTEBLENDMODEOPAQUE: boolean;
  19359. TONEMAPPING: boolean;
  19360. TONEMAPPING_ACES: boolean;
  19361. CONTRAST: boolean;
  19362. COLORCURVES: boolean;
  19363. COLORGRADING: boolean;
  19364. COLORGRADING3D: boolean;
  19365. SAMPLER3DGREENDEPTH: boolean;
  19366. SAMPLER3DBGRMAP: boolean;
  19367. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19368. /**
  19369. * If the reflection texture on this material is in linear color space
  19370. * @hidden
  19371. */
  19372. IS_REFLECTION_LINEAR: boolean;
  19373. /**
  19374. * If the refraction texture on this material is in linear color space
  19375. * @hidden
  19376. */
  19377. IS_REFRACTION_LINEAR: boolean;
  19378. EXPOSURE: boolean;
  19379. constructor();
  19380. setReflectionMode(modeToEnable: string): void;
  19381. }
  19382. /**
  19383. * This is the default material used in Babylon. It is the best trade off between quality
  19384. * and performances.
  19385. * @see http://doc.babylonjs.com/babylon101/materials
  19386. */
  19387. class StandardMaterial extends PushMaterial {
  19388. private _diffuseTexture;
  19389. /**
  19390. * The basic texture of the material as viewed under a light.
  19391. */
  19392. diffuseTexture: Nullable<BaseTexture>;
  19393. private _ambientTexture;
  19394. /**
  19395. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19396. */
  19397. ambientTexture: Nullable<BaseTexture>;
  19398. private _opacityTexture;
  19399. /**
  19400. * Define the transparency of the material from a texture.
  19401. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19402. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19403. */
  19404. opacityTexture: Nullable<BaseTexture>;
  19405. private _reflectionTexture;
  19406. /**
  19407. * Define the texture used to display the reflection.
  19408. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19409. */
  19410. reflectionTexture: Nullable<BaseTexture>;
  19411. private _emissiveTexture;
  19412. /**
  19413. * Define texture of the material as if self lit.
  19414. * This will be mixed in the final result even in the absence of light.
  19415. */
  19416. emissiveTexture: Nullable<BaseTexture>;
  19417. private _specularTexture;
  19418. /**
  19419. * Define how the color and intensity of the highlight given by the light in the material.
  19420. */
  19421. specularTexture: Nullable<BaseTexture>;
  19422. private _bumpTexture;
  19423. /**
  19424. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19425. * 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.
  19426. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  19427. */
  19428. bumpTexture: Nullable<BaseTexture>;
  19429. private _lightmapTexture;
  19430. /**
  19431. * Complex lighting can be computationally expensive to compute at runtime.
  19432. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19433. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  19434. */
  19435. lightmapTexture: Nullable<BaseTexture>;
  19436. private _refractionTexture;
  19437. /**
  19438. * Define the texture used to display the refraction.
  19439. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19440. */
  19441. refractionTexture: Nullable<BaseTexture>;
  19442. /**
  19443. * The color of the material lit by the environmental background lighting.
  19444. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19445. */
  19446. ambientColor: Color3;
  19447. /**
  19448. * The basic color of the material as viewed under a light.
  19449. */
  19450. diffuseColor: Color3;
  19451. /**
  19452. * Define how the color and intensity of the highlight given by the light in the material.
  19453. */
  19454. specularColor: Color3;
  19455. /**
  19456. * Define the color of the material as if self lit.
  19457. * This will be mixed in the final result even in the absence of light.
  19458. */
  19459. emissiveColor: Color3;
  19460. /**
  19461. * Defines how sharp are the highlights in the material.
  19462. * The bigger the value the sharper giving a more glossy feeling to the result.
  19463. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19464. */
  19465. specularPower: number;
  19466. private _useAlphaFromDiffuseTexture;
  19467. /**
  19468. * Does the transparency come from the diffuse texture alpha channel.
  19469. */
  19470. useAlphaFromDiffuseTexture: boolean;
  19471. private _useEmissiveAsIllumination;
  19472. /**
  19473. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19474. */
  19475. useEmissiveAsIllumination: boolean;
  19476. private _linkEmissiveWithDiffuse;
  19477. /**
  19478. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19479. * the emissive level when the final color is close to one.
  19480. */
  19481. linkEmissiveWithDiffuse: boolean;
  19482. private _useSpecularOverAlpha;
  19483. /**
  19484. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19485. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19486. */
  19487. useSpecularOverAlpha: boolean;
  19488. private _useReflectionOverAlpha;
  19489. /**
  19490. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19491. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19492. */
  19493. useReflectionOverAlpha: boolean;
  19494. private _disableLighting;
  19495. /**
  19496. * Does lights from the scene impacts this material.
  19497. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19498. */
  19499. disableLighting: boolean;
  19500. private _useObjectSpaceNormalMap;
  19501. /**
  19502. * Allows using an object space normal map (instead of tangent space).
  19503. */
  19504. useObjectSpaceNormalMap: boolean;
  19505. private _useParallax;
  19506. /**
  19507. * Is parallax enabled or not.
  19508. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19509. */
  19510. useParallax: boolean;
  19511. private _useParallaxOcclusion;
  19512. /**
  19513. * Is parallax occlusion enabled or not.
  19514. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19515. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19516. */
  19517. useParallaxOcclusion: boolean;
  19518. /**
  19519. * 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.
  19520. */
  19521. parallaxScaleBias: number;
  19522. private _roughness;
  19523. /**
  19524. * Helps to define how blurry the reflections should appears in the material.
  19525. */
  19526. roughness: number;
  19527. /**
  19528. * In case of refraction, define the value of the indice of refraction.
  19529. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19530. */
  19531. indexOfRefraction: number;
  19532. /**
  19533. * Invert the refraction texture alongside the y axis.
  19534. * It can be useful with procedural textures or probe for instance.
  19535. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19536. */
  19537. invertRefractionY: boolean;
  19538. /**
  19539. * Defines the alpha limits in alpha test mode.
  19540. */
  19541. alphaCutOff: number;
  19542. private _useLightmapAsShadowmap;
  19543. /**
  19544. * In case of light mapping, define whether the map contains light or shadow informations.
  19545. */
  19546. useLightmapAsShadowmap: boolean;
  19547. private _diffuseFresnelParameters;
  19548. /**
  19549. * Define the diffuse fresnel parameters of the material.
  19550. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19551. */
  19552. diffuseFresnelParameters: FresnelParameters;
  19553. private _opacityFresnelParameters;
  19554. /**
  19555. * Define the opacity fresnel parameters of the material.
  19556. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19557. */
  19558. opacityFresnelParameters: FresnelParameters;
  19559. private _reflectionFresnelParameters;
  19560. /**
  19561. * Define the reflection fresnel parameters of the material.
  19562. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19563. */
  19564. reflectionFresnelParameters: FresnelParameters;
  19565. private _refractionFresnelParameters;
  19566. /**
  19567. * Define the refraction fresnel parameters of the material.
  19568. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19569. */
  19570. refractionFresnelParameters: FresnelParameters;
  19571. private _emissiveFresnelParameters;
  19572. /**
  19573. * Define the emissive fresnel parameters of the material.
  19574. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19575. */
  19576. emissiveFresnelParameters: FresnelParameters;
  19577. private _useReflectionFresnelFromSpecular;
  19578. /**
  19579. * If true automatically deducts the fresnels values from the material specularity.
  19580. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19581. */
  19582. useReflectionFresnelFromSpecular: boolean;
  19583. private _useGlossinessFromSpecularMapAlpha;
  19584. /**
  19585. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19586. */
  19587. useGlossinessFromSpecularMapAlpha: boolean;
  19588. private _maxSimultaneousLights;
  19589. /**
  19590. * Defines the maximum number of lights that can be used in the material
  19591. */
  19592. maxSimultaneousLights: number;
  19593. private _invertNormalMapX;
  19594. /**
  19595. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19596. */
  19597. invertNormalMapX: boolean;
  19598. private _invertNormalMapY;
  19599. /**
  19600. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19601. */
  19602. invertNormalMapY: boolean;
  19603. private _twoSidedLighting;
  19604. /**
  19605. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19606. */
  19607. twoSidedLighting: boolean;
  19608. /**
  19609. * Default configuration related to image processing available in the standard Material.
  19610. */
  19611. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19612. /**
  19613. * Gets the image processing configuration used either in this material.
  19614. */
  19615. /**
  19616. * Sets the Default image processing configuration used either in the this material.
  19617. *
  19618. * If sets to null, the scene one is in use.
  19619. */
  19620. imageProcessingConfiguration: ImageProcessingConfiguration;
  19621. /**
  19622. * Keep track of the image processing observer to allow dispose and replace.
  19623. */
  19624. private _imageProcessingObserver;
  19625. /**
  19626. * Attaches a new image processing configuration to the Standard Material.
  19627. * @param configuration
  19628. */
  19629. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19630. /**
  19631. * Gets wether the color curves effect is enabled.
  19632. */
  19633. /**
  19634. * Sets wether the color curves effect is enabled.
  19635. */
  19636. cameraColorCurvesEnabled: boolean;
  19637. /**
  19638. * Gets wether the color grading effect is enabled.
  19639. */
  19640. /**
  19641. * Gets wether the color grading effect is enabled.
  19642. */
  19643. cameraColorGradingEnabled: boolean;
  19644. /**
  19645. * Gets wether tonemapping is enabled or not.
  19646. */
  19647. /**
  19648. * Sets wether tonemapping is enabled or not
  19649. */
  19650. cameraToneMappingEnabled: boolean;
  19651. /**
  19652. * The camera exposure used on this material.
  19653. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19654. * This corresponds to a photographic exposure.
  19655. */
  19656. /**
  19657. * The camera exposure used on this material.
  19658. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19659. * This corresponds to a photographic exposure.
  19660. */
  19661. cameraExposure: number;
  19662. /**
  19663. * Gets The camera contrast used on this material.
  19664. */
  19665. /**
  19666. * Sets The camera contrast used on this material.
  19667. */
  19668. cameraContrast: number;
  19669. /**
  19670. * Gets the Color Grading 2D Lookup Texture.
  19671. */
  19672. /**
  19673. * Sets the Color Grading 2D Lookup Texture.
  19674. */
  19675. cameraColorGradingTexture: Nullable<BaseTexture>;
  19676. /**
  19677. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19678. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19679. * 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;
  19680. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19681. */
  19682. /**
  19683. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19684. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19685. * 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;
  19686. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19687. */
  19688. cameraColorCurves: Nullable<ColorCurves>;
  19689. /**
  19690. * Custom callback helping to override the default shader used in the material.
  19691. */
  19692. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  19693. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19694. protected _worldViewProjectionMatrix: Matrix;
  19695. protected _globalAmbientColor: Color3;
  19696. protected _useLogarithmicDepth: boolean;
  19697. /**
  19698. * Instantiates a new standard material.
  19699. * This is the default material used in Babylon. It is the best trade off between quality
  19700. * and performances.
  19701. * @see http://doc.babylonjs.com/babylon101/materials
  19702. * @param name Define the name of the material in the scene
  19703. * @param scene Define the scene the material belong to
  19704. */
  19705. constructor(name: string, scene: Scene);
  19706. /**
  19707. * Gets a boolean indicating that current material needs to register RTT
  19708. */
  19709. readonly hasRenderTargetTextures: boolean;
  19710. /**
  19711. * Gets the current class name of the material e.g. "StandardMaterial"
  19712. * Mainly use in serialization.
  19713. * @returns the class name
  19714. */
  19715. getClassName(): string;
  19716. /**
  19717. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19718. * You can try switching to logarithmic depth.
  19719. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19720. */
  19721. useLogarithmicDepth: boolean;
  19722. /**
  19723. * Specifies if the material will require alpha blending
  19724. * @returns a boolean specifying if alpha blending is needed
  19725. */
  19726. needAlphaBlending(): boolean;
  19727. /**
  19728. * Specifies if this material should be rendered in alpha test mode
  19729. * @returns a boolean specifying if an alpha test is needed.
  19730. */
  19731. needAlphaTesting(): boolean;
  19732. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19733. /**
  19734. * Get the texture used for alpha test purpose.
  19735. * @returns the diffuse texture in case of the standard material.
  19736. */
  19737. getAlphaTestTexture(): Nullable<BaseTexture>;
  19738. /**
  19739. * Get if the submesh is ready to be used and all its information available.
  19740. * Child classes can use it to update shaders
  19741. * @param mesh defines the mesh to check
  19742. * @param subMesh defines which submesh to check
  19743. * @param useInstances specifies that instances should be used
  19744. * @returns a boolean indicating that the submesh is ready or not
  19745. */
  19746. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19747. /**
  19748. * Builds the material UBO layouts.
  19749. * Used internally during the effect preparation.
  19750. */
  19751. buildUniformLayout(): void;
  19752. /**
  19753. * Unbinds the material from the mesh
  19754. */
  19755. unbind(): void;
  19756. /**
  19757. * Binds the submesh to this material by preparing the effect and shader to draw
  19758. * @param world defines the world transformation matrix
  19759. * @param mesh defines the mesh containing the submesh
  19760. * @param subMesh defines the submesh to bind the material to
  19761. */
  19762. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19763. /**
  19764. * Get the list of animatables in the material.
  19765. * @returns the list of animatables object used in the material
  19766. */
  19767. getAnimatables(): IAnimatable[];
  19768. /**
  19769. * Gets the active textures from the material
  19770. * @returns an array of textures
  19771. */
  19772. getActiveTextures(): BaseTexture[];
  19773. /**
  19774. * Specifies if the material uses a texture
  19775. * @param texture defines the texture to check against the material
  19776. * @returns a boolean specifying if the material uses the texture
  19777. */
  19778. hasTexture(texture: BaseTexture): boolean;
  19779. /**
  19780. * Disposes the material
  19781. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19782. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19783. */
  19784. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19785. /**
  19786. * Makes a duplicate of the material, and gives it a new name
  19787. * @param name defines the new name for the duplicated material
  19788. * @returns the cloned material
  19789. */
  19790. clone(name: string): StandardMaterial;
  19791. /**
  19792. * Serializes this material in a JSON representation
  19793. * @returns the serialized material object
  19794. */
  19795. serialize(): any;
  19796. /**
  19797. * Creates a standard material from parsed material data
  19798. * @param source defines the JSON represnetation of the material
  19799. * @param scene defines the hosting scene
  19800. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19801. * @returns a new material
  19802. */
  19803. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19804. private static _DiffuseTextureEnabled;
  19805. /**
  19806. * Are diffuse textures enabled in the application.
  19807. */
  19808. static DiffuseTextureEnabled: boolean;
  19809. private static _AmbientTextureEnabled;
  19810. /**
  19811. * Are ambient textures enabled in the application.
  19812. */
  19813. static AmbientTextureEnabled: boolean;
  19814. private static _OpacityTextureEnabled;
  19815. /**
  19816. * Are opacity textures enabled in the application.
  19817. */
  19818. static OpacityTextureEnabled: boolean;
  19819. private static _ReflectionTextureEnabled;
  19820. /**
  19821. * Are reflection textures enabled in the application.
  19822. */
  19823. static ReflectionTextureEnabled: boolean;
  19824. private static _EmissiveTextureEnabled;
  19825. /**
  19826. * Are emissive textures enabled in the application.
  19827. */
  19828. static EmissiveTextureEnabled: boolean;
  19829. private static _SpecularTextureEnabled;
  19830. /**
  19831. * Are specular textures enabled in the application.
  19832. */
  19833. static SpecularTextureEnabled: boolean;
  19834. private static _BumpTextureEnabled;
  19835. /**
  19836. * Are bump textures enabled in the application.
  19837. */
  19838. static BumpTextureEnabled: boolean;
  19839. private static _LightmapTextureEnabled;
  19840. /**
  19841. * Are lightmap textures enabled in the application.
  19842. */
  19843. static LightmapTextureEnabled: boolean;
  19844. private static _RefractionTextureEnabled;
  19845. /**
  19846. * Are refraction textures enabled in the application.
  19847. */
  19848. static RefractionTextureEnabled: boolean;
  19849. private static _ColorGradingTextureEnabled;
  19850. /**
  19851. * Are color grading textures enabled in the application.
  19852. */
  19853. static ColorGradingTextureEnabled: boolean;
  19854. private static _FresnelEnabled;
  19855. /**
  19856. * Are fresnels enabled in the application.
  19857. */
  19858. static FresnelEnabled: boolean;
  19859. }
  19860. }
  19861. declare module BABYLON {
  19862. /**
  19863. * Uniform buffer objects.
  19864. *
  19865. * Handles blocks of uniform on the GPU.
  19866. *
  19867. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19868. *
  19869. * For more information, please refer to :
  19870. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19871. */
  19872. class UniformBuffer {
  19873. private _engine;
  19874. private _buffer;
  19875. private _data;
  19876. private _bufferData;
  19877. private _dynamic?;
  19878. private _uniformLocations;
  19879. private _uniformSizes;
  19880. private _uniformLocationPointer;
  19881. private _needSync;
  19882. private _noUBO;
  19883. private _currentEffect;
  19884. private static _MAX_UNIFORM_SIZE;
  19885. private static _tempBuffer;
  19886. /**
  19887. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  19888. * This is dynamic to allow compat with webgl 1 and 2.
  19889. * You will need to pass the name of the uniform as well as the value.
  19890. */
  19891. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  19892. /**
  19893. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  19894. * This is dynamic to allow compat with webgl 1 and 2.
  19895. * You will need to pass the name of the uniform as well as the value.
  19896. */
  19897. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  19898. /**
  19899. * Lambda to Update a single float in a uniform buffer.
  19900. * This is dynamic to allow compat with webgl 1 and 2.
  19901. * You will need to pass the name of the uniform as well as the value.
  19902. */
  19903. updateFloat: (name: string, x: number) => void;
  19904. /**
  19905. * Lambda to Update a vec2 of float in a uniform buffer.
  19906. * This is dynamic to allow compat with webgl 1 and 2.
  19907. * You will need to pass the name of the uniform as well as the value.
  19908. */
  19909. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  19910. /**
  19911. * Lambda to Update a vec3 of float in a uniform buffer.
  19912. * This is dynamic to allow compat with webgl 1 and 2.
  19913. * You will need to pass the name of the uniform as well as the value.
  19914. */
  19915. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  19916. /**
  19917. * Lambda to Update a vec4 of float in a uniform buffer.
  19918. * This is dynamic to allow compat with webgl 1 and 2.
  19919. * You will need to pass the name of the uniform as well as the value.
  19920. */
  19921. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  19922. /**
  19923. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  19924. * This is dynamic to allow compat with webgl 1 and 2.
  19925. * You will need to pass the name of the uniform as well as the value.
  19926. */
  19927. updateMatrix: (name: string, mat: Matrix) => void;
  19928. /**
  19929. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  19930. * This is dynamic to allow compat with webgl 1 and 2.
  19931. * You will need to pass the name of the uniform as well as the value.
  19932. */
  19933. updateVector3: (name: string, vector: Vector3) => void;
  19934. /**
  19935. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  19936. * This is dynamic to allow compat with webgl 1 and 2.
  19937. * You will need to pass the name of the uniform as well as the value.
  19938. */
  19939. updateVector4: (name: string, vector: Vector4) => void;
  19940. /**
  19941. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  19942. * This is dynamic to allow compat with webgl 1 and 2.
  19943. * You will need to pass the name of the uniform as well as the value.
  19944. */
  19945. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  19946. /**
  19947. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  19948. * This is dynamic to allow compat with webgl 1 and 2.
  19949. * You will need to pass the name of the uniform as well as the value.
  19950. */
  19951. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  19952. /**
  19953. * Instantiates a new Uniform buffer objects.
  19954. *
  19955. * Handles blocks of uniform on the GPU.
  19956. *
  19957. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19958. *
  19959. * For more information, please refer to :
  19960. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19961. * @param engine Define the engine the buffer is associated with
  19962. * @param data Define the data contained in the buffer
  19963. * @param dynamic Define if the buffer is updatable
  19964. */
  19965. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  19966. /**
  19967. * Indicates if the buffer is using the WebGL2 UBO implementation,
  19968. * or just falling back on setUniformXXX calls.
  19969. */
  19970. readonly useUbo: boolean;
  19971. /**
  19972. * Indicates if the WebGL underlying uniform buffer is in sync
  19973. * with the javascript cache data.
  19974. */
  19975. readonly isSync: boolean;
  19976. /**
  19977. * Indicates if the WebGL underlying uniform buffer is dynamic.
  19978. * Also, a dynamic UniformBuffer will disable cache verification and always
  19979. * update the underlying WebGL uniform buffer to the GPU.
  19980. * @returns if Dynamic, otherwise false
  19981. */
  19982. isDynamic(): boolean;
  19983. /**
  19984. * The data cache on JS side.
  19985. * @returns the underlying data as a float array
  19986. */
  19987. getData(): Float32Array;
  19988. /**
  19989. * The underlying WebGL Uniform buffer.
  19990. * @returns the webgl buffer
  19991. */
  19992. getBuffer(): Nullable<WebGLBuffer>;
  19993. /**
  19994. * std140 layout specifies how to align data within an UBO structure.
  19995. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  19996. * for specs.
  19997. */
  19998. private _fillAlignment;
  19999. /**
  20000. * Adds an uniform in the buffer.
  20001. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  20002. * for the layout to be correct !
  20003. * @param name Name of the uniform, as used in the uniform block in the shader.
  20004. * @param size Data size, or data directly.
  20005. */
  20006. addUniform(name: string, size: number | number[]): void;
  20007. /**
  20008. * Adds a Matrix 4x4 to the uniform buffer.
  20009. * @param name Name of the uniform, as used in the uniform block in the shader.
  20010. * @param mat A 4x4 matrix.
  20011. */
  20012. addMatrix(name: string, mat: Matrix): void;
  20013. /**
  20014. * Adds a vec2 to the uniform buffer.
  20015. * @param name Name of the uniform, as used in the uniform block in the shader.
  20016. * @param x Define the x component value of the vec2
  20017. * @param y Define the y component value of the vec2
  20018. */
  20019. addFloat2(name: string, x: number, y: number): void;
  20020. /**
  20021. * Adds a vec3 to the uniform buffer.
  20022. * @param name Name of the uniform, as used in the uniform block in the shader.
  20023. * @param x Define the x component value of the vec3
  20024. * @param y Define the y component value of the vec3
  20025. * @param z Define the z component value of the vec3
  20026. */
  20027. addFloat3(name: string, x: number, y: number, z: number): void;
  20028. /**
  20029. * Adds a vec3 to the uniform buffer.
  20030. * @param name Name of the uniform, as used in the uniform block in the shader.
  20031. * @param color Define the vec3 from a Color
  20032. */
  20033. addColor3(name: string, color: Color3): void;
  20034. /**
  20035. * Adds a vec4 to the uniform buffer.
  20036. * @param name Name of the uniform, as used in the uniform block in the shader.
  20037. * @param color Define the rgb components from a Color
  20038. * @param alpha Define the a component of the vec4
  20039. */
  20040. addColor4(name: string, color: Color3, alpha: number): void;
  20041. /**
  20042. * Adds a vec3 to the uniform buffer.
  20043. * @param name Name of the uniform, as used in the uniform block in the shader.
  20044. * @param vector Define the vec3 components from a Vector
  20045. */
  20046. addVector3(name: string, vector: Vector3): void;
  20047. /**
  20048. * Adds a Matrix 3x3 to the uniform buffer.
  20049. * @param name Name of the uniform, as used in the uniform block in the shader.
  20050. */
  20051. addMatrix3x3(name: string): void;
  20052. /**
  20053. * Adds a Matrix 2x2 to the uniform buffer.
  20054. * @param name Name of the uniform, as used in the uniform block in the shader.
  20055. */
  20056. addMatrix2x2(name: string): void;
  20057. /**
  20058. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  20059. */
  20060. create(): void;
  20061. /** @hidden */
  20062. _rebuild(): void;
  20063. /**
  20064. * Updates the WebGL Uniform Buffer on the GPU.
  20065. * If the `dynamic` flag is set to true, no cache comparison is done.
  20066. * Otherwise, the buffer will be updated only if the cache differs.
  20067. */
  20068. update(): void;
  20069. /**
  20070. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  20071. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  20072. * @param data Define the flattened data
  20073. * @param size Define the size of the data.
  20074. */
  20075. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  20076. private _updateMatrix3x3ForUniform;
  20077. private _updateMatrix3x3ForEffect;
  20078. private _updateMatrix2x2ForEffect;
  20079. private _updateMatrix2x2ForUniform;
  20080. private _updateFloatForEffect;
  20081. private _updateFloatForUniform;
  20082. private _updateFloat2ForEffect;
  20083. private _updateFloat2ForUniform;
  20084. private _updateFloat3ForEffect;
  20085. private _updateFloat3ForUniform;
  20086. private _updateFloat4ForEffect;
  20087. private _updateFloat4ForUniform;
  20088. private _updateMatrixForEffect;
  20089. private _updateMatrixForUniform;
  20090. private _updateVector3ForEffect;
  20091. private _updateVector3ForUniform;
  20092. private _updateVector4ForEffect;
  20093. private _updateVector4ForUniform;
  20094. private _updateColor3ForEffect;
  20095. private _updateColor3ForUniform;
  20096. private _updateColor4ForEffect;
  20097. private _updateColor4ForUniform;
  20098. /**
  20099. * Sets a sampler uniform on the effect.
  20100. * @param name Define the name of the sampler.
  20101. * @param texture Define the texture to set in the sampler
  20102. */
  20103. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  20104. /**
  20105. * Directly updates the value of the uniform in the cache AND on the GPU.
  20106. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  20107. * @param data Define the flattened data
  20108. */
  20109. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  20110. /**
  20111. * Binds this uniform buffer to an effect.
  20112. * @param effect Define the effect to bind the buffer to
  20113. * @param name Name of the uniform block in the shader.
  20114. */
  20115. bindToEffect(effect: Effect, name: string): void;
  20116. /**
  20117. * Disposes the uniform buffer.
  20118. */
  20119. dispose(): void;
  20120. }
  20121. }
  20122. declare module BABYLON {
  20123. /**
  20124. * Scalar computation library
  20125. */
  20126. class Scalar {
  20127. /**
  20128. * Two pi constants convenient for computation.
  20129. */
  20130. static TwoPi: number;
  20131. /**
  20132. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  20133. * @param a number
  20134. * @param b number
  20135. * @param epsilon (default = 1.401298E-45)
  20136. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  20137. */
  20138. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  20139. /**
  20140. * Returns a string : the upper case translation of the number i to hexadecimal.
  20141. * @param i number
  20142. * @returns the upper case translation of the number i to hexadecimal.
  20143. */
  20144. static ToHex(i: number): string;
  20145. /**
  20146. * Returns -1 if value is negative and +1 is value is positive.
  20147. * @param value the value
  20148. * @returns the value itself if it's equal to zero.
  20149. */
  20150. static Sign(value: number): number;
  20151. /**
  20152. * Returns the value itself if it's between min and max.
  20153. * Returns min if the value is lower than min.
  20154. * Returns max if the value is greater than max.
  20155. * @param value the value to clmap
  20156. * @param min the min value to clamp to (default: 0)
  20157. * @param max the max value to clamp to (default: 1)
  20158. * @returns the clamped value
  20159. */
  20160. static Clamp(value: number, min?: number, max?: number): number;
  20161. /**
  20162. * the log2 of value.
  20163. * @param value the value to compute log2 of
  20164. * @returns the log2 of value.
  20165. */
  20166. static Log2(value: number): number;
  20167. /**
  20168. * Loops the value, so that it is never larger than length and never smaller than 0.
  20169. *
  20170. * This is similar to the modulo operator but it works with floating point numbers.
  20171. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  20172. * With t = 5 and length = 2.5, the result would be 0.0.
  20173. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  20174. * @param value the value
  20175. * @param length the length
  20176. * @returns the looped value
  20177. */
  20178. static Repeat(value: number, length: number): number;
  20179. /**
  20180. * Normalize the value between 0.0 and 1.0 using min and max values
  20181. * @param value value to normalize
  20182. * @param min max to normalize between
  20183. * @param max min to normalize between
  20184. * @returns the normalized value
  20185. */
  20186. static Normalize(value: number, min: number, max: number): number;
  20187. /**
  20188. * Denormalize the value from 0.0 and 1.0 using min and max values
  20189. * @param normalized value to denormalize
  20190. * @param min max to denormalize between
  20191. * @param max min to denormalize between
  20192. * @returns the denormalized value
  20193. */
  20194. static Denormalize(normalized: number, min: number, max: number): number;
  20195. /**
  20196. * Calculates the shortest difference between two given angles given in degrees.
  20197. * @param current current angle in degrees
  20198. * @param target target angle in degrees
  20199. * @returns the delta
  20200. */
  20201. static DeltaAngle(current: number, target: number): number;
  20202. /**
  20203. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  20204. * @param tx value
  20205. * @param length length
  20206. * @returns The returned value will move back and forth between 0 and length
  20207. */
  20208. static PingPong(tx: number, length: number): number;
  20209. /**
  20210. * Interpolates between min and max with smoothing at the limits.
  20211. *
  20212. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  20213. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  20214. * @param from from
  20215. * @param to to
  20216. * @param tx value
  20217. * @returns the smooth stepped value
  20218. */
  20219. static SmoothStep(from: number, to: number, tx: number): number;
  20220. /**
  20221. * Moves a value current towards target.
  20222. *
  20223. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  20224. * Negative values of maxDelta pushes the value away from target.
  20225. * @param current current value
  20226. * @param target target value
  20227. * @param maxDelta max distance to move
  20228. * @returns resulting value
  20229. */
  20230. static MoveTowards(current: number, target: number, maxDelta: number): number;
  20231. /**
  20232. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  20233. *
  20234. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  20235. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  20236. * @param current current value
  20237. * @param target target value
  20238. * @param maxDelta max distance to move
  20239. * @returns resulting angle
  20240. */
  20241. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  20242. /**
  20243. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  20244. * @param start start value
  20245. * @param end target value
  20246. * @param amount amount to lerp between
  20247. * @returns the lerped value
  20248. */
  20249. static Lerp(start: number, end: number, amount: number): number;
  20250. /**
  20251. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  20252. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  20253. * @param start start value
  20254. * @param end target value
  20255. * @param amount amount to lerp between
  20256. * @returns the lerped value
  20257. */
  20258. static LerpAngle(start: number, end: number, amount: number): number;
  20259. /**
  20260. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  20261. * @param a start value
  20262. * @param b target value
  20263. * @param value value between a and b
  20264. * @returns the inverseLerp value
  20265. */
  20266. static InverseLerp(a: number, b: number, value: number): number;
  20267. /**
  20268. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  20269. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  20270. * @param value1 spline value
  20271. * @param tangent1 spline value
  20272. * @param value2 spline value
  20273. * @param tangent2 spline value
  20274. * @param amount input value
  20275. * @returns hermite result
  20276. */
  20277. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  20278. /**
  20279. * Returns a random float number between and min and max values
  20280. * @param min min value of random
  20281. * @param max max value of random
  20282. * @returns random value
  20283. */
  20284. static RandomRange(min: number, max: number): number;
  20285. /**
  20286. * This function returns percentage of a number in a given range.
  20287. *
  20288. * RangeToPercent(40,20,60) will return 0.5 (50%)
  20289. * RangeToPercent(34,0,100) will return 0.34 (34%)
  20290. * @param number to convert to percentage
  20291. * @param min min range
  20292. * @param max max range
  20293. * @returns the percentage
  20294. */
  20295. static RangeToPercent(number: number, min: number, max: number): number;
  20296. /**
  20297. * This function returns number that corresponds to the percentage in a given range.
  20298. *
  20299. * PercentToRange(0.34,0,100) will return 34.
  20300. * @param percent to convert to number
  20301. * @param min min range
  20302. * @param max max range
  20303. * @returns the number
  20304. */
  20305. static PercentToRange(percent: number, min: number, max: number): number;
  20306. /**
  20307. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  20308. * @param angle The angle to normalize in radian.
  20309. * @return The converted angle.
  20310. */
  20311. static NormalizeRadians(angle: number): number;
  20312. }
  20313. }
  20314. declare module BABYLON {
  20315. /**
  20316. * Constant used to convert a value to gamma space
  20317. * @ignorenaming
  20318. */
  20319. const ToGammaSpace: number;
  20320. /**
  20321. * Constant used to convert a value to linear space
  20322. * @ignorenaming
  20323. */
  20324. const ToLinearSpace = 2.2;
  20325. /**
  20326. * Constant used to define the minimal number value in Babylon.js
  20327. * @ignorenaming
  20328. */
  20329. const Epsilon = 0.001;
  20330. /**
  20331. * Class used to hold a RBG color
  20332. */
  20333. class Color3 {
  20334. /**
  20335. * Defines the red component (between 0 and 1, default is 0)
  20336. */
  20337. r: number;
  20338. /**
  20339. * Defines the green component (between 0 and 1, default is 0)
  20340. */
  20341. g: number;
  20342. /**
  20343. * Defines the blue component (between 0 and 1, default is 0)
  20344. */
  20345. b: number;
  20346. /**
  20347. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  20348. * @param r defines the red component (between 0 and 1, default is 0)
  20349. * @param g defines the green component (between 0 and 1, default is 0)
  20350. * @param b defines the blue component (between 0 and 1, default is 0)
  20351. */
  20352. constructor(
  20353. /**
  20354. * Defines the red component (between 0 and 1, default is 0)
  20355. */
  20356. r?: number,
  20357. /**
  20358. * Defines the green component (between 0 and 1, default is 0)
  20359. */
  20360. g?: number,
  20361. /**
  20362. * Defines the blue component (between 0 and 1, default is 0)
  20363. */
  20364. b?: number);
  20365. /**
  20366. * Creates a string with the Color3 current values
  20367. * @returns the string representation of the Color3 object
  20368. */
  20369. toString(): string;
  20370. /**
  20371. * Returns the string "Color3"
  20372. * @returns "Color3"
  20373. */
  20374. getClassName(): string;
  20375. /**
  20376. * Compute the Color3 hash code
  20377. * @returns an unique number that can be used to hash Color3 objects
  20378. */
  20379. getHashCode(): number;
  20380. /**
  20381. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  20382. * @param array defines the array where to store the r,g,b components
  20383. * @param index defines an optional index in the target array to define where to start storing values
  20384. * @returns the current Color3 object
  20385. */
  20386. toArray(array: FloatArray, index?: number): Color3;
  20387. /**
  20388. * Returns a new Color4 object from the current Color3 and the given alpha
  20389. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  20390. * @returns a new Color4 object
  20391. */
  20392. toColor4(alpha?: number): Color4;
  20393. /**
  20394. * Returns a new array populated with 3 numeric elements : red, green and blue values
  20395. * @returns the new array
  20396. */
  20397. asArray(): number[];
  20398. /**
  20399. * Returns the luminance value
  20400. * @returns a float value
  20401. */
  20402. toLuminance(): number;
  20403. /**
  20404. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  20405. * @param otherColor defines the second operand
  20406. * @returns the new Color3 object
  20407. */
  20408. multiply(otherColor: DeepImmutable<Color3>): Color3;
  20409. /**
  20410. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  20411. * @param otherColor defines the second operand
  20412. * @param result defines the Color3 object where to store the result
  20413. * @returns the current Color3
  20414. */
  20415. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20416. /**
  20417. * Determines equality between Color3 objects
  20418. * @param otherColor defines the second operand
  20419. * @returns true if the rgb values are equal to the given ones
  20420. */
  20421. equals(otherColor: DeepImmutable<Color3>): boolean;
  20422. /**
  20423. * Determines equality between the current Color3 object and a set of r,b,g values
  20424. * @param r defines the red component to check
  20425. * @param g defines the green component to check
  20426. * @param b defines the blue component to check
  20427. * @returns true if the rgb values are equal to the given ones
  20428. */
  20429. equalsFloats(r: number, g: number, b: number): boolean;
  20430. /**
  20431. * Multiplies in place each rgb value by scale
  20432. * @param scale defines the scaling factor
  20433. * @returns the updated Color3
  20434. */
  20435. scale(scale: number): Color3;
  20436. /**
  20437. * Multiplies the rgb values by scale and stores the result into "result"
  20438. * @param scale defines the scaling factor
  20439. * @param result defines the Color3 object where to store the result
  20440. * @returns the unmodified current Color3
  20441. */
  20442. scaleToRef(scale: number, result: Color3): Color3;
  20443. /**
  20444. * Scale the current Color3 values by a factor and add the result to a given Color3
  20445. * @param scale defines the scale factor
  20446. * @param result defines color to store the result into
  20447. * @returns the unmodified current Color3
  20448. */
  20449. scaleAndAddToRef(scale: number, result: Color3): Color3;
  20450. /**
  20451. * Clamps the rgb values by the min and max values and stores the result into "result"
  20452. * @param min defines minimum clamping value (default is 0)
  20453. * @param max defines maximum clamping value (default is 1)
  20454. * @param result defines color to store the result into
  20455. * @returns the original Color3
  20456. */
  20457. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  20458. /**
  20459. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  20460. * @param otherColor defines the second operand
  20461. * @returns the new Color3
  20462. */
  20463. add(otherColor: DeepImmutable<Color3>): Color3;
  20464. /**
  20465. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  20466. * @param otherColor defines the second operand
  20467. * @param result defines Color3 object to store the result into
  20468. * @returns the unmodified current Color3
  20469. */
  20470. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20471. /**
  20472. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  20473. * @param otherColor defines the second operand
  20474. * @returns the new Color3
  20475. */
  20476. subtract(otherColor: DeepImmutable<Color3>): Color3;
  20477. /**
  20478. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  20479. * @param otherColor defines the second operand
  20480. * @param result defines Color3 object to store the result into
  20481. * @returns the unmodified current Color3
  20482. */
  20483. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20484. /**
  20485. * Copy the current object
  20486. * @returns a new Color3 copied the current one
  20487. */
  20488. clone(): Color3;
  20489. /**
  20490. * Copies the rgb values from the source in the current Color3
  20491. * @param source defines the source Color3 object
  20492. * @returns the updated Color3 object
  20493. */
  20494. copyFrom(source: DeepImmutable<Color3>): Color3;
  20495. /**
  20496. * Updates the Color3 rgb values from the given floats
  20497. * @param r defines the red component to read from
  20498. * @param g defines the green component to read from
  20499. * @param b defines the blue component to read from
  20500. * @returns the current Color3 object
  20501. */
  20502. copyFromFloats(r: number, g: number, b: number): Color3;
  20503. /**
  20504. * Updates the Color3 rgb values from the given floats
  20505. * @param r defines the red component to read from
  20506. * @param g defines the green component to read from
  20507. * @param b defines the blue component to read from
  20508. * @returns the current Color3 object
  20509. */
  20510. set(r: number, g: number, b: number): Color3;
  20511. /**
  20512. * Compute the Color3 hexadecimal code as a string
  20513. * @returns a string containing the hexadecimal representation of the Color3 object
  20514. */
  20515. toHexString(): string;
  20516. /**
  20517. * Computes a new Color3 converted from the current one to linear space
  20518. * @returns a new Color3 object
  20519. */
  20520. toLinearSpace(): Color3;
  20521. /**
  20522. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  20523. * @param convertedColor defines the Color3 object where to store the linear space version
  20524. * @returns the unmodified Color3
  20525. */
  20526. toLinearSpaceToRef(convertedColor: Color3): Color3;
  20527. /**
  20528. * Computes a new Color3 converted from the current one to gamma space
  20529. * @returns a new Color3 object
  20530. */
  20531. toGammaSpace(): Color3;
  20532. /**
  20533. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  20534. * @param convertedColor defines the Color3 object where to store the gamma space version
  20535. * @returns the unmodified Color3
  20536. */
  20537. toGammaSpaceToRef(convertedColor: Color3): Color3;
  20538. /**
  20539. * Creates a new Color3 from the string containing valid hexadecimal values
  20540. * @param hex defines a string containing valid hexadecimal values
  20541. * @returns a new Color3 object
  20542. */
  20543. static FromHexString(hex: string): Color3;
  20544. /**
  20545. * Creates a new Vector3 from the starting index of the given array
  20546. * @param array defines the source array
  20547. * @param offset defines an offset in the source array
  20548. * @returns a new Color3 object
  20549. */
  20550. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  20551. /**
  20552. * Creates a new Color3 from integer values (< 256)
  20553. * @param r defines the red component to read from (value between 0 and 255)
  20554. * @param g defines the green component to read from (value between 0 and 255)
  20555. * @param b defines the blue component to read from (value between 0 and 255)
  20556. * @returns a new Color3 object
  20557. */
  20558. static FromInts(r: number, g: number, b: number): Color3;
  20559. /**
  20560. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20561. * @param start defines the start Color3 value
  20562. * @param end defines the end Color3 value
  20563. * @param amount defines the gradient value between start and end
  20564. * @returns a new Color3 object
  20565. */
  20566. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  20567. /**
  20568. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20569. * @param left defines the start value
  20570. * @param right defines the end value
  20571. * @param amount defines the gradient factor
  20572. * @param result defines the Color3 object where to store the result
  20573. */
  20574. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  20575. /**
  20576. * Returns a Color3 value containing a red color
  20577. * @returns a new Color3 object
  20578. */
  20579. static Red(): Color3;
  20580. /**
  20581. * Returns a Color3 value containing a green color
  20582. * @returns a new Color3 object
  20583. */
  20584. static Green(): Color3;
  20585. /**
  20586. * Returns a Color3 value containing a blue color
  20587. * @returns a new Color3 object
  20588. */
  20589. static Blue(): Color3;
  20590. /**
  20591. * Returns a Color3 value containing a black color
  20592. * @returns a new Color3 object
  20593. */
  20594. static Black(): Color3;
  20595. /**
  20596. * Returns a Color3 value containing a white color
  20597. * @returns a new Color3 object
  20598. */
  20599. static White(): Color3;
  20600. /**
  20601. * Returns a Color3 value containing a purple color
  20602. * @returns a new Color3 object
  20603. */
  20604. static Purple(): Color3;
  20605. /**
  20606. * Returns a Color3 value containing a magenta color
  20607. * @returns a new Color3 object
  20608. */
  20609. static Magenta(): Color3;
  20610. /**
  20611. * Returns a Color3 value containing a yellow color
  20612. * @returns a new Color3 object
  20613. */
  20614. static Yellow(): Color3;
  20615. /**
  20616. * Returns a Color3 value containing a gray color
  20617. * @returns a new Color3 object
  20618. */
  20619. static Gray(): Color3;
  20620. /**
  20621. * Returns a Color3 value containing a teal color
  20622. * @returns a new Color3 object
  20623. */
  20624. static Teal(): Color3;
  20625. /**
  20626. * Returns a Color3 value containing a random color
  20627. * @returns a new Color3 object
  20628. */
  20629. static Random(): Color3;
  20630. }
  20631. /**
  20632. * Class used to hold a RBGA color
  20633. */
  20634. class Color4 {
  20635. /**
  20636. * Defines the red component (between 0 and 1, default is 0)
  20637. */
  20638. r: number;
  20639. /**
  20640. * Defines the green component (between 0 and 1, default is 0)
  20641. */
  20642. g: number;
  20643. /**
  20644. * Defines the blue component (between 0 and 1, default is 0)
  20645. */
  20646. b: number;
  20647. /**
  20648. * Defines the alpha component (between 0 and 1, default is 1)
  20649. */
  20650. a: number;
  20651. /**
  20652. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  20653. * @param r defines the red component (between 0 and 1, default is 0)
  20654. * @param g defines the green component (between 0 and 1, default is 0)
  20655. * @param b defines the blue component (between 0 and 1, default is 0)
  20656. * @param a defines the alpha component (between 0 and 1, default is 1)
  20657. */
  20658. constructor(
  20659. /**
  20660. * Defines the red component (between 0 and 1, default is 0)
  20661. */
  20662. r?: number,
  20663. /**
  20664. * Defines the green component (between 0 and 1, default is 0)
  20665. */
  20666. g?: number,
  20667. /**
  20668. * Defines the blue component (between 0 and 1, default is 0)
  20669. */
  20670. b?: number,
  20671. /**
  20672. * Defines the alpha component (between 0 and 1, default is 1)
  20673. */
  20674. a?: number);
  20675. /**
  20676. * Adds in place the given Color4 values to the current Color4 object
  20677. * @param right defines the second operand
  20678. * @returns the current updated Color4 object
  20679. */
  20680. addInPlace(right: DeepImmutable<Color4>): Color4;
  20681. /**
  20682. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  20683. * @returns the new array
  20684. */
  20685. asArray(): number[];
  20686. /**
  20687. * Stores from the starting index in the given array the Color4 successive values
  20688. * @param array defines the array where to store the r,g,b components
  20689. * @param index defines an optional index in the target array to define where to start storing values
  20690. * @returns the current Color4 object
  20691. */
  20692. toArray(array: number[], index?: number): Color4;
  20693. /**
  20694. * Determines equality between Color4 objects
  20695. * @param otherColor defines the second operand
  20696. * @returns true if the rgba values are equal to the given ones
  20697. */
  20698. equals(otherColor: DeepImmutable<Color4>): boolean;
  20699. /**
  20700. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  20701. * @param right defines the second operand
  20702. * @returns a new Color4 object
  20703. */
  20704. add(right: DeepImmutable<Color4>): Color4;
  20705. /**
  20706. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  20707. * @param right defines the second operand
  20708. * @returns a new Color4 object
  20709. */
  20710. subtract(right: DeepImmutable<Color4>): Color4;
  20711. /**
  20712. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  20713. * @param right defines the second operand
  20714. * @param result defines the Color4 object where to store the result
  20715. * @returns the current Color4 object
  20716. */
  20717. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  20718. /**
  20719. * Creates a new Color4 with the current Color4 values multiplied by scale
  20720. * @param scale defines the scaling factor to apply
  20721. * @returns a new Color4 object
  20722. */
  20723. scale(scale: number): Color4;
  20724. /**
  20725. * Multiplies the current Color4 values by scale and stores the result in "result"
  20726. * @param scale defines the scaling factor to apply
  20727. * @param result defines the Color4 object where to store the result
  20728. * @returns the current unmodified Color4
  20729. */
  20730. scaleToRef(scale: number, result: Color4): Color4;
  20731. /**
  20732. * Scale the current Color4 values by a factor and add the result to a given Color4
  20733. * @param scale defines the scale factor
  20734. * @param result defines the Color4 object where to store the result
  20735. * @returns the unmodified current Color4
  20736. */
  20737. scaleAndAddToRef(scale: number, result: Color4): Color4;
  20738. /**
  20739. * Clamps the rgb values by the min and max values and stores the result into "result"
  20740. * @param min defines minimum clamping value (default is 0)
  20741. * @param max defines maximum clamping value (default is 1)
  20742. * @param result defines color to store the result into.
  20743. * @returns the cuurent Color4
  20744. */
  20745. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  20746. /**
  20747. * Multipy an Color4 value by another and return a new Color4 object
  20748. * @param color defines the Color4 value to multiply by
  20749. * @returns a new Color4 object
  20750. */
  20751. multiply(color: Color4): Color4;
  20752. /**
  20753. * Multipy a Color4 value by another and push the result in a reference value
  20754. * @param color defines the Color4 value to multiply by
  20755. * @param result defines the Color4 to fill the result in
  20756. * @returns the result Color4
  20757. */
  20758. multiplyToRef(color: Color4, result: Color4): Color4;
  20759. /**
  20760. * Creates a string with the Color4 current values
  20761. * @returns the string representation of the Color4 object
  20762. */
  20763. toString(): string;
  20764. /**
  20765. * Returns the string "Color4"
  20766. * @returns "Color4"
  20767. */
  20768. getClassName(): string;
  20769. /**
  20770. * Compute the Color4 hash code
  20771. * @returns an unique number that can be used to hash Color4 objects
  20772. */
  20773. getHashCode(): number;
  20774. /**
  20775. * Creates a new Color4 copied from the current one
  20776. * @returns a new Color4 object
  20777. */
  20778. clone(): Color4;
  20779. /**
  20780. * Copies the given Color4 values into the current one
  20781. * @param source defines the source Color4 object
  20782. * @returns the current updated Color4 object
  20783. */
  20784. copyFrom(source: Color4): Color4;
  20785. /**
  20786. * Copies the given float values into the current one
  20787. * @param r defines the red component to read from
  20788. * @param g defines the green component to read from
  20789. * @param b defines the blue component to read from
  20790. * @param a defines the alpha component to read from
  20791. * @returns the current updated Color4 object
  20792. */
  20793. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  20794. /**
  20795. * Copies the given float values into the current one
  20796. * @param r defines the red component to read from
  20797. * @param g defines the green component to read from
  20798. * @param b defines the blue component to read from
  20799. * @param a defines the alpha component to read from
  20800. * @returns the current updated Color4 object
  20801. */
  20802. set(r: number, g: number, b: number, a: number): Color4;
  20803. /**
  20804. * Compute the Color4 hexadecimal code as a string
  20805. * @returns a string containing the hexadecimal representation of the Color4 object
  20806. */
  20807. toHexString(): string;
  20808. /**
  20809. * Computes a new Color4 converted from the current one to linear space
  20810. * @returns a new Color4 object
  20811. */
  20812. toLinearSpace(): Color4;
  20813. /**
  20814. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  20815. * @param convertedColor defines the Color4 object where to store the linear space version
  20816. * @returns the unmodified Color4
  20817. */
  20818. toLinearSpaceToRef(convertedColor: Color4): Color4;
  20819. /**
  20820. * Computes a new Color4 converted from the current one to gamma space
  20821. * @returns a new Color4 object
  20822. */
  20823. toGammaSpace(): Color4;
  20824. /**
  20825. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  20826. * @param convertedColor defines the Color4 object where to store the gamma space version
  20827. * @returns the unmodified Color4
  20828. */
  20829. toGammaSpaceToRef(convertedColor: Color4): Color4;
  20830. /**
  20831. * Creates a new Color4 from the string containing valid hexadecimal values
  20832. * @param hex defines a string containing valid hexadecimal values
  20833. * @returns a new Color4 object
  20834. */
  20835. static FromHexString(hex: string): Color4;
  20836. /**
  20837. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20838. * @param left defines the start value
  20839. * @param right defines the end value
  20840. * @param amount defines the gradient factor
  20841. * @returns a new Color4 object
  20842. */
  20843. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  20844. /**
  20845. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20846. * @param left defines the start value
  20847. * @param right defines the end value
  20848. * @param amount defines the gradient factor
  20849. * @param result defines the Color4 object where to store data
  20850. */
  20851. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  20852. /**
  20853. * Creates a new Color4 from a Color3 and an alpha value
  20854. * @param color3 defines the source Color3 to read from
  20855. * @param alpha defines the alpha component (1.0 by default)
  20856. * @returns a new Color4 object
  20857. */
  20858. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  20859. /**
  20860. * Creates a new Color4 from the starting index element of the given array
  20861. * @param array defines the source array to read from
  20862. * @param offset defines the offset in the source array
  20863. * @returns a new Color4 object
  20864. */
  20865. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  20866. /**
  20867. * Creates a new Color3 from integer values (< 256)
  20868. * @param r defines the red component to read from (value between 0 and 255)
  20869. * @param g defines the green component to read from (value between 0 and 255)
  20870. * @param b defines the blue component to read from (value between 0 and 255)
  20871. * @param a defines the alpha component to read from (value between 0 and 255)
  20872. * @returns a new Color3 object
  20873. */
  20874. static FromInts(r: number, g: number, b: number, a: number): Color4;
  20875. /**
  20876. * Check the content of a given array and convert it to an array containing RGBA data
  20877. * If the original array was already containing count * 4 values then it is returned directly
  20878. * @param colors defines the array to check
  20879. * @param count defines the number of RGBA data to expect
  20880. * @returns an array containing count * 4 values (RGBA)
  20881. */
  20882. static CheckColors4(colors: number[], count: number): number[];
  20883. }
  20884. /**
  20885. * Class representing a vector containing 2 coordinates
  20886. */
  20887. class Vector2 {
  20888. /** defines the first coordinate */
  20889. x: number;
  20890. /** defines the second coordinate */
  20891. y: number;
  20892. /**
  20893. * Creates a new Vector2 from the given x and y coordinates
  20894. * @param x defines the first coordinate
  20895. * @param y defines the second coordinate
  20896. */
  20897. constructor(
  20898. /** defines the first coordinate */
  20899. x?: number,
  20900. /** defines the second coordinate */
  20901. y?: number);
  20902. /**
  20903. * Gets a string with the Vector2 coordinates
  20904. * @returns a string with the Vector2 coordinates
  20905. */
  20906. toString(): string;
  20907. /**
  20908. * Gets class name
  20909. * @returns the string "Vector2"
  20910. */
  20911. getClassName(): string;
  20912. /**
  20913. * Gets current vector hash code
  20914. * @returns the Vector2 hash code as a number
  20915. */
  20916. getHashCode(): number;
  20917. /**
  20918. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  20919. * @param array defines the source array
  20920. * @param index defines the offset in source array
  20921. * @returns the current Vector2
  20922. */
  20923. toArray(array: FloatArray, index?: number): Vector2;
  20924. /**
  20925. * Copy the current vector to an array
  20926. * @returns a new array with 2 elements: the Vector2 coordinates.
  20927. */
  20928. asArray(): number[];
  20929. /**
  20930. * Sets the Vector2 coordinates with the given Vector2 coordinates
  20931. * @param source defines the source Vector2
  20932. * @returns the current updated Vector2
  20933. */
  20934. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  20935. /**
  20936. * Sets the Vector2 coordinates with the given floats
  20937. * @param x defines the first coordinate
  20938. * @param y defines the second coordinate
  20939. * @returns the current updated Vector2
  20940. */
  20941. copyFromFloats(x: number, y: number): Vector2;
  20942. /**
  20943. * Sets the Vector2 coordinates with the given floats
  20944. * @param x defines the first coordinate
  20945. * @param y defines the second coordinate
  20946. * @returns the current updated Vector2
  20947. */
  20948. set(x: number, y: number): Vector2;
  20949. /**
  20950. * Add another vector with the current one
  20951. * @param otherVector defines the other vector
  20952. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  20953. */
  20954. add(otherVector: DeepImmutable<Vector2>): Vector2;
  20955. /**
  20956. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  20957. * @param otherVector defines the other vector
  20958. * @param result defines the target vector
  20959. * @returns the unmodified current Vector2
  20960. */
  20961. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20962. /**
  20963. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  20964. * @param otherVector defines the other vector
  20965. * @returns the current updated Vector2
  20966. */
  20967. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20968. /**
  20969. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  20970. * @param otherVector defines the other vector
  20971. * @returns a new Vector2
  20972. */
  20973. addVector3(otherVector: Vector3): Vector2;
  20974. /**
  20975. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  20976. * @param otherVector defines the other vector
  20977. * @returns a new Vector2
  20978. */
  20979. subtract(otherVector: Vector2): Vector2;
  20980. /**
  20981. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  20982. * @param otherVector defines the other vector
  20983. * @param result defines the target vector
  20984. * @returns the unmodified current Vector2
  20985. */
  20986. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20987. /**
  20988. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  20989. * @param otherVector defines the other vector
  20990. * @returns the current updated Vector2
  20991. */
  20992. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20993. /**
  20994. * Multiplies in place the current Vector2 coordinates by the given ones
  20995. * @param otherVector defines the other vector
  20996. * @returns the current updated Vector2
  20997. */
  20998. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20999. /**
  21000. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  21001. * @param otherVector defines the other vector
  21002. * @returns a new Vector2
  21003. */
  21004. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  21005. /**
  21006. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  21007. * @param otherVector defines the other vector
  21008. * @param result defines the target vector
  21009. * @returns the unmodified current Vector2
  21010. */
  21011. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  21012. /**
  21013. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  21014. * @param x defines the first coordinate
  21015. * @param y defines the second coordinate
  21016. * @returns a new Vector2
  21017. */
  21018. multiplyByFloats(x: number, y: number): Vector2;
  21019. /**
  21020. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  21021. * @param otherVector defines the other vector
  21022. * @returns a new Vector2
  21023. */
  21024. divide(otherVector: Vector2): Vector2;
  21025. /**
  21026. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  21027. * @param otherVector defines the other vector
  21028. * @param result defines the target vector
  21029. * @returns the unmodified current Vector2
  21030. */
  21031. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  21032. /**
  21033. * Divides the current Vector2 coordinates by the given ones
  21034. * @param otherVector defines the other vector
  21035. * @returns the current updated Vector2
  21036. */
  21037. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  21038. /**
  21039. * Gets a new Vector2 with current Vector2 negated coordinates
  21040. * @returns a new Vector2
  21041. */
  21042. negate(): Vector2;
  21043. /**
  21044. * Multiply the Vector2 coordinates by scale
  21045. * @param scale defines the scaling factor
  21046. * @returns the current updated Vector2
  21047. */
  21048. scaleInPlace(scale: number): Vector2;
  21049. /**
  21050. * Returns a new Vector2 scaled by "scale" from the current Vector2
  21051. * @param scale defines the scaling factor
  21052. * @returns a new Vector2
  21053. */
  21054. scale(scale: number): Vector2;
  21055. /**
  21056. * Scale the current Vector2 values by a factor to a given Vector2
  21057. * @param scale defines the scale factor
  21058. * @param result defines the Vector2 object where to store the result
  21059. * @returns the unmodified current Vector2
  21060. */
  21061. scaleToRef(scale: number, result: Vector2): Vector2;
  21062. /**
  21063. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  21064. * @param scale defines the scale factor
  21065. * @param result defines the Vector2 object where to store the result
  21066. * @returns the unmodified current Vector2
  21067. */
  21068. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  21069. /**
  21070. * Gets a boolean if two vectors are equals
  21071. * @param otherVector defines the other vector
  21072. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  21073. */
  21074. equals(otherVector: DeepImmutable<Vector2>): boolean;
  21075. /**
  21076. * Gets a boolean if two vectors are equals (using an epsilon value)
  21077. * @param otherVector defines the other vector
  21078. * @param epsilon defines the minimal distance to consider equality
  21079. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  21080. */
  21081. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  21082. /**
  21083. * Gets a new Vector2 from current Vector2 floored values
  21084. * @returns a new Vector2
  21085. */
  21086. floor(): Vector2;
  21087. /**
  21088. * Gets a new Vector2 from current Vector2 floored values
  21089. * @returns a new Vector2
  21090. */
  21091. fract(): Vector2;
  21092. /**
  21093. * Gets the length of the vector
  21094. * @returns the vector length (float)
  21095. */
  21096. length(): number;
  21097. /**
  21098. * Gets the vector squared length
  21099. * @returns the vector squared length (float)
  21100. */
  21101. lengthSquared(): number;
  21102. /**
  21103. * Normalize the vector
  21104. * @returns the current updated Vector2
  21105. */
  21106. normalize(): Vector2;
  21107. /**
  21108. * Gets a new Vector2 copied from the Vector2
  21109. * @returns a new Vector2
  21110. */
  21111. clone(): Vector2;
  21112. /**
  21113. * Gets a new Vector2(0, 0)
  21114. * @returns a new Vector2
  21115. */
  21116. static Zero(): Vector2;
  21117. /**
  21118. * Gets a new Vector2(1, 1)
  21119. * @returns a new Vector2
  21120. */
  21121. static One(): Vector2;
  21122. /**
  21123. * Gets a new Vector2 set from the given index element of the given array
  21124. * @param array defines the data source
  21125. * @param offset defines the offset in the data source
  21126. * @returns a new Vector2
  21127. */
  21128. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  21129. /**
  21130. * Sets "result" from the given index element of the given array
  21131. * @param array defines the data source
  21132. * @param offset defines the offset in the data source
  21133. * @param result defines the target vector
  21134. */
  21135. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  21136. /**
  21137. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  21138. * @param value1 defines 1st point of control
  21139. * @param value2 defines 2nd point of control
  21140. * @param value3 defines 3rd point of control
  21141. * @param value4 defines 4th point of control
  21142. * @param amount defines the interpolation factor
  21143. * @returns a new Vector2
  21144. */
  21145. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  21146. /**
  21147. * 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".
  21148. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  21149. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  21150. * @param value defines the value to clamp
  21151. * @param min defines the lower limit
  21152. * @param max defines the upper limit
  21153. * @returns a new Vector2
  21154. */
  21155. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  21156. /**
  21157. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  21158. * @param value1 defines the 1st control point
  21159. * @param tangent1 defines the outgoing tangent
  21160. * @param value2 defines the 2nd control point
  21161. * @param tangent2 defines the incoming tangent
  21162. * @param amount defines the interpolation factor
  21163. * @returns a new Vector2
  21164. */
  21165. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  21166. /**
  21167. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  21168. * @param start defines the start vector
  21169. * @param end defines the end vector
  21170. * @param amount defines the interpolation factor
  21171. * @returns a new Vector2
  21172. */
  21173. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  21174. /**
  21175. * Gets the dot product of the vector "left" and the vector "right"
  21176. * @param left defines first vector
  21177. * @param right defines second vector
  21178. * @returns the dot product (float)
  21179. */
  21180. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  21181. /**
  21182. * Returns a new Vector2 equal to the normalized given vector
  21183. * @param vector defines the vector to normalize
  21184. * @returns a new Vector2
  21185. */
  21186. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  21187. /**
  21188. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  21189. * @param left defines 1st vector
  21190. * @param right defines 2nd vector
  21191. * @returns a new Vector2
  21192. */
  21193. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  21194. /**
  21195. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  21196. * @param left defines 1st vector
  21197. * @param right defines 2nd vector
  21198. * @returns a new Vector2
  21199. */
  21200. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  21201. /**
  21202. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  21203. * @param vector defines the vector to transform
  21204. * @param transformation defines the matrix to apply
  21205. * @returns a new Vector2
  21206. */
  21207. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  21208. /**
  21209. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  21210. * @param vector defines the vector to transform
  21211. * @param transformation defines the matrix to apply
  21212. * @param result defines the target vector
  21213. */
  21214. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  21215. /**
  21216. * Determines if a given vector is included in a triangle
  21217. * @param p defines the vector to test
  21218. * @param p0 defines 1st triangle point
  21219. * @param p1 defines 2nd triangle point
  21220. * @param p2 defines 3rd triangle point
  21221. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  21222. */
  21223. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  21224. /**
  21225. * Gets the distance between the vectors "value1" and "value2"
  21226. * @param value1 defines first vector
  21227. * @param value2 defines second vector
  21228. * @returns the distance between vectors
  21229. */
  21230. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  21231. /**
  21232. * Returns the squared distance between the vectors "value1" and "value2"
  21233. * @param value1 defines first vector
  21234. * @param value2 defines second vector
  21235. * @returns the squared distance between vectors
  21236. */
  21237. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  21238. /**
  21239. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  21240. * @param value1 defines first vector
  21241. * @param value2 defines second vector
  21242. * @returns a new Vector2
  21243. */
  21244. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  21245. /**
  21246. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  21247. * @param p defines the middle point
  21248. * @param segA defines one point of the segment
  21249. * @param segB defines the other point of the segment
  21250. * @returns the shortest distance
  21251. */
  21252. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  21253. }
  21254. /**
  21255. * Classed used to store (x,y,z) vector representation
  21256. * A Vector3 is the main object used in 3D geometry
  21257. * It can represent etiher the coordinates of a point the space, either a direction
  21258. * Reminder: Babylon.js uses a left handed forward facing system
  21259. */
  21260. class Vector3 {
  21261. /**
  21262. * Defines the first coordinates (on X axis)
  21263. */
  21264. x: number;
  21265. /**
  21266. * Defines the second coordinates (on Y axis)
  21267. */
  21268. y: number;
  21269. /**
  21270. * Defines the third coordinates (on Z axis)
  21271. */
  21272. z: number;
  21273. private static _UpReadOnly;
  21274. /**
  21275. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  21276. * @param x defines the first coordinates (on X axis)
  21277. * @param y defines the second coordinates (on Y axis)
  21278. * @param z defines the third coordinates (on Z axis)
  21279. */
  21280. constructor(
  21281. /**
  21282. * Defines the first coordinates (on X axis)
  21283. */
  21284. x?: number,
  21285. /**
  21286. * Defines the second coordinates (on Y axis)
  21287. */
  21288. y?: number,
  21289. /**
  21290. * Defines the third coordinates (on Z axis)
  21291. */
  21292. z?: number);
  21293. /**
  21294. * Creates a string representation of the Vector3
  21295. * @returns a string with the Vector3 coordinates.
  21296. */
  21297. toString(): string;
  21298. /**
  21299. * Gets the class name
  21300. * @returns the string "Vector3"
  21301. */
  21302. getClassName(): string;
  21303. /**
  21304. * Creates the Vector3 hash code
  21305. * @returns a number which tends to be unique between Vector3 instances
  21306. */
  21307. getHashCode(): number;
  21308. /**
  21309. * Creates an array containing three elements : the coordinates of the Vector3
  21310. * @returns a new array of numbers
  21311. */
  21312. asArray(): number[];
  21313. /**
  21314. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  21315. * @param array defines the destination array
  21316. * @param index defines the offset in the destination array
  21317. * @returns the current Vector3
  21318. */
  21319. toArray(array: FloatArray, index?: number): Vector3;
  21320. /**
  21321. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  21322. * @returns a new Quaternion object, computed from the Vector3 coordinates
  21323. */
  21324. toQuaternion(): Quaternion;
  21325. /**
  21326. * Adds the given vector to the current Vector3
  21327. * @param otherVector defines the second operand
  21328. * @returns the current updated Vector3
  21329. */
  21330. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21331. /**
  21332. * Adds the given coordinates to the current Vector3
  21333. * @param x defines the x coordinate of the operand
  21334. * @param y defines the y coordinate of the operand
  21335. * @param z defines the z coordinate of the operand
  21336. * @returns the current updated Vector3
  21337. */
  21338. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21339. /**
  21340. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  21341. * @param otherVector defines the second operand
  21342. * @returns the resulting Vector3
  21343. */
  21344. add(otherVector: DeepImmutable<Vector3>): Vector3;
  21345. /**
  21346. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  21347. * @param otherVector defines the second operand
  21348. * @param result defines the Vector3 object where to store the result
  21349. * @returns the current Vector3
  21350. */
  21351. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21352. /**
  21353. * Subtract the given vector from the current Vector3
  21354. * @param otherVector defines the second operand
  21355. * @returns the current updated Vector3
  21356. */
  21357. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21358. /**
  21359. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  21360. * @param otherVector defines the second operand
  21361. * @returns the resulting Vector3
  21362. */
  21363. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  21364. /**
  21365. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  21366. * @param otherVector defines the second operand
  21367. * @param result defines the Vector3 object where to store the result
  21368. * @returns the current Vector3
  21369. */
  21370. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21371. /**
  21372. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  21373. * @param x defines the x coordinate of the operand
  21374. * @param y defines the y coordinate of the operand
  21375. * @param z defines the z coordinate of the operand
  21376. * @returns the resulting Vector3
  21377. */
  21378. subtractFromFloats(x: number, y: number, z: number): Vector3;
  21379. /**
  21380. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  21381. * @param x defines the x coordinate of the operand
  21382. * @param y defines the y coordinate of the operand
  21383. * @param z defines the z coordinate of the operand
  21384. * @param result defines the Vector3 object where to store the result
  21385. * @returns the current Vector3
  21386. */
  21387. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  21388. /**
  21389. * Gets a new Vector3 set with the current Vector3 negated coordinates
  21390. * @returns a new Vector3
  21391. */
  21392. negate(): Vector3;
  21393. /**
  21394. * Multiplies the Vector3 coordinates by the float "scale"
  21395. * @param scale defines the multiplier factor
  21396. * @returns the current updated Vector3
  21397. */
  21398. scaleInPlace(scale: number): Vector3;
  21399. /**
  21400. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  21401. * @param scale defines the multiplier factor
  21402. * @returns a new Vector3
  21403. */
  21404. scale(scale: number): Vector3;
  21405. /**
  21406. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  21407. * @param scale defines the multiplier factor
  21408. * @param result defines the Vector3 object where to store the result
  21409. * @returns the current Vector3
  21410. */
  21411. scaleToRef(scale: number, result: Vector3): Vector3;
  21412. /**
  21413. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  21414. * @param scale defines the scale factor
  21415. * @param result defines the Vector3 object where to store the result
  21416. * @returns the unmodified current Vector3
  21417. */
  21418. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  21419. /**
  21420. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  21421. * @param otherVector defines the second operand
  21422. * @returns true if both vectors are equals
  21423. */
  21424. equals(otherVector: DeepImmutable<Vector3>): boolean;
  21425. /**
  21426. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  21427. * @param otherVector defines the second operand
  21428. * @param epsilon defines the minimal distance to define values as equals
  21429. * @returns true if both vectors are distant less than epsilon
  21430. */
  21431. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  21432. /**
  21433. * Returns true if the current Vector3 coordinates equals the given floats
  21434. * @param x defines the x coordinate of the operand
  21435. * @param y defines the y coordinate of the operand
  21436. * @param z defines the z coordinate of the operand
  21437. * @returns true if both vectors are equals
  21438. */
  21439. equalsToFloats(x: number, y: number, z: number): boolean;
  21440. /**
  21441. * Multiplies the current Vector3 coordinates by the given ones
  21442. * @param otherVector defines the second operand
  21443. * @returns the current updated Vector3
  21444. */
  21445. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21446. /**
  21447. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  21448. * @param otherVector defines the second operand
  21449. * @returns the new Vector3
  21450. */
  21451. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  21452. /**
  21453. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  21454. * @param otherVector defines the second operand
  21455. * @param result defines the Vector3 object where to store the result
  21456. * @returns the current Vector3
  21457. */
  21458. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21459. /**
  21460. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  21461. * @param x defines the x coordinate of the operand
  21462. * @param y defines the y coordinate of the operand
  21463. * @param z defines the z coordinate of the operand
  21464. * @returns the new Vector3
  21465. */
  21466. multiplyByFloats(x: number, y: number, z: number): Vector3;
  21467. /**
  21468. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  21469. * @param otherVector defines the second operand
  21470. * @returns the new Vector3
  21471. */
  21472. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  21473. /**
  21474. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  21475. * @param otherVector defines the second operand
  21476. * @param result defines the Vector3 object where to store the result
  21477. * @returns the current Vector3
  21478. */
  21479. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21480. /**
  21481. * Divides the current Vector3 coordinates by the given ones.
  21482. * @param otherVector defines the second operand
  21483. * @returns the current updated Vector3
  21484. */
  21485. divideInPlace(otherVector: Vector3): Vector3;
  21486. /**
  21487. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  21488. * @param other defines the second operand
  21489. * @returns the current updated Vector3
  21490. */
  21491. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  21492. /**
  21493. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  21494. * @param other defines the second operand
  21495. * @returns the current updated Vector3
  21496. */
  21497. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  21498. /**
  21499. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  21500. * @param x defines the x coordinate of the operand
  21501. * @param y defines the y coordinate of the operand
  21502. * @param z defines the z coordinate of the operand
  21503. * @returns the current updated Vector3
  21504. */
  21505. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21506. /**
  21507. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  21508. * @param x defines the x coordinate of the operand
  21509. * @param y defines the y coordinate of the operand
  21510. * @param z defines the z coordinate of the operand
  21511. * @returns the current updated Vector3
  21512. */
  21513. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21514. /**
  21515. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  21516. */
  21517. readonly isNonUniform: boolean;
  21518. /**
  21519. * Gets a new Vector3 from current Vector3 floored values
  21520. * @returns a new Vector3
  21521. */
  21522. floor(): Vector3;
  21523. /**
  21524. * Gets a new Vector3 from current Vector3 floored values
  21525. * @returns a new Vector3
  21526. */
  21527. fract(): Vector3;
  21528. /**
  21529. * Gets the length of the Vector3
  21530. * @returns the length of the Vecto3
  21531. */
  21532. length(): number;
  21533. /**
  21534. * Gets the squared length of the Vector3
  21535. * @returns squared length of the Vector3
  21536. */
  21537. lengthSquared(): number;
  21538. /**
  21539. * Normalize the current Vector3.
  21540. * Please note that this is an in place operation.
  21541. * @returns the current updated Vector3
  21542. */
  21543. normalize(): Vector3;
  21544. /**
  21545. * Reorders the x y z properties of the vector in place
  21546. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  21547. * @returns the current updated vector
  21548. */
  21549. reorderInPlace(order: string): this;
  21550. /**
  21551. * Rotates the vector around 0,0,0 by a quaternion
  21552. * @param quaternion the rotation quaternion
  21553. * @param result vector to store the result
  21554. * @returns the resulting vector
  21555. */
  21556. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  21557. /**
  21558. * Rotates a vector around a given point
  21559. * @param quaternion the rotation quaternion
  21560. * @param point the point to rotate around
  21561. * @param result vector to store the result
  21562. * @returns the resulting vector
  21563. */
  21564. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  21565. /**
  21566. * Normalize the current Vector3 with the given input length.
  21567. * Please note that this is an in place operation.
  21568. * @param len the length of the vector
  21569. * @returns the current updated Vector3
  21570. */
  21571. normalizeFromLength(len: number): Vector3;
  21572. /**
  21573. * Normalize the current Vector3 to a new vector
  21574. * @returns the new Vector3
  21575. */
  21576. normalizeToNew(): Vector3;
  21577. /**
  21578. * Normalize the current Vector3 to the reference
  21579. * @param reference define the Vector3 to update
  21580. * @returns the updated Vector3
  21581. */
  21582. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  21583. /**
  21584. * Creates a new Vector3 copied from the current Vector3
  21585. * @returns the new Vector3
  21586. */
  21587. clone(): Vector3;
  21588. /**
  21589. * Copies the given vector coordinates to the current Vector3 ones
  21590. * @param source defines the source Vector3
  21591. * @returns the current updated Vector3
  21592. */
  21593. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  21594. /**
  21595. * Copies the given floats to the current Vector3 coordinates
  21596. * @param x defines the x coordinate of the operand
  21597. * @param y defines the y coordinate of the operand
  21598. * @param z defines the z coordinate of the operand
  21599. * @returns the current updated Vector3
  21600. */
  21601. copyFromFloats(x: number, y: number, z: number): Vector3;
  21602. /**
  21603. * Copies the given floats to the current Vector3 coordinates
  21604. * @param x defines the x coordinate of the operand
  21605. * @param y defines the y coordinate of the operand
  21606. * @param z defines the z coordinate of the operand
  21607. * @returns the current updated Vector3
  21608. */
  21609. set(x: number, y: number, z: number): Vector3;
  21610. /**
  21611. * Copies the given float to the current Vector3 coordinates
  21612. * @param v defines the x, y and z coordinates of the operand
  21613. * @returns the current updated Vector3
  21614. */
  21615. setAll(v: number): Vector3;
  21616. /**
  21617. * Get the clip factor between two vectors
  21618. * @param vector0 defines the first operand
  21619. * @param vector1 defines the second operand
  21620. * @param axis defines the axis to use
  21621. * @param size defines the size along the axis
  21622. * @returns the clip factor
  21623. */
  21624. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  21625. /**
  21626. * Get angle between two vectors
  21627. * @param vector0 angle between vector0 and vector1
  21628. * @param vector1 angle between vector0 and vector1
  21629. * @param normal direction of the normal
  21630. * @return the angle between vector0 and vector1
  21631. */
  21632. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  21633. /**
  21634. * Returns a new Vector3 set from the index "offset" of the given array
  21635. * @param array defines the source array
  21636. * @param offset defines the offset in the source array
  21637. * @returns the new Vector3
  21638. */
  21639. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  21640. /**
  21641. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  21642. * This function is deprecated. Use FromArray instead
  21643. * @param array defines the source array
  21644. * @param offset defines the offset in the source array
  21645. * @returns the new Vector3
  21646. */
  21647. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  21648. /**
  21649. * Sets the given vector "result" with the element values from the index "offset" of the given array
  21650. * @param array defines the source array
  21651. * @param offset defines the offset in the source array
  21652. * @param result defines the Vector3 where to store the result
  21653. */
  21654. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  21655. /**
  21656. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  21657. * This function is deprecated. Use FromArrayToRef instead.
  21658. * @param array defines the source array
  21659. * @param offset defines the offset in the source array
  21660. * @param result defines the Vector3 where to store the result
  21661. */
  21662. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  21663. /**
  21664. * Sets the given vector "result" with the given floats.
  21665. * @param x defines the x coordinate of the source
  21666. * @param y defines the y coordinate of the source
  21667. * @param z defines the z coordinate of the source
  21668. * @param result defines the Vector3 where to store the result
  21669. */
  21670. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  21671. /**
  21672. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  21673. * @returns a new empty Vector3
  21674. */
  21675. static Zero(): Vector3;
  21676. /**
  21677. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  21678. * @returns a new unit Vector3
  21679. */
  21680. static One(): Vector3;
  21681. /**
  21682. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  21683. * @returns a new up Vector3
  21684. */
  21685. static Up(): Vector3;
  21686. /**
  21687. * Gets a up Vector3 that must not be updated
  21688. */
  21689. static readonly UpReadOnly: DeepImmutable<Vector3>;
  21690. /**
  21691. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  21692. * @returns a new down Vector3
  21693. */
  21694. static Down(): Vector3;
  21695. /**
  21696. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  21697. * @returns a new forward Vector3
  21698. */
  21699. static Forward(): Vector3;
  21700. /**
  21701. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  21702. * @returns a new forward Vector3
  21703. */
  21704. static Backward(): Vector3;
  21705. /**
  21706. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  21707. * @returns a new right Vector3
  21708. */
  21709. static Right(): Vector3;
  21710. /**
  21711. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  21712. * @returns a new left Vector3
  21713. */
  21714. static Left(): Vector3;
  21715. /**
  21716. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  21717. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21718. * @param vector defines the Vector3 to transform
  21719. * @param transformation defines the transformation matrix
  21720. * @returns the transformed Vector3
  21721. */
  21722. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  21723. /**
  21724. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  21725. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21726. * @param vector defines the Vector3 to transform
  21727. * @param transformation defines the transformation matrix
  21728. * @param result defines the Vector3 where to store the result
  21729. */
  21730. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21731. /**
  21732. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  21733. * This method computes tranformed coordinates only, not transformed direction vectors
  21734. * @param x define the x coordinate of the source vector
  21735. * @param y define the y coordinate of the source vector
  21736. * @param z define the z coordinate of the source vector
  21737. * @param transformation defines the transformation matrix
  21738. * @param result defines the Vector3 where to store the result
  21739. */
  21740. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21741. /**
  21742. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  21743. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21744. * @param vector defines the Vector3 to transform
  21745. * @param transformation defines the transformation matrix
  21746. * @returns the new Vector3
  21747. */
  21748. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  21749. /**
  21750. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  21751. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21752. * @param vector defines the Vector3 to transform
  21753. * @param transformation defines the transformation matrix
  21754. * @param result defines the Vector3 where to store the result
  21755. */
  21756. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21757. /**
  21758. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  21759. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21760. * @param x define the x coordinate of the source vector
  21761. * @param y define the y coordinate of the source vector
  21762. * @param z define the z coordinate of the source vector
  21763. * @param transformation defines the transformation matrix
  21764. * @param result defines the Vector3 where to store the result
  21765. */
  21766. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21767. /**
  21768. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  21769. * @param value1 defines the first control point
  21770. * @param value2 defines the second control point
  21771. * @param value3 defines the third control point
  21772. * @param value4 defines the fourth control point
  21773. * @param amount defines the amount on the spline to use
  21774. * @returns the new Vector3
  21775. */
  21776. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  21777. /**
  21778. * 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"
  21779. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21780. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21781. * @param value defines the current value
  21782. * @param min defines the lower range value
  21783. * @param max defines the upper range value
  21784. * @returns the new Vector3
  21785. */
  21786. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  21787. /**
  21788. * 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"
  21789. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21790. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21791. * @param value defines the current value
  21792. * @param min defines the lower range value
  21793. * @param max defines the upper range value
  21794. * @param result defines the Vector3 where to store the result
  21795. */
  21796. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  21797. /**
  21798. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  21799. * @param value1 defines the first control point
  21800. * @param tangent1 defines the first tangent vector
  21801. * @param value2 defines the second control point
  21802. * @param tangent2 defines the second tangent vector
  21803. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  21804. * @returns the new Vector3
  21805. */
  21806. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  21807. /**
  21808. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  21809. * @param start defines the start value
  21810. * @param end defines the end value
  21811. * @param amount max defines amount between both (between 0 and 1)
  21812. * @returns the new Vector3
  21813. */
  21814. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  21815. /**
  21816. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  21817. * @param start defines the start value
  21818. * @param end defines the end value
  21819. * @param amount max defines amount between both (between 0 and 1)
  21820. * @param result defines the Vector3 where to store the result
  21821. */
  21822. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  21823. /**
  21824. * Returns the dot product (float) between the vectors "left" and "right"
  21825. * @param left defines the left operand
  21826. * @param right defines the right operand
  21827. * @returns the dot product
  21828. */
  21829. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  21830. /**
  21831. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  21832. * The cross product is then orthogonal to both "left" and "right"
  21833. * @param left defines the left operand
  21834. * @param right defines the right operand
  21835. * @returns the cross product
  21836. */
  21837. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21838. /**
  21839. * Sets the given vector "result" with the cross product of "left" and "right"
  21840. * The cross product is then orthogonal to both "left" and "right"
  21841. * @param left defines the left operand
  21842. * @param right defines the right operand
  21843. * @param result defines the Vector3 where to store the result
  21844. */
  21845. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  21846. /**
  21847. * Returns a new Vector3 as the normalization of the given vector
  21848. * @param vector defines the Vector3 to normalize
  21849. * @returns the new Vector3
  21850. */
  21851. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  21852. /**
  21853. * Sets the given vector "result" with the normalization of the given first vector
  21854. * @param vector defines the Vector3 to normalize
  21855. * @param result defines the Vector3 where to store the result
  21856. */
  21857. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  21858. /**
  21859. * Project a Vector3 onto screen space
  21860. * @param vector defines the Vector3 to project
  21861. * @param world defines the world matrix to use
  21862. * @param transform defines the transform (view x projection) matrix to use
  21863. * @param viewport defines the screen viewport to use
  21864. * @returns the new Vector3
  21865. */
  21866. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  21867. /** @hidden */
  21868. private static UnprojectFromInvertedMatrixToRef;
  21869. /**
  21870. * Unproject from screen space to object space
  21871. * @param source defines the screen space Vector3 to use
  21872. * @param viewportWidth defines the current width of the viewport
  21873. * @param viewportHeight defines the current height of the viewport
  21874. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21875. * @param transform defines the transform (view x projection) matrix to use
  21876. * @returns the new Vector3
  21877. */
  21878. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  21879. /**
  21880. * Unproject from screen space to object space
  21881. * @param source defines the screen space Vector3 to use
  21882. * @param viewportWidth defines the current width of the viewport
  21883. * @param viewportHeight defines the current height of the viewport
  21884. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21885. * @param view defines the view matrix to use
  21886. * @param projection defines the projection matrix to use
  21887. * @returns the new Vector3
  21888. */
  21889. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  21890. /**
  21891. * Unproject from screen space to object space
  21892. * @param source defines the screen space Vector3 to use
  21893. * @param viewportWidth defines the current width of the viewport
  21894. * @param viewportHeight defines the current height of the viewport
  21895. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21896. * @param view defines the view matrix to use
  21897. * @param projection defines the projection matrix to use
  21898. * @param result defines the Vector3 where to store the result
  21899. */
  21900. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  21901. /**
  21902. * Unproject from screen space to object space
  21903. * @param sourceX defines the screen space x coordinate to use
  21904. * @param sourceY defines the screen space y coordinate to use
  21905. * @param sourceZ defines the screen space z coordinate to use
  21906. * @param viewportWidth defines the current width of the viewport
  21907. * @param viewportHeight defines the current height of the viewport
  21908. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21909. * @param view defines the view matrix to use
  21910. * @param projection defines the projection matrix to use
  21911. * @param result defines the Vector3 where to store the result
  21912. */
  21913. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  21914. /**
  21915. * Unproject a ray from screen space to object space
  21916. * @param sourceX defines the screen space x coordinate to use
  21917. * @param sourceY defines the screen space y coordinate to use
  21918. * @param viewportWidth defines the current width of the viewport
  21919. * @param viewportHeight defines the current height of the viewport
  21920. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21921. * @param view defines the view matrix to use
  21922. * @param projection defines the projection matrix to use
  21923. * @param ray defines the Ray where to store the result
  21924. */
  21925. static UnprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, ray: Ray): void;
  21926. /**
  21927. * Gets the minimal coordinate values between two Vector3
  21928. * @param left defines the first operand
  21929. * @param right defines the second operand
  21930. * @returns the new Vector3
  21931. */
  21932. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21933. /**
  21934. * Gets the maximal coordinate values between two Vector3
  21935. * @param left defines the first operand
  21936. * @param right defines the second operand
  21937. * @returns the new Vector3
  21938. */
  21939. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21940. /**
  21941. * Returns the distance between the vectors "value1" and "value2"
  21942. * @param value1 defines the first operand
  21943. * @param value2 defines the second operand
  21944. * @returns the distance
  21945. */
  21946. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  21947. /**
  21948. * Returns the squared distance between the vectors "value1" and "value2"
  21949. * @param value1 defines the first operand
  21950. * @param value2 defines the second operand
  21951. * @returns the squared distance
  21952. */
  21953. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  21954. /**
  21955. * Returns a new Vector3 located at the center between "value1" and "value2"
  21956. * @param value1 defines the first operand
  21957. * @param value2 defines the second operand
  21958. * @returns the new Vector3
  21959. */
  21960. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  21961. /**
  21962. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  21963. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  21964. * to something in order to rotate it from its local system to the given target system
  21965. * Note: axis1, axis2 and axis3 are normalized during this operation
  21966. * @param axis1 defines the first axis
  21967. * @param axis2 defines the second axis
  21968. * @param axis3 defines the third axis
  21969. * @returns a new Vector3
  21970. */
  21971. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  21972. /**
  21973. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  21974. * @param axis1 defines the first axis
  21975. * @param axis2 defines the second axis
  21976. * @param axis3 defines the third axis
  21977. * @param ref defines the Vector3 where to store the result
  21978. */
  21979. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  21980. }
  21981. /**
  21982. * Vector4 class created for EulerAngle class conversion to Quaternion
  21983. */
  21984. class Vector4 {
  21985. /** x value of the vector */
  21986. x: number;
  21987. /** y value of the vector */
  21988. y: number;
  21989. /** z value of the vector */
  21990. z: number;
  21991. /** w value of the vector */
  21992. w: number;
  21993. /**
  21994. * Creates a Vector4 object from the given floats.
  21995. * @param x x value of the vector
  21996. * @param y y value of the vector
  21997. * @param z z value of the vector
  21998. * @param w w value of the vector
  21999. */
  22000. constructor(
  22001. /** x value of the vector */
  22002. x: number,
  22003. /** y value of the vector */
  22004. y: number,
  22005. /** z value of the vector */
  22006. z: number,
  22007. /** w value of the vector */
  22008. w: number);
  22009. /**
  22010. * Returns the string with the Vector4 coordinates.
  22011. * @returns a string containing all the vector values
  22012. */
  22013. toString(): string;
  22014. /**
  22015. * Returns the string "Vector4".
  22016. * @returns "Vector4"
  22017. */
  22018. getClassName(): string;
  22019. /**
  22020. * Returns the Vector4 hash code.
  22021. * @returns a unique hash code
  22022. */
  22023. getHashCode(): number;
  22024. /**
  22025. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  22026. * @returns the resulting array
  22027. */
  22028. asArray(): number[];
  22029. /**
  22030. * Populates the given array from the given index with the Vector4 coordinates.
  22031. * @param array array to populate
  22032. * @param index index of the array to start at (default: 0)
  22033. * @returns the Vector4.
  22034. */
  22035. toArray(array: FloatArray, index?: number): Vector4;
  22036. /**
  22037. * Adds the given vector to the current Vector4.
  22038. * @param otherVector the vector to add
  22039. * @returns the updated Vector4.
  22040. */
  22041. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  22042. /**
  22043. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  22044. * @param otherVector the vector to add
  22045. * @returns the resulting vector
  22046. */
  22047. add(otherVector: DeepImmutable<Vector4>): Vector4;
  22048. /**
  22049. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  22050. * @param otherVector the vector to add
  22051. * @param result the vector to store the result
  22052. * @returns the current Vector4.
  22053. */
  22054. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22055. /**
  22056. * Subtract in place the given vector from the current Vector4.
  22057. * @param otherVector the vector to subtract
  22058. * @returns the updated Vector4.
  22059. */
  22060. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  22061. /**
  22062. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  22063. * @param otherVector the vector to add
  22064. * @returns the new vector with the result
  22065. */
  22066. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  22067. /**
  22068. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  22069. * @param otherVector the vector to subtract
  22070. * @param result the vector to store the result
  22071. * @returns the current Vector4.
  22072. */
  22073. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22074. /**
  22075. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  22076. */
  22077. /**
  22078. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  22079. * @param x value to subtract
  22080. * @param y value to subtract
  22081. * @param z value to subtract
  22082. * @param w value to subtract
  22083. * @returns new vector containing the result
  22084. */
  22085. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  22086. /**
  22087. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  22088. * @param x value to subtract
  22089. * @param y value to subtract
  22090. * @param z value to subtract
  22091. * @param w value to subtract
  22092. * @param result the vector to store the result in
  22093. * @returns the current Vector4.
  22094. */
  22095. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  22096. /**
  22097. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  22098. * @returns a new vector with the negated values
  22099. */
  22100. negate(): Vector4;
  22101. /**
  22102. * Multiplies the current Vector4 coordinates by scale (float).
  22103. * @param scale the number to scale with
  22104. * @returns the updated Vector4.
  22105. */
  22106. scaleInPlace(scale: number): Vector4;
  22107. /**
  22108. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  22109. * @param scale the number to scale with
  22110. * @returns a new vector with the result
  22111. */
  22112. scale(scale: number): Vector4;
  22113. /**
  22114. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  22115. * @param scale the number to scale with
  22116. * @param result a vector to store the result in
  22117. * @returns the current Vector4.
  22118. */
  22119. scaleToRef(scale: number, result: Vector4): Vector4;
  22120. /**
  22121. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  22122. * @param scale defines the scale factor
  22123. * @param result defines the Vector4 object where to store the result
  22124. * @returns the unmodified current Vector4
  22125. */
  22126. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  22127. /**
  22128. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  22129. * @param otherVector the vector to compare against
  22130. * @returns true if they are equal
  22131. */
  22132. equals(otherVector: DeepImmutable<Vector4>): boolean;
  22133. /**
  22134. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  22135. * @param otherVector vector to compare against
  22136. * @param epsilon (Default: very small number)
  22137. * @returns true if they are equal
  22138. */
  22139. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  22140. /**
  22141. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  22142. * @param x x value to compare against
  22143. * @param y y value to compare against
  22144. * @param z z value to compare against
  22145. * @param w w value to compare against
  22146. * @returns true if equal
  22147. */
  22148. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  22149. /**
  22150. * Multiplies in place the current Vector4 by the given one.
  22151. * @param otherVector vector to multiple with
  22152. * @returns the updated Vector4.
  22153. */
  22154. multiplyInPlace(otherVector: Vector4): Vector4;
  22155. /**
  22156. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  22157. * @param otherVector vector to multiple with
  22158. * @returns resulting new vector
  22159. */
  22160. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  22161. /**
  22162. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  22163. * @param otherVector vector to multiple with
  22164. * @param result vector to store the result
  22165. * @returns the current Vector4.
  22166. */
  22167. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22168. /**
  22169. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  22170. * @param x x value multiply with
  22171. * @param y y value multiply with
  22172. * @param z z value multiply with
  22173. * @param w w value multiply with
  22174. * @returns resulting new vector
  22175. */
  22176. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  22177. /**
  22178. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  22179. * @param otherVector vector to devide with
  22180. * @returns resulting new vector
  22181. */
  22182. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  22183. /**
  22184. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  22185. * @param otherVector vector to devide with
  22186. * @param result vector to store the result
  22187. * @returns the current Vector4.
  22188. */
  22189. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22190. /**
  22191. * Divides the current Vector3 coordinates by the given ones.
  22192. * @param otherVector vector to devide with
  22193. * @returns the updated Vector3.
  22194. */
  22195. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  22196. /**
  22197. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  22198. * @param other defines the second operand
  22199. * @returns the current updated Vector4
  22200. */
  22201. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  22202. /**
  22203. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  22204. * @param other defines the second operand
  22205. * @returns the current updated Vector4
  22206. */
  22207. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  22208. /**
  22209. * Gets a new Vector4 from current Vector4 floored values
  22210. * @returns a new Vector4
  22211. */
  22212. floor(): Vector4;
  22213. /**
  22214. * Gets a new Vector4 from current Vector3 floored values
  22215. * @returns a new Vector4
  22216. */
  22217. fract(): Vector4;
  22218. /**
  22219. * Returns the Vector4 length (float).
  22220. * @returns the length
  22221. */
  22222. length(): number;
  22223. /**
  22224. * Returns the Vector4 squared length (float).
  22225. * @returns the length squared
  22226. */
  22227. lengthSquared(): number;
  22228. /**
  22229. * Normalizes in place the Vector4.
  22230. * @returns the updated Vector4.
  22231. */
  22232. normalize(): Vector4;
  22233. /**
  22234. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  22235. * @returns this converted to a new vector3
  22236. */
  22237. toVector3(): Vector3;
  22238. /**
  22239. * Returns a new Vector4 copied from the current one.
  22240. * @returns the new cloned vector
  22241. */
  22242. clone(): Vector4;
  22243. /**
  22244. * Updates the current Vector4 with the given one coordinates.
  22245. * @param source the source vector to copy from
  22246. * @returns the updated Vector4.
  22247. */
  22248. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  22249. /**
  22250. * Updates the current Vector4 coordinates with the given floats.
  22251. * @param x float to copy from
  22252. * @param y float to copy from
  22253. * @param z float to copy from
  22254. * @param w float to copy from
  22255. * @returns the updated Vector4.
  22256. */
  22257. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  22258. /**
  22259. * Updates the current Vector4 coordinates with the given floats.
  22260. * @param x float to set from
  22261. * @param y float to set from
  22262. * @param z float to set from
  22263. * @param w float to set from
  22264. * @returns the updated Vector4.
  22265. */
  22266. set(x: number, y: number, z: number, w: number): Vector4;
  22267. /**
  22268. * Copies the given float to the current Vector3 coordinates
  22269. * @param v defines the x, y, z and w coordinates of the operand
  22270. * @returns the current updated Vector3
  22271. */
  22272. setAll(v: number): Vector4;
  22273. /**
  22274. * Returns a new Vector4 set from the starting index of the given array.
  22275. * @param array the array to pull values from
  22276. * @param offset the offset into the array to start at
  22277. * @returns the new vector
  22278. */
  22279. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  22280. /**
  22281. * Updates the given vector "result" from the starting index of the given array.
  22282. * @param array the array to pull values from
  22283. * @param offset the offset into the array to start at
  22284. * @param result the vector to store the result in
  22285. */
  22286. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  22287. /**
  22288. * Updates the given vector "result" from the starting index of the given Float32Array.
  22289. * @param array the array to pull values from
  22290. * @param offset the offset into the array to start at
  22291. * @param result the vector to store the result in
  22292. */
  22293. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  22294. /**
  22295. * Updates the given vector "result" coordinates from the given floats.
  22296. * @param x float to set from
  22297. * @param y float to set from
  22298. * @param z float to set from
  22299. * @param w float to set from
  22300. * @param result the vector to the floats in
  22301. */
  22302. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  22303. /**
  22304. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  22305. * @returns the new vector
  22306. */
  22307. static Zero(): Vector4;
  22308. /**
  22309. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  22310. * @returns the new vector
  22311. */
  22312. static One(): Vector4;
  22313. /**
  22314. * Returns a new normalized Vector4 from the given one.
  22315. * @param vector the vector to normalize
  22316. * @returns the vector
  22317. */
  22318. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  22319. /**
  22320. * Updates the given vector "result" from the normalization of the given one.
  22321. * @param vector the vector to normalize
  22322. * @param result the vector to store the result in
  22323. */
  22324. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  22325. /**
  22326. * Returns a vector with the minimum values from the left and right vectors
  22327. * @param left left vector to minimize
  22328. * @param right right vector to minimize
  22329. * @returns a new vector with the minimum of the left and right vector values
  22330. */
  22331. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  22332. /**
  22333. * Returns a vector with the maximum values from the left and right vectors
  22334. * @param left left vector to maximize
  22335. * @param right right vector to maximize
  22336. * @returns a new vector with the maximum of the left and right vector values
  22337. */
  22338. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  22339. /**
  22340. * Returns the distance (float) between the vectors "value1" and "value2".
  22341. * @param value1 value to calulate the distance between
  22342. * @param value2 value to calulate the distance between
  22343. * @return the distance between the two vectors
  22344. */
  22345. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  22346. /**
  22347. * Returns the squared distance (float) between the vectors "value1" and "value2".
  22348. * @param value1 value to calulate the distance between
  22349. * @param value2 value to calulate the distance between
  22350. * @return the distance between the two vectors squared
  22351. */
  22352. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  22353. /**
  22354. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  22355. * @param value1 value to calulate the center between
  22356. * @param value2 value to calulate the center between
  22357. * @return the center between the two vectors
  22358. */
  22359. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  22360. /**
  22361. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  22362. * This methods computes transformed normalized direction vectors only.
  22363. * @param vector the vector to transform
  22364. * @param transformation the transformation matrix to apply
  22365. * @returns the new vector
  22366. */
  22367. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  22368. /**
  22369. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  22370. * This methods computes transformed normalized direction vectors only.
  22371. * @param vector the vector to transform
  22372. * @param transformation the transformation matrix to apply
  22373. * @param result the vector to store the result in
  22374. */
  22375. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  22376. /**
  22377. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  22378. * This methods computes transformed normalized direction vectors only.
  22379. * @param x value to transform
  22380. * @param y value to transform
  22381. * @param z value to transform
  22382. * @param w value to transform
  22383. * @param transformation the transformation matrix to apply
  22384. * @param result the vector to store the results in
  22385. */
  22386. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  22387. /**
  22388. * Creates a new Vector4 from a Vector3
  22389. * @param source defines the source data
  22390. * @param w defines the 4th component (default is 0)
  22391. * @returns a new Vector4
  22392. */
  22393. static FromVector3(source: Vector3, w?: number): Vector4;
  22394. }
  22395. /**
  22396. * Interface for the size containing width and height
  22397. */
  22398. interface ISize {
  22399. /**
  22400. * Width
  22401. */
  22402. width: number;
  22403. /**
  22404. * Heighht
  22405. */
  22406. height: number;
  22407. }
  22408. /**
  22409. * Size containing widht and height
  22410. */
  22411. class Size implements ISize {
  22412. /**
  22413. * Width
  22414. */
  22415. width: number;
  22416. /**
  22417. * Height
  22418. */
  22419. height: number;
  22420. /**
  22421. * Creates a Size object from the given width and height (floats).
  22422. * @param width width of the new size
  22423. * @param height height of the new size
  22424. */
  22425. constructor(width: number, height: number);
  22426. /**
  22427. * Returns a string with the Size width and height
  22428. * @returns a string with the Size width and height
  22429. */
  22430. toString(): string;
  22431. /**
  22432. * "Size"
  22433. * @returns the string "Size"
  22434. */
  22435. getClassName(): string;
  22436. /**
  22437. * Returns the Size hash code.
  22438. * @returns a hash code for a unique width and height
  22439. */
  22440. getHashCode(): number;
  22441. /**
  22442. * Updates the current size from the given one.
  22443. * @param src the given size
  22444. */
  22445. copyFrom(src: Size): void;
  22446. /**
  22447. * Updates in place the current Size from the given floats.
  22448. * @param width width of the new size
  22449. * @param height height of the new size
  22450. * @returns the updated Size.
  22451. */
  22452. copyFromFloats(width: number, height: number): Size;
  22453. /**
  22454. * Updates in place the current Size from the given floats.
  22455. * @param width width to set
  22456. * @param height height to set
  22457. * @returns the updated Size.
  22458. */
  22459. set(width: number, height: number): Size;
  22460. /**
  22461. * Multiplies the width and height by numbers
  22462. * @param w factor to multiple the width by
  22463. * @param h factor to multiple the height by
  22464. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  22465. */
  22466. multiplyByFloats(w: number, h: number): Size;
  22467. /**
  22468. * Clones the size
  22469. * @returns a new Size copied from the given one.
  22470. */
  22471. clone(): Size;
  22472. /**
  22473. * True if the current Size and the given one width and height are strictly equal.
  22474. * @param other the other size to compare against
  22475. * @returns True if the current Size and the given one width and height are strictly equal.
  22476. */
  22477. equals(other: Size): boolean;
  22478. /**
  22479. * The surface of the Size : width * height (float).
  22480. */
  22481. readonly surface: number;
  22482. /**
  22483. * Create a new size of zero
  22484. * @returns a new Size set to (0.0, 0.0)
  22485. */
  22486. static Zero(): Size;
  22487. /**
  22488. * Sums the width and height of two sizes
  22489. * @param otherSize size to add to this size
  22490. * @returns a new Size set as the addition result of the current Size and the given one.
  22491. */
  22492. add(otherSize: Size): Size;
  22493. /**
  22494. * Subtracts the width and height of two
  22495. * @param otherSize size to subtract to this size
  22496. * @returns a new Size set as the subtraction result of the given one from the current Size.
  22497. */
  22498. subtract(otherSize: Size): Size;
  22499. /**
  22500. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  22501. * @param start starting size to lerp between
  22502. * @param end end size to lerp between
  22503. * @param amount amount to lerp between the start and end values
  22504. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  22505. */
  22506. static Lerp(start: Size, end: Size, amount: number): Size;
  22507. }
  22508. /**
  22509. * Class used to store quaternion data
  22510. * @see https://en.wikipedia.org/wiki/Quaternion
  22511. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  22512. */
  22513. class Quaternion {
  22514. /** defines the first component (0 by default) */
  22515. x: number;
  22516. /** defines the second component (0 by default) */
  22517. y: number;
  22518. /** defines the third component (0 by default) */
  22519. z: number;
  22520. /** defines the fourth component (1.0 by default) */
  22521. w: number;
  22522. /**
  22523. * Creates a new Quaternion from the given floats
  22524. * @param x defines the first component (0 by default)
  22525. * @param y defines the second component (0 by default)
  22526. * @param z defines the third component (0 by default)
  22527. * @param w defines the fourth component (1.0 by default)
  22528. */
  22529. constructor(
  22530. /** defines the first component (0 by default) */
  22531. x?: number,
  22532. /** defines the second component (0 by default) */
  22533. y?: number,
  22534. /** defines the third component (0 by default) */
  22535. z?: number,
  22536. /** defines the fourth component (1.0 by default) */
  22537. w?: number);
  22538. /**
  22539. * Gets a string representation for the current quaternion
  22540. * @returns a string with the Quaternion coordinates
  22541. */
  22542. toString(): string;
  22543. /**
  22544. * Gets the class name of the quaternion
  22545. * @returns the string "Quaternion"
  22546. */
  22547. getClassName(): string;
  22548. /**
  22549. * Gets a hash code for this quaternion
  22550. * @returns the quaternion hash code
  22551. */
  22552. getHashCode(): number;
  22553. /**
  22554. * Copy the quaternion to an array
  22555. * @returns a new array populated with 4 elements from the quaternion coordinates
  22556. */
  22557. asArray(): number[];
  22558. /**
  22559. * Check if two quaternions are equals
  22560. * @param otherQuaternion defines the second operand
  22561. * @return true if the current quaternion and the given one coordinates are strictly equals
  22562. */
  22563. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  22564. /**
  22565. * Clone the current quaternion
  22566. * @returns a new quaternion copied from the current one
  22567. */
  22568. clone(): Quaternion;
  22569. /**
  22570. * Copy a quaternion to the current one
  22571. * @param other defines the other quaternion
  22572. * @returns the updated current quaternion
  22573. */
  22574. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  22575. /**
  22576. * Updates the current quaternion with the given float coordinates
  22577. * @param x defines the x coordinate
  22578. * @param y defines the y coordinate
  22579. * @param z defines the z coordinate
  22580. * @param w defines the w coordinate
  22581. * @returns the updated current quaternion
  22582. */
  22583. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  22584. /**
  22585. * Updates the current quaternion from the given float coordinates
  22586. * @param x defines the x coordinate
  22587. * @param y defines the y coordinate
  22588. * @param z defines the z coordinate
  22589. * @param w defines the w coordinate
  22590. * @returns the updated current quaternion
  22591. */
  22592. set(x: number, y: number, z: number, w: number): Quaternion;
  22593. /**
  22594. * Adds two quaternions
  22595. * @param other defines the second operand
  22596. * @returns a new quaternion as the addition result of the given one and the current quaternion
  22597. */
  22598. add(other: DeepImmutable<Quaternion>): Quaternion;
  22599. /**
  22600. * Add a quaternion to the current one
  22601. * @param other defines the quaternion to add
  22602. * @returns the current quaternion
  22603. */
  22604. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  22605. /**
  22606. * Subtract two quaternions
  22607. * @param other defines the second operand
  22608. * @returns a new quaternion as the subtraction result of the given one from the current one
  22609. */
  22610. subtract(other: Quaternion): Quaternion;
  22611. /**
  22612. * Multiplies the current quaternion by a scale factor
  22613. * @param value defines the scale factor
  22614. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  22615. */
  22616. scale(value: number): Quaternion;
  22617. /**
  22618. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  22619. * @param scale defines the scale factor
  22620. * @param result defines the Quaternion object where to store the result
  22621. * @returns the unmodified current quaternion
  22622. */
  22623. scaleToRef(scale: number, result: Quaternion): Quaternion;
  22624. /**
  22625. * Multiplies in place the current quaternion by a scale factor
  22626. * @param value defines the scale factor
  22627. * @returns the current modified quaternion
  22628. */
  22629. scaleInPlace(value: number): Quaternion;
  22630. /**
  22631. * Scale the current quaternion values by a factor and add the result to a given quaternion
  22632. * @param scale defines the scale factor
  22633. * @param result defines the Quaternion object where to store the result
  22634. * @returns the unmodified current quaternion
  22635. */
  22636. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  22637. /**
  22638. * Multiplies two quaternions
  22639. * @param q1 defines the second operand
  22640. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  22641. */
  22642. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  22643. /**
  22644. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  22645. * @param q1 defines the second operand
  22646. * @param result defines the target quaternion
  22647. * @returns the current quaternion
  22648. */
  22649. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  22650. /**
  22651. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  22652. * @param q1 defines the second operand
  22653. * @returns the currentupdated quaternion
  22654. */
  22655. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  22656. /**
  22657. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  22658. * @param ref defines the target quaternion
  22659. * @returns the current quaternion
  22660. */
  22661. conjugateToRef(ref: Quaternion): Quaternion;
  22662. /**
  22663. * Conjugates in place (1-q) the current quaternion
  22664. * @returns the current updated quaternion
  22665. */
  22666. conjugateInPlace(): Quaternion;
  22667. /**
  22668. * Conjugates in place (1-q) the current quaternion
  22669. * @returns a new quaternion
  22670. */
  22671. conjugate(): Quaternion;
  22672. /**
  22673. * Gets length of current quaternion
  22674. * @returns the quaternion length (float)
  22675. */
  22676. length(): number;
  22677. /**
  22678. * Normalize in place the current quaternion
  22679. * @returns the current updated quaternion
  22680. */
  22681. normalize(): Quaternion;
  22682. /**
  22683. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  22684. * @param order is a reserved parameter and is ignore for now
  22685. * @returns a new Vector3 containing the Euler angles
  22686. */
  22687. toEulerAngles(order?: string): Vector3;
  22688. /**
  22689. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  22690. * @param result defines the vector which will be filled with the Euler angles
  22691. * @param order is a reserved parameter and is ignore for now
  22692. * @returns the current unchanged quaternion
  22693. */
  22694. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  22695. /**
  22696. * Updates the given rotation matrix with the current quaternion values
  22697. * @param result defines the target matrix
  22698. * @returns the current unchanged quaternion
  22699. */
  22700. toRotationMatrix(result: Matrix): Quaternion;
  22701. /**
  22702. * Updates the current quaternion from the given rotation matrix values
  22703. * @param matrix defines the source matrix
  22704. * @returns the current updated quaternion
  22705. */
  22706. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  22707. /**
  22708. * Creates a new quaternion from a rotation matrix
  22709. * @param matrix defines the source matrix
  22710. * @returns a new quaternion created from the given rotation matrix values
  22711. */
  22712. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  22713. /**
  22714. * Updates the given quaternion with the given rotation matrix values
  22715. * @param matrix defines the source matrix
  22716. * @param result defines the target quaternion
  22717. */
  22718. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  22719. /**
  22720. * Returns the dot product (float) between the quaternions "left" and "right"
  22721. * @param left defines the left operand
  22722. * @param right defines the right operand
  22723. * @returns the dot product
  22724. */
  22725. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  22726. /**
  22727. * Checks if the two quaternions are close to each other
  22728. * @param quat0 defines the first quaternion to check
  22729. * @param quat1 defines the second quaternion to check
  22730. * @returns true if the two quaternions are close to each other
  22731. */
  22732. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  22733. /**
  22734. * Creates an empty quaternion
  22735. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  22736. */
  22737. static Zero(): Quaternion;
  22738. /**
  22739. * Inverse a given quaternion
  22740. * @param q defines the source quaternion
  22741. * @returns a new quaternion as the inverted current quaternion
  22742. */
  22743. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  22744. /**
  22745. * Inverse a given quaternion
  22746. * @param q defines the source quaternion
  22747. * @param result the quaternion the result will be stored in
  22748. * @returns the result quaternion
  22749. */
  22750. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  22751. /**
  22752. * Creates an identity quaternion
  22753. * @returns the identity quaternion
  22754. */
  22755. static Identity(): Quaternion;
  22756. /**
  22757. * Gets a boolean indicating if the given quaternion is identity
  22758. * @param quaternion defines the quaternion to check
  22759. * @returns true if the quaternion is identity
  22760. */
  22761. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  22762. /**
  22763. * Creates a quaternion from a rotation around an axis
  22764. * @param axis defines the axis to use
  22765. * @param angle defines the angle to use
  22766. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  22767. */
  22768. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  22769. /**
  22770. * Creates a rotation around an axis and stores it into the given quaternion
  22771. * @param axis defines the axis to use
  22772. * @param angle defines the angle to use
  22773. * @param result defines the target quaternion
  22774. * @returns the target quaternion
  22775. */
  22776. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  22777. /**
  22778. * Creates a new quaternion from data stored into an array
  22779. * @param array defines the data source
  22780. * @param offset defines the offset in the source array where the data starts
  22781. * @returns a new quaternion
  22782. */
  22783. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  22784. /**
  22785. * Create a quaternion from Euler rotation angles
  22786. * @param x Pitch
  22787. * @param y Yaw
  22788. * @param z Roll
  22789. * @returns the new Quaternion
  22790. */
  22791. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  22792. /**
  22793. * Updates a quaternion from Euler rotation angles
  22794. * @param x Pitch
  22795. * @param y Yaw
  22796. * @param z Roll
  22797. * @param result the quaternion to store the result
  22798. * @returns the updated quaternion
  22799. */
  22800. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  22801. /**
  22802. * Create a quaternion from Euler rotation vector
  22803. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22804. * @returns the new Quaternion
  22805. */
  22806. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  22807. /**
  22808. * Updates a quaternion from Euler rotation vector
  22809. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22810. * @param result the quaternion to store the result
  22811. * @returns the updated quaternion
  22812. */
  22813. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  22814. /**
  22815. * Creates a new quaternion from the given Euler float angles (y, x, z)
  22816. * @param yaw defines the rotation around Y axis
  22817. * @param pitch defines the rotation around X axis
  22818. * @param roll defines the rotation around Z axis
  22819. * @returns the new quaternion
  22820. */
  22821. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  22822. /**
  22823. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  22824. * @param yaw defines the rotation around Y axis
  22825. * @param pitch defines the rotation around X axis
  22826. * @param roll defines the rotation around Z axis
  22827. * @param result defines the target quaternion
  22828. */
  22829. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  22830. /**
  22831. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  22832. * @param alpha defines the rotation around first axis
  22833. * @param beta defines the rotation around second axis
  22834. * @param gamma defines the rotation around third axis
  22835. * @returns the new quaternion
  22836. */
  22837. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  22838. /**
  22839. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  22840. * @param alpha defines the rotation around first axis
  22841. * @param beta defines the rotation around second axis
  22842. * @param gamma defines the rotation around third axis
  22843. * @param result defines the target quaternion
  22844. */
  22845. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  22846. /**
  22847. * 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)
  22848. * @param axis1 defines the first axis
  22849. * @param axis2 defines the second axis
  22850. * @param axis3 defines the third axis
  22851. * @returns the new quaternion
  22852. */
  22853. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  22854. /**
  22855. * 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
  22856. * @param axis1 defines the first axis
  22857. * @param axis2 defines the second axis
  22858. * @param axis3 defines the third axis
  22859. * @param ref defines the target quaternion
  22860. */
  22861. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  22862. /**
  22863. * Interpolates between two quaternions
  22864. * @param left defines first quaternion
  22865. * @param right defines second quaternion
  22866. * @param amount defines the gradient to use
  22867. * @returns the new interpolated quaternion
  22868. */
  22869. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  22870. /**
  22871. * Interpolates between two quaternions and stores it into a target quaternion
  22872. * @param left defines first quaternion
  22873. * @param right defines second quaternion
  22874. * @param amount defines the gradient to use
  22875. * @param result defines the target quaternion
  22876. */
  22877. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  22878. /**
  22879. * Interpolate between two quaternions using Hermite interpolation
  22880. * @param value1 defines first quaternion
  22881. * @param tangent1 defines the incoming tangent
  22882. * @param value2 defines second quaternion
  22883. * @param tangent2 defines the outgoing tangent
  22884. * @param amount defines the target quaternion
  22885. * @returns the new interpolated quaternion
  22886. */
  22887. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  22888. }
  22889. /**
  22890. * Class used to store matrix data (4x4)
  22891. */
  22892. class Matrix {
  22893. private static _updateFlagSeed;
  22894. private static _identityReadOnly;
  22895. private _isIdentity;
  22896. private _isIdentityDirty;
  22897. private _isIdentity3x2;
  22898. private _isIdentity3x2Dirty;
  22899. /**
  22900. * Gets the update flag of the matrix which is an unique number for the matrix.
  22901. * It will be incremented every time the matrix data change.
  22902. * You can use it to speed the comparison between two versions of the same matrix.
  22903. */
  22904. updateFlag: number;
  22905. private readonly _m;
  22906. /**
  22907. * Gets the internal data of the matrix
  22908. */
  22909. readonly m: DeepImmutable<Float32Array>;
  22910. /** @hidden */
  22911. _markAsUpdated(): void;
  22912. /** @hidden */
  22913. private _updateIdentityStatus;
  22914. /**
  22915. * Creates an empty matrix (filled with zeros)
  22916. */
  22917. constructor();
  22918. /**
  22919. * Check if the current matrix is identity
  22920. * @returns true is the matrix is the identity matrix
  22921. */
  22922. isIdentity(): boolean;
  22923. /**
  22924. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  22925. * @returns true is the matrix is the identity matrix
  22926. */
  22927. isIdentityAs3x2(): boolean;
  22928. /**
  22929. * Gets the determinant of the matrix
  22930. * @returns the matrix determinant
  22931. */
  22932. determinant(): number;
  22933. /**
  22934. * Returns the matrix as a Float32Array
  22935. * @returns the matrix underlying array
  22936. */
  22937. toArray(): DeepImmutable<Float32Array>;
  22938. /**
  22939. * Returns the matrix as a Float32Array
  22940. * @returns the matrix underlying array.
  22941. */
  22942. asArray(): DeepImmutable<Float32Array>;
  22943. /**
  22944. * Inverts the current matrix in place
  22945. * @returns the current inverted matrix
  22946. */
  22947. invert(): Matrix;
  22948. /**
  22949. * Sets all the matrix elements to zero
  22950. * @returns the current matrix
  22951. */
  22952. reset(): Matrix;
  22953. /**
  22954. * Adds the current matrix with a second one
  22955. * @param other defines the matrix to add
  22956. * @returns a new matrix as the addition of the current matrix and the given one
  22957. */
  22958. add(other: DeepImmutable<Matrix>): Matrix;
  22959. /**
  22960. * Sets the given matrix "result" to the addition of the current matrix and the given one
  22961. * @param other defines the matrix to add
  22962. * @param result defines the target matrix
  22963. * @returns the current matrix
  22964. */
  22965. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  22966. /**
  22967. * Adds in place the given matrix to the current matrix
  22968. * @param other defines the second operand
  22969. * @returns the current updated matrix
  22970. */
  22971. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  22972. /**
  22973. * Sets the given matrix to the current inverted Matrix
  22974. * @param other defines the target matrix
  22975. * @returns the unmodified current matrix
  22976. */
  22977. invertToRef(other: Matrix): Matrix;
  22978. /**
  22979. * add a value at the specified position in the current Matrix
  22980. * @param index the index of the value within the matrix. between 0 and 15.
  22981. * @param value the value to be added
  22982. * @returns the current updated matrix
  22983. */
  22984. addAtIndex(index: number, value: number): Matrix;
  22985. /**
  22986. * mutiply the specified position in the current Matrix by a value
  22987. * @param index the index of the value within the matrix. between 0 and 15.
  22988. * @param value the value to be added
  22989. * @returns the current updated matrix
  22990. */
  22991. multiplyAtIndex(index: number, value: number): Matrix;
  22992. /**
  22993. * Inserts the translation vector (using 3 floats) in the current matrix
  22994. * @param x defines the 1st component of the translation
  22995. * @param y defines the 2nd component of the translation
  22996. * @param z defines the 3rd component of the translation
  22997. * @returns the current updated matrix
  22998. */
  22999. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  23000. /**
  23001. * Inserts the translation vector in the current matrix
  23002. * @param vector3 defines the translation to insert
  23003. * @returns the current updated matrix
  23004. */
  23005. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  23006. /**
  23007. * Gets the translation value of the current matrix
  23008. * @returns a new Vector3 as the extracted translation from the matrix
  23009. */
  23010. getTranslation(): Vector3;
  23011. /**
  23012. * Fill a Vector3 with the extracted translation from the matrix
  23013. * @param result defines the Vector3 where to store the translation
  23014. * @returns the current matrix
  23015. */
  23016. getTranslationToRef(result: Vector3): Matrix;
  23017. /**
  23018. * Remove rotation and scaling part from the matrix
  23019. * @returns the updated matrix
  23020. */
  23021. removeRotationAndScaling(): Matrix;
  23022. /**
  23023. * Multiply two matrices
  23024. * @param other defines the second operand
  23025. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  23026. */
  23027. multiply(other: DeepImmutable<Matrix>): Matrix;
  23028. /**
  23029. * Copy the current matrix from the given one
  23030. * @param other defines the source matrix
  23031. * @returns the current updated matrix
  23032. */
  23033. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  23034. /**
  23035. * Populates the given array from the starting index with the current matrix values
  23036. * @param array defines the target array
  23037. * @param offset defines the offset in the target array where to start storing values
  23038. * @returns the current matrix
  23039. */
  23040. copyToArray(array: Float32Array, offset?: number): Matrix;
  23041. /**
  23042. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  23043. * @param other defines the second operand
  23044. * @param result defines the matrix where to store the multiplication
  23045. * @returns the current matrix
  23046. */
  23047. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  23048. /**
  23049. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  23050. * @param other defines the second operand
  23051. * @param result defines the array where to store the multiplication
  23052. * @param offset defines the offset in the target array where to start storing values
  23053. * @returns the current matrix
  23054. */
  23055. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  23056. /**
  23057. * Check equality between this matrix and a second one
  23058. * @param value defines the second matrix to compare
  23059. * @returns true is the current matrix and the given one values are strictly equal
  23060. */
  23061. equals(value: DeepImmutable<Matrix>): boolean;
  23062. /**
  23063. * Clone the current matrix
  23064. * @returns a new matrix from the current matrix
  23065. */
  23066. clone(): Matrix;
  23067. /**
  23068. * Returns the name of the current matrix class
  23069. * @returns the string "Matrix"
  23070. */
  23071. getClassName(): string;
  23072. /**
  23073. * Gets the hash code of the current matrix
  23074. * @returns the hash code
  23075. */
  23076. getHashCode(): number;
  23077. /**
  23078. * Decomposes the current Matrix into a translation, rotation and scaling components
  23079. * @param scale defines the scale vector3 given as a reference to update
  23080. * @param rotation defines the rotation quaternion given as a reference to update
  23081. * @param translation defines the translation vector3 given as a reference to update
  23082. * @returns true if operation was successful
  23083. */
  23084. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  23085. /**
  23086. * Gets specific row of the matrix
  23087. * @param index defines the number of the row to get
  23088. * @returns the index-th row of the current matrix as a new Vector4
  23089. */
  23090. getRow(index: number): Nullable<Vector4>;
  23091. /**
  23092. * Sets the index-th row of the current matrix to the vector4 values
  23093. * @param index defines the number of the row to set
  23094. * @param row defines the target vector4
  23095. * @returns the updated current matrix
  23096. */
  23097. setRow(index: number, row: Vector4): Matrix;
  23098. /**
  23099. * Compute the transpose of the matrix
  23100. * @returns the new transposed matrix
  23101. */
  23102. transpose(): Matrix;
  23103. /**
  23104. * Compute the transpose of the matrix and store it in a given matrix
  23105. * @param result defines the target matrix
  23106. * @returns the current matrix
  23107. */
  23108. transposeToRef(result: Matrix): Matrix;
  23109. /**
  23110. * Sets the index-th row of the current matrix with the given 4 x float values
  23111. * @param index defines the row index
  23112. * @param x defines the x component to set
  23113. * @param y defines the y component to set
  23114. * @param z defines the z component to set
  23115. * @param w defines the w component to set
  23116. * @returns the updated current matrix
  23117. */
  23118. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  23119. /**
  23120. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  23121. * @param scale defines the scale factor
  23122. * @returns a new matrix
  23123. */
  23124. scale(scale: number): Matrix;
  23125. /**
  23126. * Scale the current matrix values by a factor to a given result matrix
  23127. * @param scale defines the scale factor
  23128. * @param result defines the matrix to store the result
  23129. * @returns the current matrix
  23130. */
  23131. scaleToRef(scale: number, result: Matrix): Matrix;
  23132. /**
  23133. * Scale the current matrix values by a factor and add the result to a given matrix
  23134. * @param scale defines the scale factor
  23135. * @param result defines the Matrix to store the result
  23136. * @returns the current matrix
  23137. */
  23138. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  23139. /**
  23140. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  23141. * @param ref matrix to store the result
  23142. */
  23143. toNormalMatrix(ref: Matrix): void;
  23144. /**
  23145. * Gets only rotation part of the current matrix
  23146. * @returns a new matrix sets to the extracted rotation matrix from the current one
  23147. */
  23148. getRotationMatrix(): Matrix;
  23149. /**
  23150. * Extracts the rotation matrix from the current one and sets it as the given "result"
  23151. * @param result defines the target matrix to store data to
  23152. * @returns the current matrix
  23153. */
  23154. getRotationMatrixToRef(result: Matrix): Matrix;
  23155. /**
  23156. * Toggles model matrix from being right handed to left handed in place and vice versa
  23157. */
  23158. toggleModelMatrixHandInPlace(): void;
  23159. /**
  23160. * Toggles projection matrix from being right handed to left handed in place and vice versa
  23161. */
  23162. toggleProjectionMatrixHandInPlace(): void;
  23163. /**
  23164. * Creates a matrix from an array
  23165. * @param array defines the source array
  23166. * @param offset defines an offset in the source array
  23167. * @returns a new Matrix set from the starting index of the given array
  23168. */
  23169. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  23170. /**
  23171. * Copy the content of an array into a given matrix
  23172. * @param array defines the source array
  23173. * @param offset defines an offset in the source array
  23174. * @param result defines the target matrix
  23175. */
  23176. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  23177. /**
  23178. * Stores an array into a matrix after having multiplied each component by a given factor
  23179. * @param array defines the source array
  23180. * @param offset defines the offset in the source array
  23181. * @param scale defines the scaling factor
  23182. * @param result defines the target matrix
  23183. */
  23184. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  23185. /**
  23186. * Gets an identity matrix that must not be updated
  23187. */
  23188. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  23189. /**
  23190. * Stores a list of values (16) inside a given matrix
  23191. * @param initialM11 defines 1st value of 1st row
  23192. * @param initialM12 defines 2nd value of 1st row
  23193. * @param initialM13 defines 3rd value of 1st row
  23194. * @param initialM14 defines 4th value of 1st row
  23195. * @param initialM21 defines 1st value of 2nd row
  23196. * @param initialM22 defines 2nd value of 2nd row
  23197. * @param initialM23 defines 3rd value of 2nd row
  23198. * @param initialM24 defines 4th value of 2nd row
  23199. * @param initialM31 defines 1st value of 3rd row
  23200. * @param initialM32 defines 2nd value of 3rd row
  23201. * @param initialM33 defines 3rd value of 3rd row
  23202. * @param initialM34 defines 4th value of 3rd row
  23203. * @param initialM41 defines 1st value of 4th row
  23204. * @param initialM42 defines 2nd value of 4th row
  23205. * @param initialM43 defines 3rd value of 4th row
  23206. * @param initialM44 defines 4th value of 4th row
  23207. * @param result defines the target matrix
  23208. */
  23209. 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;
  23210. /**
  23211. * Creates new matrix from a list of values (16)
  23212. * @param initialM11 defines 1st value of 1st row
  23213. * @param initialM12 defines 2nd value of 1st row
  23214. * @param initialM13 defines 3rd value of 1st row
  23215. * @param initialM14 defines 4th value of 1st row
  23216. * @param initialM21 defines 1st value of 2nd row
  23217. * @param initialM22 defines 2nd value of 2nd row
  23218. * @param initialM23 defines 3rd value of 2nd row
  23219. * @param initialM24 defines 4th value of 2nd row
  23220. * @param initialM31 defines 1st value of 3rd row
  23221. * @param initialM32 defines 2nd value of 3rd row
  23222. * @param initialM33 defines 3rd value of 3rd row
  23223. * @param initialM34 defines 4th value of 3rd row
  23224. * @param initialM41 defines 1st value of 4th row
  23225. * @param initialM42 defines 2nd value of 4th row
  23226. * @param initialM43 defines 3rd value of 4th row
  23227. * @param initialM44 defines 4th value of 4th row
  23228. * @returns the new matrix
  23229. */
  23230. 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;
  23231. /**
  23232. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  23233. * @param scale defines the scale vector3
  23234. * @param rotation defines the rotation quaternion
  23235. * @param translation defines the translation vector3
  23236. * @returns a new matrix
  23237. */
  23238. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  23239. /**
  23240. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  23241. * @param scale defines the scale vector3
  23242. * @param rotation defines the rotation quaternion
  23243. * @param translation defines the translation vector3
  23244. * @param result defines the target matrix
  23245. */
  23246. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  23247. /**
  23248. * Creates a new identity matrix
  23249. * @returns a new identity matrix
  23250. */
  23251. static Identity(): Matrix;
  23252. /**
  23253. * Creates a new identity matrix and stores the result in a given matrix
  23254. * @param result defines the target matrix
  23255. */
  23256. static IdentityToRef(result: Matrix): void;
  23257. /**
  23258. * Creates a new zero matrix
  23259. * @returns a new zero matrix
  23260. */
  23261. static Zero(): Matrix;
  23262. /**
  23263. * Creates a new rotation matrix for "angle" radians around the X axis
  23264. * @param angle defines the angle (in radians) to use
  23265. * @return the new matrix
  23266. */
  23267. static RotationX(angle: number): Matrix;
  23268. /**
  23269. * Creates a new matrix as the invert of a given matrix
  23270. * @param source defines the source matrix
  23271. * @returns the new matrix
  23272. */
  23273. static Invert(source: DeepImmutable<Matrix>): Matrix;
  23274. /**
  23275. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  23276. * @param angle defines the angle (in radians) to use
  23277. * @param result defines the target matrix
  23278. */
  23279. static RotationXToRef(angle: number, result: Matrix): void;
  23280. /**
  23281. * Creates a new rotation matrix for "angle" radians around the Y axis
  23282. * @param angle defines the angle (in radians) to use
  23283. * @return the new matrix
  23284. */
  23285. static RotationY(angle: number): Matrix;
  23286. /**
  23287. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  23288. * @param angle defines the angle (in radians) to use
  23289. * @param result defines the target matrix
  23290. */
  23291. static RotationYToRef(angle: number, result: Matrix): void;
  23292. /**
  23293. * Creates a new rotation matrix for "angle" radians around the Z axis
  23294. * @param angle defines the angle (in radians) to use
  23295. * @return the new matrix
  23296. */
  23297. static RotationZ(angle: number): Matrix;
  23298. /**
  23299. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  23300. * @param angle defines the angle (in radians) to use
  23301. * @param result defines the target matrix
  23302. */
  23303. static RotationZToRef(angle: number, result: Matrix): void;
  23304. /**
  23305. * Creates a new rotation matrix for "angle" radians around the given axis
  23306. * @param axis defines the axis to use
  23307. * @param angle defines the angle (in radians) to use
  23308. * @return the new matrix
  23309. */
  23310. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  23311. /**
  23312. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  23313. * @param axis defines the axis to use
  23314. * @param angle defines the angle (in radians) to use
  23315. * @param result defines the target matrix
  23316. */
  23317. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  23318. /**
  23319. * Creates a rotation matrix
  23320. * @param yaw defines the yaw angle in radians (Y axis)
  23321. * @param pitch defines the pitch angle in radians (X axis)
  23322. * @param roll defines the roll angle in radians (X axis)
  23323. * @returns the new rotation matrix
  23324. */
  23325. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  23326. /**
  23327. * Creates a rotation matrix and stores it in a given matrix
  23328. * @param yaw defines the yaw angle in radians (Y axis)
  23329. * @param pitch defines the pitch angle in radians (X axis)
  23330. * @param roll defines the roll angle in radians (X axis)
  23331. * @param result defines the target matrix
  23332. */
  23333. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  23334. /**
  23335. * Creates a scaling matrix
  23336. * @param x defines the scale factor on X axis
  23337. * @param y defines the scale factor on Y axis
  23338. * @param z defines the scale factor on Z axis
  23339. * @returns the new matrix
  23340. */
  23341. static Scaling(x: number, y: number, z: number): Matrix;
  23342. /**
  23343. * Creates a scaling matrix and stores it in a given matrix
  23344. * @param x defines the scale factor on X axis
  23345. * @param y defines the scale factor on Y axis
  23346. * @param z defines the scale factor on Z axis
  23347. * @param result defines the target matrix
  23348. */
  23349. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  23350. /**
  23351. * Creates a translation matrix
  23352. * @param x defines the translation on X axis
  23353. * @param y defines the translation on Y axis
  23354. * @param z defines the translationon Z axis
  23355. * @returns the new matrix
  23356. */
  23357. static Translation(x: number, y: number, z: number): Matrix;
  23358. /**
  23359. * Creates a translation matrix and stores it in a given matrix
  23360. * @param x defines the translation on X axis
  23361. * @param y defines the translation on Y axis
  23362. * @param z defines the translationon Z axis
  23363. * @param result defines the target matrix
  23364. */
  23365. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  23366. /**
  23367. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23368. * @param startValue defines the start value
  23369. * @param endValue defines the end value
  23370. * @param gradient defines the gradient factor
  23371. * @returns the new matrix
  23372. */
  23373. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  23374. /**
  23375. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23376. * @param startValue defines the start value
  23377. * @param endValue defines the end value
  23378. * @param gradient defines the gradient factor
  23379. * @param result defines the Matrix object where to store data
  23380. */
  23381. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  23382. /**
  23383. * Builds a new matrix whose values are computed by:
  23384. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23385. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23386. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23387. * @param startValue defines the first matrix
  23388. * @param endValue defines the second matrix
  23389. * @param gradient defines the gradient between the two matrices
  23390. * @returns the new matrix
  23391. */
  23392. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  23393. /**
  23394. * Update a matrix to values which are computed by:
  23395. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23396. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23397. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23398. * @param startValue defines the first matrix
  23399. * @param endValue defines the second matrix
  23400. * @param gradient defines the gradient between the two matrices
  23401. * @param result defines the target matrix
  23402. */
  23403. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  23404. /**
  23405. * 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"
  23406. * This function works in left handed mode
  23407. * @param eye defines the final position of the entity
  23408. * @param target defines where the entity should look at
  23409. * @param up defines the up vector for the entity
  23410. * @returns the new matrix
  23411. */
  23412. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  23413. /**
  23414. * 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".
  23415. * This function works in left handed mode
  23416. * @param eye defines the final position of the entity
  23417. * @param target defines where the entity should look at
  23418. * @param up defines the up vector for the entity
  23419. * @param result defines the target matrix
  23420. */
  23421. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  23422. /**
  23423. * 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"
  23424. * This function works in right handed mode
  23425. * @param eye defines the final position of the entity
  23426. * @param target defines where the entity should look at
  23427. * @param up defines the up vector for the entity
  23428. * @returns the new matrix
  23429. */
  23430. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  23431. /**
  23432. * 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".
  23433. * This function works in right handed mode
  23434. * @param eye defines the final position of the entity
  23435. * @param target defines where the entity should look at
  23436. * @param up defines the up vector for the entity
  23437. * @param result defines the target matrix
  23438. */
  23439. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  23440. /**
  23441. * Create a left-handed orthographic projection matrix
  23442. * @param width defines the viewport width
  23443. * @param height defines the viewport height
  23444. * @param znear defines the near clip plane
  23445. * @param zfar defines the far clip plane
  23446. * @returns a new matrix as a left-handed orthographic projection matrix
  23447. */
  23448. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23449. /**
  23450. * Store a left-handed orthographic projection to a given matrix
  23451. * @param width defines the viewport width
  23452. * @param height defines the viewport height
  23453. * @param znear defines the near clip plane
  23454. * @param zfar defines the far clip plane
  23455. * @param result defines the target matrix
  23456. */
  23457. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  23458. /**
  23459. * Create a left-handed orthographic projection matrix
  23460. * @param left defines the viewport left coordinate
  23461. * @param right defines the viewport right coordinate
  23462. * @param bottom defines the viewport bottom coordinate
  23463. * @param top defines the viewport top coordinate
  23464. * @param znear defines the near clip plane
  23465. * @param zfar defines the far clip plane
  23466. * @returns a new matrix as a left-handed orthographic projection matrix
  23467. */
  23468. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23469. /**
  23470. * Stores a left-handed orthographic projection into a given matrix
  23471. * @param left defines the viewport left coordinate
  23472. * @param right defines the viewport right coordinate
  23473. * @param bottom defines the viewport bottom coordinate
  23474. * @param top defines the viewport top coordinate
  23475. * @param znear defines the near clip plane
  23476. * @param zfar defines the far clip plane
  23477. * @param result defines the target matrix
  23478. */
  23479. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23480. /**
  23481. * Creates a right-handed orthographic projection matrix
  23482. * @param left defines the viewport left coordinate
  23483. * @param right defines the viewport right coordinate
  23484. * @param bottom defines the viewport bottom coordinate
  23485. * @param top defines the viewport top coordinate
  23486. * @param znear defines the near clip plane
  23487. * @param zfar defines the far clip plane
  23488. * @returns a new matrix as a right-handed orthographic projection matrix
  23489. */
  23490. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23491. /**
  23492. * Stores a right-handed orthographic projection into a given matrix
  23493. * @param left defines the viewport left coordinate
  23494. * @param right defines the viewport right coordinate
  23495. * @param bottom defines the viewport bottom coordinate
  23496. * @param top defines the viewport top coordinate
  23497. * @param znear defines the near clip plane
  23498. * @param zfar defines the far clip plane
  23499. * @param result defines the target matrix
  23500. */
  23501. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23502. /**
  23503. * Creates a left-handed perspective projection matrix
  23504. * @param width defines the viewport width
  23505. * @param height defines the viewport height
  23506. * @param znear defines the near clip plane
  23507. * @param zfar defines the far clip plane
  23508. * @returns a new matrix as a left-handed perspective projection matrix
  23509. */
  23510. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23511. /**
  23512. * Creates a left-handed perspective projection matrix
  23513. * @param fov defines the horizontal field of view
  23514. * @param aspect defines the aspect ratio
  23515. * @param znear defines the near clip plane
  23516. * @param zfar defines the far clip plane
  23517. * @returns a new matrix as a left-handed perspective projection matrix
  23518. */
  23519. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23520. /**
  23521. * Stores a left-handed perspective projection into a given matrix
  23522. * @param fov defines the horizontal field of view
  23523. * @param aspect defines the aspect ratio
  23524. * @param znear defines the near clip plane
  23525. * @param zfar defines the far clip plane
  23526. * @param result defines the target matrix
  23527. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23528. */
  23529. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23530. /**
  23531. * Creates a right-handed perspective projection matrix
  23532. * @param fov defines the horizontal field of view
  23533. * @param aspect defines the aspect ratio
  23534. * @param znear defines the near clip plane
  23535. * @param zfar defines the far clip plane
  23536. * @returns a new matrix as a right-handed perspective projection matrix
  23537. */
  23538. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23539. /**
  23540. * Stores a right-handed perspective projection into a given matrix
  23541. * @param fov defines the horizontal field of view
  23542. * @param aspect defines the aspect ratio
  23543. * @param znear defines the near clip plane
  23544. * @param zfar defines the far clip plane
  23545. * @param result defines the target matrix
  23546. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23547. */
  23548. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23549. /**
  23550. * Stores a perspective projection for WebVR info a given matrix
  23551. * @param fov defines the field of view
  23552. * @param znear defines the near clip plane
  23553. * @param zfar defines the far clip plane
  23554. * @param result defines the target matrix
  23555. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  23556. */
  23557. static PerspectiveFovWebVRToRef(fov: {
  23558. upDegrees: number;
  23559. downDegrees: number;
  23560. leftDegrees: number;
  23561. rightDegrees: number;
  23562. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  23563. /**
  23564. * Computes a complete transformation matrix
  23565. * @param viewport defines the viewport to use
  23566. * @param world defines the world matrix
  23567. * @param view defines the view matrix
  23568. * @param projection defines the projection matrix
  23569. * @param zmin defines the near clip plane
  23570. * @param zmax defines the far clip plane
  23571. * @returns the transformation matrix
  23572. */
  23573. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  23574. /**
  23575. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  23576. * @param matrix defines the matrix to use
  23577. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  23578. */
  23579. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  23580. /**
  23581. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  23582. * @param matrix defines the matrix to use
  23583. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  23584. */
  23585. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  23586. /**
  23587. * Compute the transpose of a given matrix
  23588. * @param matrix defines the matrix to transpose
  23589. * @returns the new matrix
  23590. */
  23591. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  23592. /**
  23593. * Compute the transpose of a matrix and store it in a target matrix
  23594. * @param matrix defines the matrix to transpose
  23595. * @param result defines the target matrix
  23596. */
  23597. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  23598. /**
  23599. * Computes a reflection matrix from a plane
  23600. * @param plane defines the reflection plane
  23601. * @returns a new matrix
  23602. */
  23603. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  23604. /**
  23605. * Computes a reflection matrix from a plane
  23606. * @param plane defines the reflection plane
  23607. * @param result defines the target matrix
  23608. */
  23609. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  23610. /**
  23611. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  23612. * @param xaxis defines the value of the 1st axis
  23613. * @param yaxis defines the value of the 2nd axis
  23614. * @param zaxis defines the value of the 3rd axis
  23615. * @param result defines the target matrix
  23616. */
  23617. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  23618. /**
  23619. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  23620. * @param quat defines the quaternion to use
  23621. * @param result defines the target matrix
  23622. */
  23623. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  23624. }
  23625. /**
  23626. * Represens a plane by the equation ax + by + cz + d = 0
  23627. */
  23628. class Plane {
  23629. /**
  23630. * Normal of the plane (a,b,c)
  23631. */
  23632. normal: Vector3;
  23633. /**
  23634. * d component of the plane
  23635. */
  23636. d: number;
  23637. /**
  23638. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  23639. * @param a a component of the plane
  23640. * @param b b component of the plane
  23641. * @param c c component of the plane
  23642. * @param d d component of the plane
  23643. */
  23644. constructor(a: number, b: number, c: number, d: number);
  23645. /**
  23646. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  23647. */
  23648. asArray(): number[];
  23649. /**
  23650. * @returns a new plane copied from the current Plane.
  23651. */
  23652. clone(): Plane;
  23653. /**
  23654. * @returns the string "Plane".
  23655. */
  23656. getClassName(): string;
  23657. /**
  23658. * @returns the Plane hash code.
  23659. */
  23660. getHashCode(): number;
  23661. /**
  23662. * Normalize the current Plane in place.
  23663. * @returns the updated Plane.
  23664. */
  23665. normalize(): Plane;
  23666. /**
  23667. * Applies a transformation the plane and returns the result
  23668. * @param transformation the transformation matrix to be applied to the plane
  23669. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  23670. */
  23671. transform(transformation: DeepImmutable<Matrix>): Plane;
  23672. /**
  23673. * Calcualtte the dot product between the point and the plane normal
  23674. * @param point point to calculate the dot product with
  23675. * @returns the dot product (float) of the point coordinates and the plane normal.
  23676. */
  23677. dotCoordinate(point: DeepImmutable<Vector3>): number;
  23678. /**
  23679. * Updates the current Plane from the plane defined by the three given points.
  23680. * @param point1 one of the points used to contruct the plane
  23681. * @param point2 one of the points used to contruct the plane
  23682. * @param point3 one of the points used to contruct the plane
  23683. * @returns the updated Plane.
  23684. */
  23685. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  23686. /**
  23687. * Checks if the plane is facing a given direction
  23688. * @param direction the direction to check if the plane is facing
  23689. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  23690. * @returns True is the vector "direction" is the same side than the plane normal.
  23691. */
  23692. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  23693. /**
  23694. * Calculates the distance to a point
  23695. * @param point point to calculate distance to
  23696. * @returns the signed distance (float) from the given point to the Plane.
  23697. */
  23698. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  23699. /**
  23700. * Creates a plane from an array
  23701. * @param array the array to create a plane from
  23702. * @returns a new Plane from the given array.
  23703. */
  23704. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  23705. /**
  23706. * Creates a plane from three points
  23707. * @param point1 point used to create the plane
  23708. * @param point2 point used to create the plane
  23709. * @param point3 point used to create the plane
  23710. * @returns a new Plane defined by the three given points.
  23711. */
  23712. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  23713. /**
  23714. * Creates a plane from an origin point and a normal
  23715. * @param origin origin of the plane to be constructed
  23716. * @param normal normal of the plane to be constructed
  23717. * @returns a new Plane the normal vector to this plane at the given origin point.
  23718. * Note : the vector "normal" is updated because normalized.
  23719. */
  23720. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  23721. /**
  23722. * Calculates the distance from a plane and a point
  23723. * @param origin origin of the plane to be constructed
  23724. * @param normal normal of the plane to be constructed
  23725. * @param point point to calculate distance to
  23726. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  23727. */
  23728. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  23729. }
  23730. /**
  23731. * Class used to represent a viewport on screen
  23732. */
  23733. class Viewport {
  23734. /** viewport left coordinate */
  23735. x: number;
  23736. /** viewport top coordinate */
  23737. y: number;
  23738. /**viewport width */
  23739. width: number;
  23740. /** viewport height */
  23741. height: number;
  23742. /**
  23743. * Creates a Viewport object located at (x, y) and sized (width, height)
  23744. * @param x defines viewport left coordinate
  23745. * @param y defines viewport top coordinate
  23746. * @param width defines the viewport width
  23747. * @param height defines the viewport height
  23748. */
  23749. constructor(
  23750. /** viewport left coordinate */
  23751. x: number,
  23752. /** viewport top coordinate */
  23753. y: number,
  23754. /**viewport width */
  23755. width: number,
  23756. /** viewport height */
  23757. height: number);
  23758. /**
  23759. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  23760. * @param renderWidthOrEngine defines either an engine or the rendering width
  23761. * @param renderHeight defines the rendering height
  23762. * @returns a new Viewport
  23763. */
  23764. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  23765. /**
  23766. * Returns a new Viewport copied from the current one
  23767. * @returns a new Viewport
  23768. */
  23769. clone(): Viewport;
  23770. }
  23771. /**
  23772. * Reprasents a camera frustum
  23773. */
  23774. class Frustum {
  23775. /**
  23776. * Gets the planes representing the frustum
  23777. * @param transform matrix to be applied to the returned planes
  23778. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  23779. */
  23780. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  23781. /**
  23782. * Gets the near frustum plane transformed by the transform matrix
  23783. * @param transform transformation matrix to be applied to the resulting frustum plane
  23784. * @param frustumPlane the resuling frustum plane
  23785. */
  23786. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23787. /**
  23788. * Gets the far frustum plane transformed by the transform matrix
  23789. * @param transform transformation matrix to be applied to the resulting frustum plane
  23790. * @param frustumPlane the resuling frustum plane
  23791. */
  23792. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23793. /**
  23794. * Gets the left frustum plane transformed by the transform matrix
  23795. * @param transform transformation matrix to be applied to the resulting frustum plane
  23796. * @param frustumPlane the resuling frustum plane
  23797. */
  23798. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23799. /**
  23800. * Gets the right frustum plane transformed by the transform matrix
  23801. * @param transform transformation matrix to be applied to the resulting frustum plane
  23802. * @param frustumPlane the resuling frustum plane
  23803. */
  23804. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23805. /**
  23806. * Gets the top frustum plane transformed by the transform matrix
  23807. * @param transform transformation matrix to be applied to the resulting frustum plane
  23808. * @param frustumPlane the resuling frustum plane
  23809. */
  23810. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23811. /**
  23812. * Gets the bottom frustum plane transformed by the transform matrix
  23813. * @param transform transformation matrix to be applied to the resulting frustum plane
  23814. * @param frustumPlane the resuling frustum plane
  23815. */
  23816. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23817. /**
  23818. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  23819. * @param transform transformation matrix to be applied to the resulting frustum planes
  23820. * @param frustumPlanes the resuling frustum planes
  23821. */
  23822. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  23823. }
  23824. /** Defines supported spaces */
  23825. enum Space {
  23826. /** Local (object) space */
  23827. LOCAL = 0,
  23828. /** World space */
  23829. WORLD = 1,
  23830. /** Bone space */
  23831. BONE = 2
  23832. }
  23833. /** Defines the 3 main axes */
  23834. class Axis {
  23835. /** X axis */
  23836. static X: Vector3;
  23837. /** Y axis */
  23838. static Y: Vector3;
  23839. /** Z axis */
  23840. static Z: Vector3;
  23841. }
  23842. /** Class used to represent a Bezier curve */
  23843. class BezierCurve {
  23844. /**
  23845. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  23846. * @param t defines the time
  23847. * @param x1 defines the left coordinate on X axis
  23848. * @param y1 defines the left coordinate on Y axis
  23849. * @param x2 defines the right coordinate on X axis
  23850. * @param y2 defines the right coordinate on Y axis
  23851. * @returns the interpolated value
  23852. */
  23853. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  23854. }
  23855. /**
  23856. * Defines potential orientation for back face culling
  23857. */
  23858. enum Orientation {
  23859. /**
  23860. * Clockwise
  23861. */
  23862. CW = 0,
  23863. /** Counter clockwise */
  23864. CCW = 1
  23865. }
  23866. /**
  23867. * Defines angle representation
  23868. */
  23869. class Angle {
  23870. private _radians;
  23871. /**
  23872. * Creates an Angle object of "radians" radians (float).
  23873. */
  23874. constructor(radians: number);
  23875. /**
  23876. * Get value in degrees
  23877. * @returns the Angle value in degrees (float)
  23878. */
  23879. degrees(): number;
  23880. /**
  23881. * Get value in radians
  23882. * @returns the Angle value in radians (float)
  23883. */
  23884. radians(): number;
  23885. /**
  23886. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  23887. * @param a defines first vector
  23888. * @param b defines second vector
  23889. * @returns a new Angle
  23890. */
  23891. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  23892. /**
  23893. * Gets a new Angle object from the given float in radians
  23894. * @param radians defines the angle value in radians
  23895. * @returns a new Angle
  23896. */
  23897. static FromRadians(radians: number): Angle;
  23898. /**
  23899. * Gets a new Angle object from the given float in degrees
  23900. * @param degrees defines the angle value in degrees
  23901. * @returns a new Angle
  23902. */
  23903. static FromDegrees(degrees: number): Angle;
  23904. }
  23905. /**
  23906. * This represents an arc in a 2d space.
  23907. */
  23908. class Arc2 {
  23909. /** Defines the start point of the arc */
  23910. startPoint: Vector2;
  23911. /** Defines the mid point of the arc */
  23912. midPoint: Vector2;
  23913. /** Defines the end point of the arc */
  23914. endPoint: Vector2;
  23915. /**
  23916. * Defines the center point of the arc.
  23917. */
  23918. centerPoint: Vector2;
  23919. /**
  23920. * Defines the radius of the arc.
  23921. */
  23922. radius: number;
  23923. /**
  23924. * Defines the angle of the arc (from mid point to end point).
  23925. */
  23926. angle: Angle;
  23927. /**
  23928. * Defines the start angle of the arc (from start point to middle point).
  23929. */
  23930. startAngle: Angle;
  23931. /**
  23932. * Defines the orientation of the arc (clock wise/counter clock wise).
  23933. */
  23934. orientation: Orientation;
  23935. /**
  23936. * Creates an Arc object from the three given points : start, middle and end.
  23937. * @param startPoint Defines the start point of the arc
  23938. * @param midPoint Defines the midlle point of the arc
  23939. * @param endPoint Defines the end point of the arc
  23940. */
  23941. constructor(
  23942. /** Defines the start point of the arc */
  23943. startPoint: Vector2,
  23944. /** Defines the mid point of the arc */
  23945. midPoint: Vector2,
  23946. /** Defines the end point of the arc */
  23947. endPoint: Vector2);
  23948. }
  23949. /**
  23950. * Represents a 2D path made up of multiple 2D points
  23951. */
  23952. class Path2 {
  23953. private _points;
  23954. private _length;
  23955. /**
  23956. * If the path start and end point are the same
  23957. */
  23958. closed: boolean;
  23959. /**
  23960. * Creates a Path2 object from the starting 2D coordinates x and y.
  23961. * @param x the starting points x value
  23962. * @param y the starting points y value
  23963. */
  23964. constructor(x: number, y: number);
  23965. /**
  23966. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  23967. * @param x the added points x value
  23968. * @param y the added points y value
  23969. * @returns the updated Path2.
  23970. */
  23971. addLineTo(x: number, y: number): Path2;
  23972. /**
  23973. * 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.
  23974. * @param midX middle point x value
  23975. * @param midY middle point y value
  23976. * @param endX end point x value
  23977. * @param endY end point y value
  23978. * @param numberOfSegments (default: 36)
  23979. * @returns the updated Path2.
  23980. */
  23981. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  23982. /**
  23983. * Closes the Path2.
  23984. * @returns the Path2.
  23985. */
  23986. close(): Path2;
  23987. /**
  23988. * Gets the sum of the distance between each sequential point in the path
  23989. * @returns the Path2 total length (float).
  23990. */
  23991. length(): number;
  23992. /**
  23993. * Gets the points which construct the path
  23994. * @returns the Path2 internal array of points.
  23995. */
  23996. getPoints(): Vector2[];
  23997. /**
  23998. * Retreives the point at the distance aways from the starting point
  23999. * @param normalizedLengthPosition the length along the path to retreive the point from
  24000. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  24001. */
  24002. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  24003. /**
  24004. * Creates a new path starting from an x and y position
  24005. * @param x starting x value
  24006. * @param y starting y value
  24007. * @returns a new Path2 starting at the coordinates (x, y).
  24008. */
  24009. static StartingAt(x: number, y: number): Path2;
  24010. }
  24011. /**
  24012. * Represents a 3D path made up of multiple 3D points
  24013. */
  24014. class Path3D {
  24015. /**
  24016. * an array of Vector3, the curve axis of the Path3D
  24017. */
  24018. path: Vector3[];
  24019. private _curve;
  24020. private _distances;
  24021. private _tangents;
  24022. private _normals;
  24023. private _binormals;
  24024. private _raw;
  24025. /**
  24026. * new Path3D(path, normal, raw)
  24027. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  24028. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  24029. * @param path an array of Vector3, the curve axis of the Path3D
  24030. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  24031. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  24032. */
  24033. constructor(
  24034. /**
  24035. * an array of Vector3, the curve axis of the Path3D
  24036. */
  24037. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  24038. /**
  24039. * Returns the Path3D array of successive Vector3 designing its curve.
  24040. * @returns the Path3D array of successive Vector3 designing its curve.
  24041. */
  24042. getCurve(): Vector3[];
  24043. /**
  24044. * Returns an array populated with tangent vectors on each Path3D curve point.
  24045. * @returns an array populated with tangent vectors on each Path3D curve point.
  24046. */
  24047. getTangents(): Vector3[];
  24048. /**
  24049. * Returns an array populated with normal vectors on each Path3D curve point.
  24050. * @returns an array populated with normal vectors on each Path3D curve point.
  24051. */
  24052. getNormals(): Vector3[];
  24053. /**
  24054. * Returns an array populated with binormal vectors on each Path3D curve point.
  24055. * @returns an array populated with binormal vectors on each Path3D curve point.
  24056. */
  24057. getBinormals(): Vector3[];
  24058. /**
  24059. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  24060. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  24061. */
  24062. getDistances(): number[];
  24063. /**
  24064. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  24065. * @param path path which all values are copied into the curves points
  24066. * @param firstNormal which should be projected onto the curve
  24067. * @returns the same object updated.
  24068. */
  24069. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  24070. private _compute;
  24071. private _getFirstNonNullVector;
  24072. private _getLastNonNullVector;
  24073. private _normalVector;
  24074. }
  24075. /**
  24076. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  24077. * A Curve3 is designed from a series of successive Vector3.
  24078. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  24079. */
  24080. class Curve3 {
  24081. private _points;
  24082. private _length;
  24083. /**
  24084. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  24085. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  24086. * @param v1 (Vector3) the control point
  24087. * @param v2 (Vector3) the end point of the Quadratic Bezier
  24088. * @param nbPoints (integer) the wanted number of points in the curve
  24089. * @returns the created Curve3
  24090. */
  24091. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  24092. /**
  24093. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  24094. * @param v0 (Vector3) the origin point of the Cubic Bezier
  24095. * @param v1 (Vector3) the first control point
  24096. * @param v2 (Vector3) the second control point
  24097. * @param v3 (Vector3) the end point of the Cubic Bezier
  24098. * @param nbPoints (integer) the wanted number of points in the curve
  24099. * @returns the created Curve3
  24100. */
  24101. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  24102. /**
  24103. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  24104. * @param p1 (Vector3) the origin point of the Hermite Spline
  24105. * @param t1 (Vector3) the tangent vector at the origin point
  24106. * @param p2 (Vector3) the end point of the Hermite Spline
  24107. * @param t2 (Vector3) the tangent vector at the end point
  24108. * @param nbPoints (integer) the wanted number of points in the curve
  24109. * @returns the created Curve3
  24110. */
  24111. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  24112. /**
  24113. * Returns a Curve3 object along a CatmullRom Spline curve :
  24114. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  24115. * @param nbPoints (integer) the wanted number of points between each curve control points
  24116. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  24117. * @returns the created Curve3
  24118. */
  24119. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  24120. /**
  24121. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  24122. * A Curve3 is designed from a series of successive Vector3.
  24123. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  24124. * @param points points which make up the curve
  24125. */
  24126. constructor(points: Vector3[]);
  24127. /**
  24128. * @returns the Curve3 stored array of successive Vector3
  24129. */
  24130. getPoints(): Vector3[];
  24131. /**
  24132. * @returns the computed length (float) of the curve.
  24133. */
  24134. length(): number;
  24135. /**
  24136. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  24137. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  24138. * curveA and curveB keep unchanged.
  24139. * @param curve the curve to continue from this curve
  24140. * @returns the newly constructed curve
  24141. */
  24142. continue(curve: DeepImmutable<Curve3>): Curve3;
  24143. private _computeLength;
  24144. }
  24145. /**
  24146. * Contains position and normal vectors for a vertex
  24147. */
  24148. class PositionNormalVertex {
  24149. /** the position of the vertex (defaut: 0,0,0) */
  24150. position: Vector3;
  24151. /** the normal of the vertex (defaut: 0,1,0) */
  24152. normal: Vector3;
  24153. /**
  24154. * Creates a PositionNormalVertex
  24155. * @param position the position of the vertex (defaut: 0,0,0)
  24156. * @param normal the normal of the vertex (defaut: 0,1,0)
  24157. */
  24158. constructor(
  24159. /** the position of the vertex (defaut: 0,0,0) */
  24160. position?: Vector3,
  24161. /** the normal of the vertex (defaut: 0,1,0) */
  24162. normal?: Vector3);
  24163. /**
  24164. * Clones the PositionNormalVertex
  24165. * @returns the cloned PositionNormalVertex
  24166. */
  24167. clone(): PositionNormalVertex;
  24168. }
  24169. /**
  24170. * Contains position, normal and uv vectors for a vertex
  24171. */
  24172. class PositionNormalTextureVertex {
  24173. /** the position of the vertex (defaut: 0,0,0) */
  24174. position: Vector3;
  24175. /** the normal of the vertex (defaut: 0,1,0) */
  24176. normal: Vector3;
  24177. /** the uv of the vertex (default: 0,0) */
  24178. uv: Vector2;
  24179. /**
  24180. * Creates a PositionNormalTextureVertex
  24181. * @param position the position of the vertex (defaut: 0,0,0)
  24182. * @param normal the normal of the vertex (defaut: 0,1,0)
  24183. * @param uv the uv of the vertex (default: 0,0)
  24184. */
  24185. constructor(
  24186. /** the position of the vertex (defaut: 0,0,0) */
  24187. position?: Vector3,
  24188. /** the normal of the vertex (defaut: 0,1,0) */
  24189. normal?: Vector3,
  24190. /** the uv of the vertex (default: 0,0) */
  24191. uv?: Vector2);
  24192. /**
  24193. * Clones the PositionNormalTextureVertex
  24194. * @returns the cloned PositionNormalTextureVertex
  24195. */
  24196. clone(): PositionNormalTextureVertex;
  24197. }
  24198. /**
  24199. * @hidden
  24200. */
  24201. class Tmp {
  24202. static Color3: Color3[];
  24203. static Color4: Color4[];
  24204. static Vector2: Vector2[];
  24205. static Vector3: Vector3[];
  24206. static Vector4: Vector4[];
  24207. static Quaternion: Quaternion[];
  24208. static Matrix: Matrix[];
  24209. }
  24210. }
  24211. declare module BABYLON {
  24212. /**
  24213. * Class representing spherical polynomial coefficients to the 3rd degree
  24214. */
  24215. class SphericalPolynomial {
  24216. /**
  24217. * The x coefficients of the spherical polynomial
  24218. */
  24219. x: Vector3;
  24220. /**
  24221. * The y coefficients of the spherical polynomial
  24222. */
  24223. y: Vector3;
  24224. /**
  24225. * The z coefficients of the spherical polynomial
  24226. */
  24227. z: Vector3;
  24228. /**
  24229. * The xx coefficients of the spherical polynomial
  24230. */
  24231. xx: Vector3;
  24232. /**
  24233. * The yy coefficients of the spherical polynomial
  24234. */
  24235. yy: Vector3;
  24236. /**
  24237. * The zz coefficients of the spherical polynomial
  24238. */
  24239. zz: Vector3;
  24240. /**
  24241. * The xy coefficients of the spherical polynomial
  24242. */
  24243. xy: Vector3;
  24244. /**
  24245. * The yz coefficients of the spherical polynomial
  24246. */
  24247. yz: Vector3;
  24248. /**
  24249. * The zx coefficients of the spherical polynomial
  24250. */
  24251. zx: Vector3;
  24252. /**
  24253. * Adds an ambient color to the spherical polynomial
  24254. * @param color the color to add
  24255. */
  24256. addAmbient(color: Color3): void;
  24257. /**
  24258. * Scales the spherical polynomial by the given amount
  24259. * @param scale the amount to scale
  24260. */
  24261. scale(scale: number): void;
  24262. /**
  24263. * Gets the spherical polynomial from harmonics
  24264. * @param harmonics the spherical harmonics
  24265. * @returns the spherical polynomial
  24266. */
  24267. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  24268. /**
  24269. * Constructs a spherical polynomial from an array.
  24270. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  24271. * @returns the spherical polynomial
  24272. */
  24273. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  24274. }
  24275. /**
  24276. * Class representing spherical harmonics coefficients to the 3rd degree
  24277. */
  24278. class SphericalHarmonics {
  24279. /**
  24280. * The l0,0 coefficients of the spherical harmonics
  24281. */
  24282. l00: Vector3;
  24283. /**
  24284. * The l1,-1 coefficients of the spherical harmonics
  24285. */
  24286. l1_1: Vector3;
  24287. /**
  24288. * The l1,0 coefficients of the spherical harmonics
  24289. */
  24290. l10: Vector3;
  24291. /**
  24292. * The l1,1 coefficients of the spherical harmonics
  24293. */
  24294. l11: Vector3;
  24295. /**
  24296. * The l2,-2 coefficients of the spherical harmonics
  24297. */
  24298. l2_2: Vector3;
  24299. /**
  24300. * The l2,-1 coefficients of the spherical harmonics
  24301. */
  24302. l2_1: Vector3;
  24303. /**
  24304. * The l2,0 coefficients of the spherical harmonics
  24305. */
  24306. l20: Vector3;
  24307. /**
  24308. * The l2,1 coefficients of the spherical harmonics
  24309. */
  24310. l21: Vector3;
  24311. /**
  24312. * The l2,2 coefficients of the spherical harmonics
  24313. */
  24314. lL22: Vector3;
  24315. /**
  24316. * Adds a light to the spherical harmonics
  24317. * @param direction the direction of the light
  24318. * @param color the color of the light
  24319. * @param deltaSolidAngle the delta solid angle of the light
  24320. */
  24321. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  24322. /**
  24323. * Scales the spherical harmonics by the given amount
  24324. * @param scale the amount to scale
  24325. */
  24326. scale(scale: number): void;
  24327. /**
  24328. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  24329. *
  24330. * ```
  24331. * E_lm = A_l * L_lm
  24332. * ```
  24333. *
  24334. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  24335. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  24336. * the scaling factors are given in equation 9.
  24337. */
  24338. convertIncidentRadianceToIrradiance(): void;
  24339. /**
  24340. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  24341. *
  24342. * ```
  24343. * L = (1/pi) * E * rho
  24344. * ```
  24345. *
  24346. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  24347. */
  24348. convertIrradianceToLambertianRadiance(): void;
  24349. /**
  24350. * Gets the spherical harmonics from polynomial
  24351. * @param polynomial the spherical polynomial
  24352. * @returns the spherical harmonics
  24353. */
  24354. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  24355. /**
  24356. * Constructs a spherical harmonics from an array.
  24357. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  24358. * @returns the spherical harmonics
  24359. */
  24360. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  24361. }
  24362. }
  24363. declare module BABYLON {
  24364. /**
  24365. * Class used to store all common mesh properties
  24366. */
  24367. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24368. /** No occlusion */
  24369. static OCCLUSION_TYPE_NONE: number;
  24370. /** Occlusion set to optimisitic */
  24371. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24372. /** Occlusion set to strict */
  24373. static OCCLUSION_TYPE_STRICT: number;
  24374. /** Use an accurante occlusion algorithm */
  24375. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24376. /** Use a conservative occlusion algorithm */
  24377. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24378. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  24379. static readonly CULLINGSTRATEGY_STANDARD: number;
  24380. /** Culling strategy with bounding sphere only and then frustum culling */
  24381. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24382. /**
  24383. * No billboard
  24384. */
  24385. static readonly BILLBOARDMODE_NONE: number;
  24386. /** Billboard on X axis */
  24387. static readonly BILLBOARDMODE_X: number;
  24388. /** Billboard on Y axis */
  24389. static readonly BILLBOARDMODE_Y: number;
  24390. /** Billboard on Z axis */
  24391. static readonly BILLBOARDMODE_Z: number;
  24392. /** Billboard on all axes */
  24393. static readonly BILLBOARDMODE_ALL: number;
  24394. private _facetData;
  24395. /** Gets ot sets the culling strategy to use to find visible meshes */
  24396. cullingStrategy: number;
  24397. /**
  24398. * Gets the number of facets in the mesh
  24399. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24400. */
  24401. readonly facetNb: number;
  24402. /**
  24403. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24404. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24405. */
  24406. partitioningSubdivisions: number;
  24407. /**
  24408. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24409. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24410. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24411. */
  24412. partitioningBBoxRatio: number;
  24413. /**
  24414. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24415. * Works only for updatable meshes.
  24416. * Doesn't work with multi-materials
  24417. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24418. */
  24419. mustDepthSortFacets: boolean;
  24420. /**
  24421. * The location (Vector3) where the facet depth sort must be computed from.
  24422. * By default, the active camera position.
  24423. * Used only when facet depth sort is enabled
  24424. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24425. */
  24426. facetDepthSortFrom: Vector3;
  24427. /**
  24428. * gets a boolean indicating if facetData is enabled
  24429. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24430. */
  24431. readonly isFacetDataEnabled: boolean;
  24432. /** @hidden */
  24433. _updateNonUniformScalingState(value: boolean): boolean;
  24434. /**
  24435. * An event triggered when this mesh collides with another one
  24436. */
  24437. onCollideObservable: Observable<AbstractMesh>;
  24438. private _onCollideObserver;
  24439. /** Set a function to call when this mesh collides with another one */
  24440. onCollide: () => void;
  24441. /**
  24442. * An event triggered when the collision's position changes
  24443. */
  24444. onCollisionPositionChangeObservable: Observable<Vector3>;
  24445. private _onCollisionPositionChangeObserver;
  24446. /** Set a function to call when the collision's position changes */
  24447. onCollisionPositionChange: () => void;
  24448. /**
  24449. * An event triggered when material is changed
  24450. */
  24451. onMaterialChangedObservable: Observable<AbstractMesh>;
  24452. /**
  24453. * Gets or sets the orientation for POV movement & rotation
  24454. */
  24455. definedFacingForward: boolean;
  24456. /** @hidden */
  24457. _occlusionQuery: Nullable<WebGLQuery>;
  24458. private _visibility;
  24459. /**
  24460. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24461. */
  24462. /**
  24463. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24464. */
  24465. visibility: number;
  24466. /** Gets or sets the alpha index used to sort transparent meshes
  24467. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24468. */
  24469. alphaIndex: number;
  24470. /**
  24471. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24472. */
  24473. isVisible: boolean;
  24474. /**
  24475. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24476. */
  24477. isPickable: boolean;
  24478. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24479. showSubMeshesBoundingBox: boolean;
  24480. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24481. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24482. */
  24483. isBlocker: boolean;
  24484. /**
  24485. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24486. */
  24487. enablePointerMoveEvents: boolean;
  24488. /**
  24489. * Specifies the rendering group id for this mesh (0 by default)
  24490. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24491. */
  24492. renderingGroupId: number;
  24493. private _material;
  24494. /** Gets or sets current material */
  24495. material: Nullable<Material>;
  24496. private _receiveShadows;
  24497. /**
  24498. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24499. * @see http://doc.babylonjs.com/babylon101/shadows
  24500. */
  24501. receiveShadows: boolean;
  24502. /** Defines color to use when rendering outline */
  24503. outlineColor: Color3;
  24504. /** Define width to use when rendering outline */
  24505. outlineWidth: number;
  24506. /** Defines color to use when rendering overlay */
  24507. overlayColor: Color3;
  24508. /** Defines alpha to use when rendering overlay */
  24509. overlayAlpha: number;
  24510. private _hasVertexAlpha;
  24511. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24512. hasVertexAlpha: boolean;
  24513. private _useVertexColors;
  24514. /** 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) */
  24515. useVertexColors: boolean;
  24516. private _computeBonesUsingShaders;
  24517. /**
  24518. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24519. */
  24520. computeBonesUsingShaders: boolean;
  24521. private _numBoneInfluencers;
  24522. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24523. numBoneInfluencers: number;
  24524. private _applyFog;
  24525. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24526. applyFog: boolean;
  24527. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24528. useOctreeForRenderingSelection: boolean;
  24529. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24530. useOctreeForPicking: boolean;
  24531. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24532. useOctreeForCollisions: boolean;
  24533. private _layerMask;
  24534. /**
  24535. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24536. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24537. */
  24538. layerMask: number;
  24539. /**
  24540. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24541. */
  24542. alwaysSelectAsActiveMesh: boolean;
  24543. /**
  24544. * Gets or sets the current action manager
  24545. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24546. */
  24547. actionManager: Nullable<ActionManager>;
  24548. private _checkCollisions;
  24549. private _collisionMask;
  24550. private _collisionGroup;
  24551. /**
  24552. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24553. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24554. */
  24555. ellipsoid: Vector3;
  24556. /**
  24557. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24558. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24559. */
  24560. ellipsoidOffset: Vector3;
  24561. private _collider;
  24562. private _oldPositionForCollisions;
  24563. private _diffPositionForCollisions;
  24564. /**
  24565. * Gets or sets a collision mask used to mask collisions (default is -1).
  24566. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24567. */
  24568. collisionMask: number;
  24569. /**
  24570. * Gets or sets the current collision group mask (-1 by default).
  24571. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24572. */
  24573. collisionGroup: number;
  24574. /**
  24575. * Defines edge width used when edgesRenderer is enabled
  24576. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24577. */
  24578. edgesWidth: number;
  24579. /**
  24580. * Defines edge color used when edgesRenderer is enabled
  24581. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24582. */
  24583. edgesColor: Color4;
  24584. /** @hidden */
  24585. _edgesRenderer: Nullable<IEdgesRenderer>;
  24586. /** @hidden */
  24587. _masterMesh: Nullable<AbstractMesh>;
  24588. /** @hidden */
  24589. _boundingInfo: Nullable<BoundingInfo>;
  24590. /** @hidden */
  24591. _renderId: number;
  24592. /**
  24593. * Gets or sets the list of subMeshes
  24594. * @see http://doc.babylonjs.com/how_to/multi_materials
  24595. */
  24596. subMeshes: SubMesh[];
  24597. /** @hidden */
  24598. _intersectionsInProgress: AbstractMesh[];
  24599. /** @hidden */
  24600. _unIndexed: boolean;
  24601. /** @hidden */
  24602. _lightSources: Light[];
  24603. /** @hidden */
  24604. readonly _positions: Nullable<Vector3[]>;
  24605. /** @hidden */
  24606. _waitingActions: any;
  24607. /** @hidden */
  24608. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24609. private _skeleton;
  24610. /** @hidden */
  24611. _bonesTransformMatrices: Nullable<Float32Array>;
  24612. /**
  24613. * Gets or sets a skeleton to apply skining transformations
  24614. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24615. */
  24616. skeleton: Nullable<Skeleton>;
  24617. /**
  24618. * An event triggered when the mesh is rebuilt.
  24619. */
  24620. onRebuildObservable: Observable<AbstractMesh>;
  24621. /**
  24622. * Creates a new AbstractMesh
  24623. * @param name defines the name of the mesh
  24624. * @param scene defines the hosting scene
  24625. */
  24626. constructor(name: string, scene?: Nullable<Scene>);
  24627. /**
  24628. * Returns the string "AbstractMesh"
  24629. * @returns "AbstractMesh"
  24630. */
  24631. getClassName(): string;
  24632. /**
  24633. * Gets a string representation of the current mesh
  24634. * @param fullDetails defines a boolean indicating if full details must be included
  24635. * @returns a string representation of the current mesh
  24636. */
  24637. toString(fullDetails?: boolean): string;
  24638. /** @hidden */
  24639. _rebuild(): void;
  24640. /** @hidden */
  24641. _resyncLightSources(): void;
  24642. /** @hidden */
  24643. _resyncLighSource(light: Light): void;
  24644. /** @hidden */
  24645. _unBindEffect(): void;
  24646. /** @hidden */
  24647. _removeLightSource(light: Light): void;
  24648. private _markSubMeshesAsDirty;
  24649. /** @hidden */
  24650. _markSubMeshesAsLightDirty(): void;
  24651. /** @hidden */
  24652. _markSubMeshesAsAttributesDirty(): void;
  24653. /** @hidden */
  24654. _markSubMeshesAsMiscDirty(): void;
  24655. /**
  24656. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24657. */
  24658. scaling: Vector3;
  24659. /**
  24660. * Returns true if the mesh is blocked. Implemented by child classes
  24661. */
  24662. readonly isBlocked: boolean;
  24663. /**
  24664. * Returns the mesh itself by default. Implemented by child classes
  24665. * @param camera defines the camera to use to pick the right LOD level
  24666. * @returns the currentAbstractMesh
  24667. */
  24668. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24669. /**
  24670. * Returns 0 by default. Implemented by child classes
  24671. * @returns an integer
  24672. */
  24673. getTotalVertices(): number;
  24674. /**
  24675. * Returns a positive integer : the total number of indices in this mesh geometry.
  24676. * @returns the numner of indices or zero if the mesh has no geometry.
  24677. */
  24678. getTotalIndices(): number;
  24679. /**
  24680. * Returns null by default. Implemented by child classes
  24681. * @returns null
  24682. */
  24683. getIndices(): Nullable<IndicesArray>;
  24684. /**
  24685. * Returns the array of the requested vertex data kind. Implemented by child classes
  24686. * @param kind defines the vertex data kind to use
  24687. * @returns null
  24688. */
  24689. getVerticesData(kind: string): Nullable<FloatArray>;
  24690. /**
  24691. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24692. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24693. * Note that a new underlying VertexBuffer object is created each call.
  24694. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24695. * @param kind defines vertex data kind:
  24696. * * BABYLON.VertexBuffer.PositionKind
  24697. * * BABYLON.VertexBuffer.UVKind
  24698. * * BABYLON.VertexBuffer.UV2Kind
  24699. * * BABYLON.VertexBuffer.UV3Kind
  24700. * * BABYLON.VertexBuffer.UV4Kind
  24701. * * BABYLON.VertexBuffer.UV5Kind
  24702. * * BABYLON.VertexBuffer.UV6Kind
  24703. * * BABYLON.VertexBuffer.ColorKind
  24704. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24705. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24706. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24707. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24708. * @param data defines the data source
  24709. * @param updatable defines if the data must be flagged as updatable (or static)
  24710. * @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
  24711. * @returns the current mesh
  24712. */
  24713. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24714. /**
  24715. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24716. * If the mesh has no geometry, it is simply returned as it is.
  24717. * @param kind defines vertex data kind:
  24718. * * BABYLON.VertexBuffer.PositionKind
  24719. * * BABYLON.VertexBuffer.UVKind
  24720. * * BABYLON.VertexBuffer.UV2Kind
  24721. * * BABYLON.VertexBuffer.UV3Kind
  24722. * * BABYLON.VertexBuffer.UV4Kind
  24723. * * BABYLON.VertexBuffer.UV5Kind
  24724. * * BABYLON.VertexBuffer.UV6Kind
  24725. * * BABYLON.VertexBuffer.ColorKind
  24726. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24727. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24728. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24729. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24730. * @param data defines the data source
  24731. * @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
  24732. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24733. * @returns the current mesh
  24734. */
  24735. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24736. /**
  24737. * Sets the mesh indices,
  24738. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24739. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24740. * @param totalVertices Defines the total number of vertices
  24741. * @returns the current mesh
  24742. */
  24743. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24744. /**
  24745. * Gets a boolean indicating if specific vertex data is present
  24746. * @param kind defines the vertex data kind to use
  24747. * @returns true is data kind is present
  24748. */
  24749. isVerticesDataPresent(kind: string): boolean;
  24750. /**
  24751. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24752. * @returns a BoundingInfo
  24753. */
  24754. getBoundingInfo(): BoundingInfo;
  24755. /**
  24756. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24757. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24758. * @returns the current mesh
  24759. */
  24760. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24761. /**
  24762. * Overwrite the current bounding info
  24763. * @param boundingInfo defines the new bounding info
  24764. * @returns the current mesh
  24765. */
  24766. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24767. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24768. readonly useBones: boolean;
  24769. /** @hidden */
  24770. _preActivate(): void;
  24771. /** @hidden */
  24772. _preActivateForIntermediateRendering(renderId: number): void;
  24773. /** @hidden */
  24774. _activate(renderId: number): void;
  24775. /**
  24776. * Gets the current world matrix
  24777. * @returns a Matrix
  24778. */
  24779. getWorldMatrix(): Matrix;
  24780. /** @hidden */
  24781. _getWorldMatrixDeterminant(): number;
  24782. /**
  24783. * Perform relative position change from the point of view of behind the front of the mesh.
  24784. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24785. * Supports definition of mesh facing forward or backward
  24786. * @param amountRight defines the distance on the right axis
  24787. * @param amountUp defines the distance on the up axis
  24788. * @param amountForward defines the distance on the forward axis
  24789. * @returns the current mesh
  24790. */
  24791. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24792. /**
  24793. * Calculate relative position change from the point of view of behind the front of the mesh.
  24794. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24795. * Supports definition of mesh facing forward or backward
  24796. * @param amountRight defines the distance on the right axis
  24797. * @param amountUp defines the distance on the up axis
  24798. * @param amountForward defines the distance on the forward axis
  24799. * @returns the new displacement vector
  24800. */
  24801. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24802. /**
  24803. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24804. * Supports definition of mesh facing forward or backward
  24805. * @param flipBack defines the flip
  24806. * @param twirlClockwise defines the twirl
  24807. * @param tiltRight defines the tilt
  24808. * @returns the current mesh
  24809. */
  24810. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24811. /**
  24812. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24813. * Supports definition of mesh facing forward or backward.
  24814. * @param flipBack defines the flip
  24815. * @param twirlClockwise defines the twirl
  24816. * @param tiltRight defines the tilt
  24817. * @returns the new rotation vector
  24818. */
  24819. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24820. /**
  24821. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24822. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24823. * @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
  24824. * @returns the new bounding vectors
  24825. */
  24826. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24827. min: Vector3;
  24828. max: Vector3;
  24829. };
  24830. /**
  24831. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24832. * This means the mesh underlying bounding box and sphere are recomputed.
  24833. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24834. * @returns the current mesh
  24835. */
  24836. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24837. /** @hidden */
  24838. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24839. /** @hidden */
  24840. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24841. /** @hidden */
  24842. _updateBoundingInfo(): AbstractMesh;
  24843. /** @hidden */
  24844. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24845. /** @hidden */
  24846. protected _afterComputeWorldMatrix(): void;
  24847. /**
  24848. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24849. * A mesh is in the frustum if its bounding box intersects the frustum
  24850. * @param frustumPlanes defines the frustum to test
  24851. * @returns true if the mesh is in the frustum planes
  24852. */
  24853. isInFrustum(frustumPlanes: Plane[]): boolean;
  24854. /**
  24855. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24856. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24857. * @param frustumPlanes defines the frustum to test
  24858. * @returns true if the mesh is completely in the frustum planes
  24859. */
  24860. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24861. /**
  24862. * True if the mesh intersects another mesh or a SolidParticle object
  24863. * @param mesh defines a target mesh or SolidParticle to test
  24864. * @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)
  24865. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24866. * @returns true if there is an intersection
  24867. */
  24868. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24869. /**
  24870. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24871. * @param point defines the point to test
  24872. * @returns true if there is an intersection
  24873. */
  24874. intersectsPoint(point: Vector3): boolean;
  24875. /**
  24876. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24877. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24878. */
  24879. checkCollisions: boolean;
  24880. /**
  24881. * Gets Collider object used to compute collisions (not physics)
  24882. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24883. */
  24884. readonly collider: Collider;
  24885. /**
  24886. * Move the mesh using collision engine
  24887. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24888. * @param displacement defines the requested displacement vector
  24889. * @returns the current mesh
  24890. */
  24891. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24892. private _onCollisionPositionChange;
  24893. /** @hidden */
  24894. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24895. /** @hidden */
  24896. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24897. /** @hidden */
  24898. _checkCollision(collider: Collider): AbstractMesh;
  24899. /** @hidden */
  24900. _generatePointsArray(): boolean;
  24901. /**
  24902. * Checks if the passed Ray intersects with the mesh
  24903. * @param ray defines the ray to use
  24904. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24905. * @returns the picking info
  24906. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24907. */
  24908. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24909. /**
  24910. * Clones the current mesh
  24911. * @param name defines the mesh name
  24912. * @param newParent defines the new mesh parent
  24913. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24914. * @returns the new mesh
  24915. */
  24916. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24917. /**
  24918. * Disposes all the submeshes of the current meshnp
  24919. * @returns the current mesh
  24920. */
  24921. releaseSubMeshes(): AbstractMesh;
  24922. /**
  24923. * Releases resources associated with this abstract mesh.
  24924. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24925. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24926. */
  24927. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24928. /**
  24929. * Adds the passed mesh as a child to the current mesh
  24930. * @param mesh defines the child mesh
  24931. * @returns the current mesh
  24932. */
  24933. addChild(mesh: AbstractMesh): AbstractMesh;
  24934. /**
  24935. * Removes the passed mesh from the current mesh children list
  24936. * @param mesh defines the child mesh
  24937. * @returns the current mesh
  24938. */
  24939. removeChild(mesh: AbstractMesh): AbstractMesh;
  24940. /** @hidden */
  24941. private _initFacetData;
  24942. /**
  24943. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24944. * This method can be called within the render loop.
  24945. * 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
  24946. * @returns the current mesh
  24947. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24948. */
  24949. updateFacetData(): AbstractMesh;
  24950. /**
  24951. * Returns the facetLocalNormals array.
  24952. * The normals are expressed in the mesh local spac
  24953. * @returns an array of Vector3
  24954. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24955. */
  24956. getFacetLocalNormals(): Vector3[];
  24957. /**
  24958. * Returns the facetLocalPositions array.
  24959. * The facet positions are expressed in the mesh local space
  24960. * @returns an array of Vector3
  24961. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24962. */
  24963. getFacetLocalPositions(): Vector3[];
  24964. /**
  24965. * Returns the facetLocalPartioning array
  24966. * @returns an array of array of numbers
  24967. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24968. */
  24969. getFacetLocalPartitioning(): number[][];
  24970. /**
  24971. * Returns the i-th facet position in the world system.
  24972. * This method allocates a new Vector3 per call
  24973. * @param i defines the facet index
  24974. * @returns a new Vector3
  24975. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24976. */
  24977. getFacetPosition(i: number): Vector3;
  24978. /**
  24979. * Sets the reference Vector3 with the i-th facet position in the world system
  24980. * @param i defines the facet index
  24981. * @param ref defines the target vector
  24982. * @returns the current mesh
  24983. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24984. */
  24985. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24986. /**
  24987. * Returns the i-th facet normal in the world system.
  24988. * This method allocates a new Vector3 per call
  24989. * @param i defines the facet index
  24990. * @returns a new Vector3
  24991. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24992. */
  24993. getFacetNormal(i: number): Vector3;
  24994. /**
  24995. * Sets the reference Vector3 with the i-th facet normal in the world system
  24996. * @param i defines the facet index
  24997. * @param ref defines the target vector
  24998. * @returns the current mesh
  24999. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25000. */
  25001. getFacetNormalToRef(i: number, ref: Vector3): this;
  25002. /**
  25003. * 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)
  25004. * @param x defines x coordinate
  25005. * @param y defines y coordinate
  25006. * @param z defines z coordinate
  25007. * @returns the array of facet indexes
  25008. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25009. */
  25010. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25011. /**
  25012. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25013. * @param projected sets as the (x,y,z) world projection on the facet
  25014. * @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
  25015. * @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
  25016. * @param x defines x coordinate
  25017. * @param y defines y coordinate
  25018. * @param z defines z coordinate
  25019. * @returns the face index if found (or null instead)
  25020. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25021. */
  25022. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25023. /**
  25024. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25025. * @param projected sets as the (x,y,z) local projection on the facet
  25026. * @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
  25027. * @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
  25028. * @param x defines x coordinate
  25029. * @param y defines y coordinate
  25030. * @param z defines z coordinate
  25031. * @returns the face index if found (or null instead)
  25032. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25033. */
  25034. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25035. /**
  25036. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25037. * @returns the parameters
  25038. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25039. */
  25040. getFacetDataParameters(): any;
  25041. /**
  25042. * Disables the feature FacetData and frees the related memory
  25043. * @returns the current mesh
  25044. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25045. */
  25046. disableFacetData(): AbstractMesh;
  25047. /**
  25048. * Updates the AbstractMesh indices array
  25049. * @param indices defines the data source
  25050. * @returns the current mesh
  25051. */
  25052. updateIndices(indices: IndicesArray): AbstractMesh;
  25053. /**
  25054. * Creates new normals data for the mesh
  25055. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25056. * @returns the current mesh
  25057. */
  25058. createNormals(updatable: boolean): AbstractMesh;
  25059. /**
  25060. * Align the mesh with a normal
  25061. * @param normal defines the normal to use
  25062. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25063. * @returns the current mesh
  25064. */
  25065. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25066. /** @hidden */
  25067. _checkOcclusionQuery(): boolean;
  25068. }
  25069. }
  25070. declare module BABYLON {
  25071. /**
  25072. * Class used to store data that will be store in GPU memory
  25073. */
  25074. class Buffer {
  25075. private _engine;
  25076. private _buffer;
  25077. /** @hidden */
  25078. _data: Nullable<DataArray>;
  25079. private _updatable;
  25080. private _instanced;
  25081. /**
  25082. * Gets the byte stride.
  25083. */
  25084. readonly byteStride: number;
  25085. /**
  25086. * Constructor
  25087. * @param engine the engine
  25088. * @param data the data to use for this buffer
  25089. * @param updatable whether the data is updatable
  25090. * @param stride the stride (optional)
  25091. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  25092. * @param instanced whether the buffer is instanced (optional)
  25093. * @param useBytes set to true if the stride in in bytes (optional)
  25094. */
  25095. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  25096. /**
  25097. * Create a new VertexBuffer based on the current buffer
  25098. * @param kind defines the vertex buffer kind (position, normal, etc.)
  25099. * @param offset defines offset in the buffer (0 by default)
  25100. * @param size defines the size in floats of attributes (position is 3 for instance)
  25101. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  25102. * @param instanced defines if the vertex buffer contains indexed data
  25103. * @param useBytes defines if the offset and stride are in bytes
  25104. * @returns the new vertex buffer
  25105. */
  25106. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  25107. /**
  25108. * Gets a boolean indicating if the Buffer is updatable?
  25109. * @returns true if the buffer is updatable
  25110. */
  25111. isUpdatable(): boolean;
  25112. /**
  25113. * Gets current buffer's data
  25114. * @returns a DataArray or null
  25115. */
  25116. getData(): Nullable<DataArray>;
  25117. /**
  25118. * Gets underlying native buffer
  25119. * @returns underlying native buffer
  25120. */
  25121. getBuffer(): Nullable<WebGLBuffer>;
  25122. /**
  25123. * Gets the stride in float32 units (i.e. byte stride / 4).
  25124. * May not be an integer if the byte stride is not divisible by 4.
  25125. * DEPRECATED. Use byteStride instead.
  25126. * @returns the stride in float32 units
  25127. */
  25128. getStrideSize(): number;
  25129. /**
  25130. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  25131. * @param data defines the data to store
  25132. */
  25133. create(data?: Nullable<DataArray>): void;
  25134. /** @hidden */
  25135. _rebuild(): void;
  25136. /**
  25137. * Update current buffer data
  25138. * @param data defines the data to store
  25139. */
  25140. update(data: DataArray): void;
  25141. /**
  25142. * Updates the data directly.
  25143. * @param data the new data
  25144. * @param offset the new offset
  25145. * @param vertexCount the vertex count (optional)
  25146. * @param useBytes set to true if the offset is in bytes
  25147. */
  25148. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  25149. /**
  25150. * Release all resources
  25151. */
  25152. dispose(): void;
  25153. }
  25154. }
  25155. declare module BABYLON {
  25156. /**
  25157. * Class for building Constructive Solid Geometry
  25158. */
  25159. class CSG {
  25160. private polygons;
  25161. /**
  25162. * The world matrix
  25163. */
  25164. matrix: Matrix;
  25165. /**
  25166. * Stores the position
  25167. */
  25168. position: Vector3;
  25169. /**
  25170. * Stores the rotation
  25171. */
  25172. rotation: Vector3;
  25173. /**
  25174. * Stores the rotation quaternion
  25175. */
  25176. rotationQuaternion: Nullable<Quaternion>;
  25177. /**
  25178. * Stores the scaling vector
  25179. */
  25180. scaling: Vector3;
  25181. /**
  25182. * Convert the BABYLON.Mesh to BABYLON.CSG
  25183. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  25184. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  25185. */
  25186. static FromMesh(mesh: Mesh): CSG;
  25187. /**
  25188. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  25189. * @param polygons Polygons used to construct a BABYLON.CSG solid
  25190. */
  25191. private static FromPolygons;
  25192. /**
  25193. * Clones, or makes a deep copy, of the BABYLON.CSG
  25194. * @returns A new BABYLON.CSG
  25195. */
  25196. clone(): CSG;
  25197. /**
  25198. * Unions this CSG with another CSG
  25199. * @param csg The CSG to union against this CSG
  25200. * @returns The unioned CSG
  25201. */
  25202. union(csg: CSG): CSG;
  25203. /**
  25204. * Unions this CSG with another CSG in place
  25205. * @param csg The CSG to union against this CSG
  25206. */
  25207. unionInPlace(csg: CSG): void;
  25208. /**
  25209. * Subtracts this CSG with another CSG
  25210. * @param csg The CSG to subtract against this CSG
  25211. * @returns A new BABYLON.CSG
  25212. */
  25213. subtract(csg: CSG): CSG;
  25214. /**
  25215. * Subtracts this CSG with another CSG in place
  25216. * @param csg The CSG to subtact against this CSG
  25217. */
  25218. subtractInPlace(csg: CSG): void;
  25219. /**
  25220. * Intersect this CSG with another CSG
  25221. * @param csg The CSG to intersect against this CSG
  25222. * @returns A new BABYLON.CSG
  25223. */
  25224. intersect(csg: CSG): CSG;
  25225. /**
  25226. * Intersects this CSG with another CSG in place
  25227. * @param csg The CSG to intersect against this CSG
  25228. */
  25229. intersectInPlace(csg: CSG): void;
  25230. /**
  25231. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  25232. * not modified.
  25233. * @returns A new BABYLON.CSG solid with solid and empty space switched
  25234. */
  25235. inverse(): CSG;
  25236. /**
  25237. * Inverses the BABYLON.CSG in place
  25238. */
  25239. inverseInPlace(): void;
  25240. /**
  25241. * This is used to keep meshes transformations so they can be restored
  25242. * when we build back a Babylon Mesh
  25243. * NB : All CSG operations are performed in world coordinates
  25244. * @param csg The BABYLON.CSG to copy the transform attributes from
  25245. * @returns This BABYLON.CSG
  25246. */
  25247. copyTransformAttributes(csg: CSG): CSG;
  25248. /**
  25249. * Build Raw mesh from CSG
  25250. * Coordinates here are in world space
  25251. * @param name The name of the mesh geometry
  25252. * @param scene The BABYLON.Scene
  25253. * @param keepSubMeshes Specifies if the submeshes should be kept
  25254. * @returns A new BABYLON.Mesh
  25255. */
  25256. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  25257. /**
  25258. * Build Mesh from CSG taking material and transforms into account
  25259. * @param name The name of the BABYLON.Mesh
  25260. * @param material The material of the BABYLON.Mesh
  25261. * @param scene The BABYLON.Scene
  25262. * @param keepSubMeshes Specifies if submeshes should be kept
  25263. * @returns The new BABYLON.Mesh
  25264. */
  25265. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  25266. }
  25267. }
  25268. declare module BABYLON {
  25269. /**
  25270. * Class used to store geometry data (vertex buffers + index buffer)
  25271. */
  25272. class Geometry implements IGetSetVerticesData {
  25273. /**
  25274. * Gets or sets the ID of the geometry
  25275. */
  25276. id: string;
  25277. /**
  25278. * Gets or sets the unique ID of the geometry
  25279. */
  25280. uniqueId: number;
  25281. /**
  25282. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25283. */
  25284. delayLoadState: number;
  25285. /**
  25286. * Gets the file containing the data to load when running in delay load state
  25287. */
  25288. delayLoadingFile: Nullable<string>;
  25289. /**
  25290. * Callback called when the geometry is updated
  25291. */
  25292. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25293. private _scene;
  25294. private _engine;
  25295. private _meshes;
  25296. private _totalVertices;
  25297. /** @hidden */
  25298. _indices: IndicesArray;
  25299. /** @hidden */
  25300. _vertexBuffers: {
  25301. [key: string]: VertexBuffer;
  25302. };
  25303. private _isDisposed;
  25304. private _extend;
  25305. private _boundingBias;
  25306. /** @hidden */
  25307. _delayInfo: Array<string>;
  25308. private _indexBuffer;
  25309. private _indexBufferIsUpdatable;
  25310. /** @hidden */
  25311. _boundingInfo: Nullable<BoundingInfo>;
  25312. /** @hidden */
  25313. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25314. /** @hidden */
  25315. _softwareSkinningFrameId: number;
  25316. private _vertexArrayObjects;
  25317. private _updatable;
  25318. /** @hidden */
  25319. _positions: Nullable<Vector3[]>;
  25320. /**
  25321. * 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
  25322. */
  25323. /**
  25324. * 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
  25325. */
  25326. boundingBias: Vector2;
  25327. /**
  25328. * Static function used to attach a new empty geometry to a mesh
  25329. * @param mesh defines the mesh to attach the geometry to
  25330. * @returns the new Geometry
  25331. */
  25332. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25333. /**
  25334. * Creates a new geometry
  25335. * @param id defines the unique ID
  25336. * @param scene defines the hosting scene
  25337. * @param vertexData defines the VertexData used to get geometry data
  25338. * @param updatable defines if geometry must be updatable (false by default)
  25339. * @param mesh defines the mesh that will be associated with the geometry
  25340. */
  25341. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25342. /**
  25343. * Gets the current extend of the geometry
  25344. */
  25345. readonly extend: {
  25346. minimum: Vector3;
  25347. maximum: Vector3;
  25348. };
  25349. /**
  25350. * Gets the hosting scene
  25351. * @returns the hosting Scene
  25352. */
  25353. getScene(): Scene;
  25354. /**
  25355. * Gets the hosting engine
  25356. * @returns the hosting Engine
  25357. */
  25358. getEngine(): Engine;
  25359. /**
  25360. * Defines if the geometry is ready to use
  25361. * @returns true if the geometry is ready to be used
  25362. */
  25363. isReady(): boolean;
  25364. /**
  25365. * Gets a value indicating that the geometry should not be serialized
  25366. */
  25367. readonly doNotSerialize: boolean;
  25368. /** @hidden */
  25369. _rebuild(): void;
  25370. /**
  25371. * Affects all geometry data in one call
  25372. * @param vertexData defines the geometry data
  25373. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25374. */
  25375. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25376. /**
  25377. * Set specific vertex data
  25378. * @param kind defines the data kind (Position, normal, etc...)
  25379. * @param data defines the vertex data to use
  25380. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25381. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25382. */
  25383. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25384. /**
  25385. * Removes a specific vertex data
  25386. * @param kind defines the data kind (Position, normal, etc...)
  25387. */
  25388. removeVerticesData(kind: string): void;
  25389. /**
  25390. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25391. * @param buffer defines the vertex buffer to use
  25392. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25393. */
  25394. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25395. /**
  25396. * Update a specific vertex buffer
  25397. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  25398. * It will do nothing if the buffer is not updatable
  25399. * @param kind defines the data kind (Position, normal, etc...)
  25400. * @param data defines the data to use
  25401. * @param offset defines the offset in the target buffer where to store the data
  25402. * @param useBytes set to true if the offset is in bytes
  25403. */
  25404. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25405. /**
  25406. * Update a specific vertex buffer
  25407. * This function will create a new buffer if the current one is not updatable
  25408. * @param kind defines the data kind (Position, normal, etc...)
  25409. * @param data defines the data to use
  25410. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25411. */
  25412. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25413. private _updateBoundingInfo;
  25414. /** @hidden */
  25415. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  25416. /**
  25417. * Gets total number of vertices
  25418. * @returns the total number of vertices
  25419. */
  25420. getTotalVertices(): number;
  25421. /**
  25422. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25423. * @param kind defines the data kind (Position, normal, etc...)
  25424. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25425. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25426. * @returns a float array containing vertex data
  25427. */
  25428. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25429. /**
  25430. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25431. * @param kind defines the data kind (Position, normal, etc...)
  25432. * @returns true if the vertex buffer with the specified kind is updatable
  25433. */
  25434. isVertexBufferUpdatable(kind: string): boolean;
  25435. /**
  25436. * Gets a specific vertex buffer
  25437. * @param kind defines the data kind (Position, normal, etc...)
  25438. * @returns a VertexBuffer
  25439. */
  25440. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25441. /**
  25442. * Returns all vertex buffers
  25443. * @return an object holding all vertex buffers indexed by kind
  25444. */
  25445. getVertexBuffers(): Nullable<{
  25446. [key: string]: VertexBuffer;
  25447. }>;
  25448. /**
  25449. * Gets a boolean indicating if specific vertex buffer is present
  25450. * @param kind defines the data kind (Position, normal, etc...)
  25451. * @returns true if data is present
  25452. */
  25453. isVerticesDataPresent(kind: string): boolean;
  25454. /**
  25455. * Gets a list of all attached data kinds (Position, normal, etc...)
  25456. * @returns a list of string containing all kinds
  25457. */
  25458. getVerticesDataKinds(): string[];
  25459. /**
  25460. * Update index buffer
  25461. * @param indices defines the indices to store in the index buffer
  25462. * @param offset defines the offset in the target buffer where to store the data
  25463. */
  25464. updateIndices(indices: IndicesArray, offset?: number): void;
  25465. /**
  25466. * Creates a new index buffer
  25467. * @param indices defines the indices to store in the index buffer
  25468. * @param totalVertices defines the total number of vertices (could be null)
  25469. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25470. */
  25471. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25472. /**
  25473. * Return the total number of indices
  25474. * @returns the total number of indices
  25475. */
  25476. getTotalIndices(): number;
  25477. /**
  25478. * Gets the index buffer array
  25479. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25480. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25481. * @returns the index buffer array
  25482. */
  25483. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25484. /**
  25485. * Gets the index buffer
  25486. * @return the index buffer
  25487. */
  25488. getIndexBuffer(): Nullable<WebGLBuffer>;
  25489. /** @hidden */
  25490. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25491. /**
  25492. * Release the associated resources for a specific mesh
  25493. * @param mesh defines the source mesh
  25494. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25495. */
  25496. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25497. /**
  25498. * Apply current geometry to a given mesh
  25499. * @param mesh defines the mesh to apply geometry to
  25500. */
  25501. applyToMesh(mesh: Mesh): void;
  25502. private _updateExtend;
  25503. private _applyToMesh;
  25504. private notifyUpdate;
  25505. /**
  25506. * Load the geometry if it was flagged as delay loaded
  25507. * @param scene defines the hosting scene
  25508. * @param onLoaded defines a callback called when the geometry is loaded
  25509. */
  25510. load(scene: Scene, onLoaded?: () => void): void;
  25511. private _queueLoad;
  25512. /**
  25513. * Invert the geometry to move from a right handed system to a left handed one.
  25514. */
  25515. toLeftHanded(): void;
  25516. /** @hidden */
  25517. _resetPointsArrayCache(): void;
  25518. /** @hidden */
  25519. _generatePointsArray(): boolean;
  25520. /**
  25521. * Gets a value indicating if the geometry is disposed
  25522. * @returns true if the geometry was disposed
  25523. */
  25524. isDisposed(): boolean;
  25525. private _disposeVertexArrayObjects;
  25526. /**
  25527. * Free all associated resources
  25528. */
  25529. dispose(): void;
  25530. /**
  25531. * Clone the current geometry into a new geometry
  25532. * @param id defines the unique ID of the new geometry
  25533. * @returns a new geometry object
  25534. */
  25535. copy(id: string): Geometry;
  25536. /**
  25537. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25538. * @return a JSON representation of the current geometry data (without the vertices data)
  25539. */
  25540. serialize(): any;
  25541. private toNumberArray;
  25542. /**
  25543. * Serialize all vertices data into a JSON oject
  25544. * @returns a JSON representation of the current geometry data
  25545. */
  25546. serializeVerticeData(): any;
  25547. /**
  25548. * Extracts a clone of a mesh geometry
  25549. * @param mesh defines the source mesh
  25550. * @param id defines the unique ID of the new geometry object
  25551. * @returns the new geometry object
  25552. */
  25553. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25554. /**
  25555. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25556. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25557. * Be aware Math.random() could cause collisions, but:
  25558. * "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"
  25559. * @returns a string containing a new GUID
  25560. */
  25561. static RandomId(): string;
  25562. /** @hidden */
  25563. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25564. private static _CleanMatricesWeights;
  25565. /**
  25566. * Create a new geometry from persisted data (Using .babylon file format)
  25567. * @param parsedVertexData defines the persisted data
  25568. * @param scene defines the hosting scene
  25569. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25570. * @returns the new geometry object
  25571. */
  25572. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25573. }
  25574. /**
  25575. * Abstract class used to provide common services for all typed geometries
  25576. * @hidden
  25577. */
  25578. class _PrimitiveGeometry extends Geometry {
  25579. private _canBeRegenerated;
  25580. private _beingRegenerated;
  25581. /**
  25582. * Creates a new typed geometry
  25583. * @param id defines the unique ID of the geometry
  25584. * @param scene defines the hosting scene
  25585. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25586. * @param mesh defines the hosting mesh (can be null)
  25587. */
  25588. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25589. /**
  25590. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  25591. * @returns true if the geometry can be regenerated
  25592. */
  25593. canBeRegenerated(): boolean;
  25594. /**
  25595. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  25596. */
  25597. regenerate(): void;
  25598. /**
  25599. * Clone the geometry
  25600. * @param id defines the unique ID of the new geometry
  25601. * @returns the new geometry
  25602. */
  25603. asNewGeometry(id: string): Geometry;
  25604. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25605. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  25606. /** @hidden */
  25607. _regenerateVertexData(): VertexData;
  25608. copy(id: string): Geometry;
  25609. serialize(): any;
  25610. }
  25611. /**
  25612. * Creates a ribbon geometry
  25613. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  25614. */
  25615. class RibbonGeometry extends _PrimitiveGeometry {
  25616. /**
  25617. * Defines the array of paths to use
  25618. */
  25619. pathArray: Vector3[][];
  25620. /**
  25621. * Defines if the last and first points of each path in your pathArray must be joined
  25622. */
  25623. closeArray: boolean;
  25624. /**
  25625. * Defines if the last and first points of each path in your pathArray must be joined
  25626. */
  25627. closePath: boolean;
  25628. /**
  25629. * Defines the offset between points
  25630. */
  25631. offset: number;
  25632. /**
  25633. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25634. */
  25635. side: number;
  25636. /**
  25637. * Creates a ribbon geometry
  25638. * @param id defines the unique ID of the geometry
  25639. * @param scene defines the hosting scene
  25640. * @param pathArray defines the array of paths to use
  25641. * @param closeArray defines if the last path and the first path must be joined
  25642. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  25643. * @param offset defines the offset between points
  25644. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25645. * @param mesh defines the hosting mesh (can be null)
  25646. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25647. */
  25648. constructor(id: string, scene: Scene,
  25649. /**
  25650. * Defines the array of paths to use
  25651. */
  25652. pathArray: Vector3[][],
  25653. /**
  25654. * Defines if the last and first points of each path in your pathArray must be joined
  25655. */
  25656. closeArray: boolean,
  25657. /**
  25658. * Defines if the last and first points of each path in your pathArray must be joined
  25659. */
  25660. closePath: boolean,
  25661. /**
  25662. * Defines the offset between points
  25663. */
  25664. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  25665. /**
  25666. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25667. */
  25668. side?: number);
  25669. /** @hidden */
  25670. _regenerateVertexData(): VertexData;
  25671. copy(id: string): Geometry;
  25672. }
  25673. /**
  25674. * Creates a box geometry
  25675. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  25676. */
  25677. class BoxGeometry extends _PrimitiveGeometry {
  25678. /**
  25679. * Defines the zise of the box (width, height and depth are the same)
  25680. */
  25681. size: number;
  25682. /**
  25683. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25684. */
  25685. side: number;
  25686. /**
  25687. * Creates a box geometry
  25688. * @param id defines the unique ID of the geometry
  25689. * @param scene defines the hosting scene
  25690. * @param size defines the zise of the box (width, height and depth are the same)
  25691. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25692. * @param mesh defines the hosting mesh (can be null)
  25693. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25694. */
  25695. constructor(id: string, scene: Scene,
  25696. /**
  25697. * Defines the zise of the box (width, height and depth are the same)
  25698. */
  25699. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25700. /**
  25701. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25702. */
  25703. side?: number);
  25704. /** @hidden */
  25705. _regenerateVertexData(): VertexData;
  25706. copy(id: string): Geometry;
  25707. serialize(): any;
  25708. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  25709. }
  25710. /**
  25711. * Creates a sphere geometry
  25712. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  25713. */
  25714. class SphereGeometry extends _PrimitiveGeometry {
  25715. /**
  25716. * Defines the number of segments to use to create the sphere
  25717. */
  25718. segments: number;
  25719. /**
  25720. * Defines the diameter of the sphere
  25721. */
  25722. diameter: number;
  25723. /**
  25724. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25725. */
  25726. side: number;
  25727. /**
  25728. * Create a new sphere geometry
  25729. * @param id defines the unique ID of the geometry
  25730. * @param scene defines the hosting scene
  25731. * @param segments defines the number of segments to use to create the sphere
  25732. * @param diameter defines the diameter of the sphere
  25733. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25734. * @param mesh defines the hosting mesh (can be null)
  25735. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25736. */
  25737. constructor(id: string, scene: Scene,
  25738. /**
  25739. * Defines the number of segments to use to create the sphere
  25740. */
  25741. segments: number,
  25742. /**
  25743. * Defines the diameter of the sphere
  25744. */
  25745. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25746. /**
  25747. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25748. */
  25749. side?: number);
  25750. /** @hidden */
  25751. _regenerateVertexData(): VertexData;
  25752. copy(id: string): Geometry;
  25753. serialize(): any;
  25754. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  25755. }
  25756. /**
  25757. * Creates a disc geometry
  25758. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25759. */
  25760. class DiscGeometry extends _PrimitiveGeometry {
  25761. /**
  25762. * Defines the radius of the disc
  25763. */
  25764. radius: number;
  25765. /**
  25766. * Defines the tesselation factor to apply to the disc
  25767. */
  25768. tessellation: number;
  25769. /**
  25770. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25771. */
  25772. side: number;
  25773. /**
  25774. * Creates a new disc geometry
  25775. * @param id defines the unique ID of the geometry
  25776. * @param scene defines the hosting scene
  25777. * @param radius defines the radius of the disc
  25778. * @param tessellation defines the tesselation factor to apply to the disc
  25779. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25780. * @param mesh defines the hosting mesh (can be null)
  25781. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25782. */
  25783. constructor(id: string, scene: Scene,
  25784. /**
  25785. * Defines the radius of the disc
  25786. */
  25787. radius: number,
  25788. /**
  25789. * Defines the tesselation factor to apply to the disc
  25790. */
  25791. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25792. /**
  25793. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25794. */
  25795. side?: number);
  25796. /** @hidden */
  25797. _regenerateVertexData(): VertexData;
  25798. copy(id: string): Geometry;
  25799. }
  25800. /**
  25801. * Creates a new cylinder geometry
  25802. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  25803. */
  25804. class CylinderGeometry extends _PrimitiveGeometry {
  25805. /**
  25806. * Defines the height of the cylinder
  25807. */
  25808. height: number;
  25809. /**
  25810. * Defines the diameter of the cylinder's top cap
  25811. */
  25812. diameterTop: number;
  25813. /**
  25814. * Defines the diameter of the cylinder's bottom cap
  25815. */
  25816. diameterBottom: number;
  25817. /**
  25818. * Defines the tessellation factor to apply to the cylinder
  25819. */
  25820. tessellation: number;
  25821. /**
  25822. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25823. */
  25824. subdivisions: number;
  25825. /**
  25826. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25827. */
  25828. side: number;
  25829. /**
  25830. * Creates a new cylinder geometry
  25831. * @param id defines the unique ID of the geometry
  25832. * @param scene defines the hosting scene
  25833. * @param height defines the height of the cylinder
  25834. * @param diameterTop defines the diameter of the cylinder's top cap
  25835. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  25836. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  25837. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  25838. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25839. * @param mesh defines the hosting mesh (can be null)
  25840. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25841. */
  25842. constructor(id: string, scene: Scene,
  25843. /**
  25844. * Defines the height of the cylinder
  25845. */
  25846. height: number,
  25847. /**
  25848. * Defines the diameter of the cylinder's top cap
  25849. */
  25850. diameterTop: number,
  25851. /**
  25852. * Defines the diameter of the cylinder's bottom cap
  25853. */
  25854. diameterBottom: number,
  25855. /**
  25856. * Defines the tessellation factor to apply to the cylinder
  25857. */
  25858. tessellation: number,
  25859. /**
  25860. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25861. */
  25862. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25863. /**
  25864. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25865. */
  25866. side?: number);
  25867. /** @hidden */
  25868. _regenerateVertexData(): VertexData;
  25869. copy(id: string): Geometry;
  25870. serialize(): any;
  25871. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  25872. }
  25873. /**
  25874. * Creates a new torus geometry
  25875. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  25876. */
  25877. class TorusGeometry extends _PrimitiveGeometry {
  25878. /**
  25879. * Defines the diameter of the torus
  25880. */
  25881. diameter: number;
  25882. /**
  25883. * Defines the thickness of the torus (ie. internal diameter)
  25884. */
  25885. thickness: number;
  25886. /**
  25887. * Defines the tesselation factor to apply to the torus
  25888. */
  25889. tessellation: number;
  25890. /**
  25891. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25892. */
  25893. side: number;
  25894. /**
  25895. * Creates a new torus geometry
  25896. * @param id defines the unique ID of the geometry
  25897. * @param scene defines the hosting scene
  25898. * @param diameter defines the diameter of the torus
  25899. * @param thickness defines the thickness of the torus (ie. internal diameter)
  25900. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  25901. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25902. * @param mesh defines the hosting mesh (can be null)
  25903. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25904. */
  25905. constructor(id: string, scene: Scene,
  25906. /**
  25907. * Defines the diameter of the torus
  25908. */
  25909. diameter: number,
  25910. /**
  25911. * Defines the thickness of the torus (ie. internal diameter)
  25912. */
  25913. thickness: number,
  25914. /**
  25915. * Defines the tesselation factor to apply to the torus
  25916. */
  25917. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25918. /**
  25919. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25920. */
  25921. side?: number);
  25922. /** @hidden */
  25923. _regenerateVertexData(): VertexData;
  25924. copy(id: string): Geometry;
  25925. serialize(): any;
  25926. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  25927. }
  25928. /**
  25929. * Creates a new ground geometry
  25930. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  25931. */
  25932. class GroundGeometry extends _PrimitiveGeometry {
  25933. /**
  25934. * Defines the width of the ground
  25935. */
  25936. width: number;
  25937. /**
  25938. * Defines the height of the ground
  25939. */
  25940. height: number;
  25941. /**
  25942. * Defines the subdivisions to apply to the ground
  25943. */
  25944. subdivisions: number;
  25945. /**
  25946. * Creates a new ground geometry
  25947. * @param id defines the unique ID of the geometry
  25948. * @param scene defines the hosting scene
  25949. * @param width defines the width of the ground
  25950. * @param height defines the height of the ground
  25951. * @param subdivisions defines the subdivisions to apply to the ground
  25952. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25953. * @param mesh defines the hosting mesh (can be null)
  25954. */
  25955. constructor(id: string, scene: Scene,
  25956. /**
  25957. * Defines the width of the ground
  25958. */
  25959. width: number,
  25960. /**
  25961. * Defines the height of the ground
  25962. */
  25963. height: number,
  25964. /**
  25965. * Defines the subdivisions to apply to the ground
  25966. */
  25967. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25968. /** @hidden */
  25969. _regenerateVertexData(): VertexData;
  25970. copy(id: string): Geometry;
  25971. serialize(): any;
  25972. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  25973. }
  25974. /**
  25975. * Creates a tiled ground geometry
  25976. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  25977. */
  25978. class TiledGroundGeometry extends _PrimitiveGeometry {
  25979. /**
  25980. * Defines the minimum value on X axis
  25981. */
  25982. xmin: number;
  25983. /**
  25984. * Defines the minimum value on Z axis
  25985. */
  25986. zmin: number;
  25987. /**
  25988. * Defines the maximum value on X axis
  25989. */
  25990. xmax: number;
  25991. /**
  25992. * Defines the maximum value on Z axis
  25993. */
  25994. zmax: number;
  25995. /**
  25996. * Defines the subdivisions to apply to the ground
  25997. */
  25998. subdivisions: {
  25999. w: number;
  26000. h: number;
  26001. };
  26002. /**
  26003. * Defines the precision to use when computing the tiles
  26004. */
  26005. precision: {
  26006. w: number;
  26007. h: number;
  26008. };
  26009. /**
  26010. * Creates a tiled ground geometry
  26011. * @param id defines the unique ID of the geometry
  26012. * @param scene defines the hosting scene
  26013. * @param xmin defines the minimum value on X axis
  26014. * @param zmin defines the minimum value on Z axis
  26015. * @param xmax defines the maximum value on X axis
  26016. * @param zmax defines the maximum value on Z axis
  26017. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  26018. * @param precision defines the precision to use when computing the tiles
  26019. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26020. * @param mesh defines the hosting mesh (can be null)
  26021. */
  26022. constructor(id: string, scene: Scene,
  26023. /**
  26024. * Defines the minimum value on X axis
  26025. */
  26026. xmin: number,
  26027. /**
  26028. * Defines the minimum value on Z axis
  26029. */
  26030. zmin: number,
  26031. /**
  26032. * Defines the maximum value on X axis
  26033. */
  26034. xmax: number,
  26035. /**
  26036. * Defines the maximum value on Z axis
  26037. */
  26038. zmax: number,
  26039. /**
  26040. * Defines the subdivisions to apply to the ground
  26041. */
  26042. subdivisions: {
  26043. w: number;
  26044. h: number;
  26045. },
  26046. /**
  26047. * Defines the precision to use when computing the tiles
  26048. */
  26049. precision: {
  26050. w: number;
  26051. h: number;
  26052. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  26053. /** @hidden */
  26054. _regenerateVertexData(): VertexData;
  26055. copy(id: string): Geometry;
  26056. }
  26057. /**
  26058. * Creates a plane geometry
  26059. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  26060. */
  26061. class PlaneGeometry extends _PrimitiveGeometry {
  26062. /**
  26063. * Defines the size of the plane (width === height)
  26064. */
  26065. size: number;
  26066. /**
  26067. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26068. */
  26069. side: number;
  26070. /**
  26071. * Creates a plane geometry
  26072. * @param id defines the unique ID of the geometry
  26073. * @param scene defines the hosting scene
  26074. * @param size defines the size of the plane (width === height)
  26075. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26076. * @param mesh defines the hosting mesh (can be null)
  26077. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26078. */
  26079. constructor(id: string, scene: Scene,
  26080. /**
  26081. * Defines the size of the plane (width === height)
  26082. */
  26083. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26084. /**
  26085. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26086. */
  26087. side?: number);
  26088. /** @hidden */
  26089. _regenerateVertexData(): VertexData;
  26090. copy(id: string): Geometry;
  26091. serialize(): any;
  26092. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  26093. }
  26094. /**
  26095. * Creates a torus knot geometry
  26096. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  26097. */
  26098. class TorusKnotGeometry extends _PrimitiveGeometry {
  26099. /**
  26100. * Defines the radius of the torus knot
  26101. */
  26102. radius: number;
  26103. /**
  26104. * Defines the thickness of the torus knot tube
  26105. */
  26106. tube: number;
  26107. /**
  26108. * Defines the number of radial segments
  26109. */
  26110. radialSegments: number;
  26111. /**
  26112. * Defines the number of tubular segments
  26113. */
  26114. tubularSegments: number;
  26115. /**
  26116. * Defines the first number of windings
  26117. */
  26118. p: number;
  26119. /**
  26120. * Defines the second number of windings
  26121. */
  26122. q: number;
  26123. /**
  26124. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26125. */
  26126. side: number;
  26127. /**
  26128. * Creates a torus knot geometry
  26129. * @param id defines the unique ID of the geometry
  26130. * @param scene defines the hosting scene
  26131. * @param radius defines the radius of the torus knot
  26132. * @param tube defines the thickness of the torus knot tube
  26133. * @param radialSegments defines the number of radial segments
  26134. * @param tubularSegments defines the number of tubular segments
  26135. * @param p defines the first number of windings
  26136. * @param q defines the second number of windings
  26137. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26138. * @param mesh defines the hosting mesh (can be null)
  26139. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26140. */
  26141. constructor(id: string, scene: Scene,
  26142. /**
  26143. * Defines the radius of the torus knot
  26144. */
  26145. radius: number,
  26146. /**
  26147. * Defines the thickness of the torus knot tube
  26148. */
  26149. tube: number,
  26150. /**
  26151. * Defines the number of radial segments
  26152. */
  26153. radialSegments: number,
  26154. /**
  26155. * Defines the number of tubular segments
  26156. */
  26157. tubularSegments: number,
  26158. /**
  26159. * Defines the first number of windings
  26160. */
  26161. p: number,
  26162. /**
  26163. * Defines the second number of windings
  26164. */
  26165. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26166. /**
  26167. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26168. */
  26169. side?: number);
  26170. /** @hidden */
  26171. _regenerateVertexData(): VertexData;
  26172. copy(id: string): Geometry;
  26173. serialize(): any;
  26174. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  26175. }
  26176. }
  26177. declare module BABYLON {
  26178. /**
  26179. * Mesh representing the gorund
  26180. */
  26181. class GroundMesh extends Mesh {
  26182. /** If octree should be generated */
  26183. generateOctree: boolean;
  26184. private _heightQuads;
  26185. /** @hidden */
  26186. _subdivisionsX: number;
  26187. /** @hidden */
  26188. _subdivisionsY: number;
  26189. /** @hidden */
  26190. _width: number;
  26191. /** @hidden */
  26192. _height: number;
  26193. /** @hidden */
  26194. _minX: number;
  26195. /** @hidden */
  26196. _maxX: number;
  26197. /** @hidden */
  26198. _minZ: number;
  26199. /** @hidden */
  26200. _maxZ: number;
  26201. constructor(name: string, scene: Scene);
  26202. /**
  26203. * "GroundMesh"
  26204. * @returns "GroundMesh"
  26205. */
  26206. getClassName(): string;
  26207. /**
  26208. * The minimum of x and y subdivisions
  26209. */
  26210. readonly subdivisions: number;
  26211. /**
  26212. * X subdivisions
  26213. */
  26214. readonly subdivisionsX: number;
  26215. /**
  26216. * Y subdivisions
  26217. */
  26218. readonly subdivisionsY: number;
  26219. /**
  26220. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26221. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26222. * @param chunksCount the number of subdivisions for x and y
  26223. * @param octreeBlocksSize (Default: 32)
  26224. */
  26225. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26226. /**
  26227. * Returns a height (y) value in the Worl system :
  26228. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26229. * @param x x coordinate
  26230. * @param z z coordinate
  26231. * @returns the ground y position if (x, z) are outside the ground surface.
  26232. */
  26233. getHeightAtCoordinates(x: number, z: number): number;
  26234. /**
  26235. * Returns a normalized vector (Vector3) orthogonal to the ground
  26236. * at the ground coordinates (x, z) expressed in the World system.
  26237. * @param x x coordinate
  26238. * @param z z coordinate
  26239. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26240. */
  26241. getNormalAtCoordinates(x: number, z: number): Vector3;
  26242. /**
  26243. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26244. * at the ground coordinates (x, z) expressed in the World system.
  26245. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26246. * @param x x coordinate
  26247. * @param z z coordinate
  26248. * @param ref vector to store the result
  26249. * @returns the GroundMesh.
  26250. */
  26251. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26252. /**
  26253. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26254. * if the ground has been updated.
  26255. * This can be used in the render loop.
  26256. * @returns the GroundMesh.
  26257. */
  26258. updateCoordinateHeights(): GroundMesh;
  26259. private _getFacetAt;
  26260. private _initHeightQuads;
  26261. private _computeHeightQuads;
  26262. /**
  26263. * Serializes this ground mesh
  26264. * @param serializationObject object to write serialization to
  26265. */
  26266. serialize(serializationObject: any): void;
  26267. /**
  26268. * Parses a serialized ground mesh
  26269. * @param parsedMesh the serialized mesh
  26270. * @param scene the scene to create the ground mesh in
  26271. * @returns the created ground mesh
  26272. */
  26273. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26274. }
  26275. }
  26276. declare module BABYLON {
  26277. /**
  26278. * Creates an instance based on a source mesh.
  26279. */
  26280. class InstancedMesh extends AbstractMesh {
  26281. private _sourceMesh;
  26282. private _currentLOD;
  26283. /** @hidden */
  26284. _indexInSourceMeshInstanceArray: number;
  26285. constructor(name: string, source: Mesh);
  26286. /**
  26287. * Returns the string "InstancedMesh".
  26288. */
  26289. getClassName(): string;
  26290. /**
  26291. * If the source mesh receives shadows
  26292. */
  26293. readonly receiveShadows: boolean;
  26294. /**
  26295. * The material of the source mesh
  26296. */
  26297. readonly material: Nullable<Material>;
  26298. /**
  26299. * Visibility of the source mesh
  26300. */
  26301. readonly visibility: number;
  26302. /**
  26303. * Skeleton of the source mesh
  26304. */
  26305. readonly skeleton: Nullable<Skeleton>;
  26306. /**
  26307. * Rendering ground id of the source mesh
  26308. */
  26309. renderingGroupId: number;
  26310. /**
  26311. * Returns the total number of vertices (integer).
  26312. */
  26313. getTotalVertices(): number;
  26314. /**
  26315. * Returns a positive integer : the total number of indices in this mesh geometry.
  26316. * @returns the numner of indices or zero if the mesh has no geometry.
  26317. */
  26318. getTotalIndices(): number;
  26319. /**
  26320. * The source mesh of the instance
  26321. */
  26322. readonly sourceMesh: Mesh;
  26323. /**
  26324. * Is this node ready to be used/rendered
  26325. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26326. * @return {boolean} is it ready
  26327. */
  26328. isReady(completeCheck?: boolean): boolean;
  26329. /**
  26330. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26331. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  26332. * @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.
  26333. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  26334. */
  26335. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  26336. /**
  26337. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26338. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26339. * The `data` are either a numeric array either a Float32Array.
  26340. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  26341. * 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).
  26342. * Note that a new underlying VertexBuffer object is created each call.
  26343. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26344. *
  26345. * Possible `kind` values :
  26346. * - BABYLON.VertexBuffer.PositionKind
  26347. * - BABYLON.VertexBuffer.UVKind
  26348. * - BABYLON.VertexBuffer.UV2Kind
  26349. * - BABYLON.VertexBuffer.UV3Kind
  26350. * - BABYLON.VertexBuffer.UV4Kind
  26351. * - BABYLON.VertexBuffer.UV5Kind
  26352. * - BABYLON.VertexBuffer.UV6Kind
  26353. * - BABYLON.VertexBuffer.ColorKind
  26354. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26355. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26356. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26357. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26358. *
  26359. * Returns the Mesh.
  26360. */
  26361. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26362. /**
  26363. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26364. * If the mesh has no geometry, it is simply returned as it is.
  26365. * The `data` are either a numeric array either a Float32Array.
  26366. * No new underlying VertexBuffer object is created.
  26367. * 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.
  26368. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  26369. *
  26370. * Possible `kind` values :
  26371. * - BABYLON.VertexBuffer.PositionKind
  26372. * - BABYLON.VertexBuffer.UVKind
  26373. * - BABYLON.VertexBuffer.UV2Kind
  26374. * - BABYLON.VertexBuffer.UV3Kind
  26375. * - BABYLON.VertexBuffer.UV4Kind
  26376. * - BABYLON.VertexBuffer.UV5Kind
  26377. * - BABYLON.VertexBuffer.UV6Kind
  26378. * - BABYLON.VertexBuffer.ColorKind
  26379. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26380. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26381. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26382. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26383. *
  26384. * Returns the Mesh.
  26385. */
  26386. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26387. /**
  26388. * Sets the mesh indices.
  26389. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  26390. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26391. * This method creates a new index buffer each call.
  26392. * Returns the Mesh.
  26393. */
  26394. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  26395. /**
  26396. * Boolean : True if the mesh owns the requested kind of data.
  26397. */
  26398. isVerticesDataPresent(kind: string): boolean;
  26399. /**
  26400. * Returns an array of indices (IndicesArray).
  26401. */
  26402. getIndices(): Nullable<IndicesArray>;
  26403. readonly _positions: Nullable<Vector3[]>;
  26404. /**
  26405. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26406. * This means the mesh underlying bounding box and sphere are recomputed.
  26407. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26408. * @returns the current mesh
  26409. */
  26410. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  26411. /** @hidden */
  26412. _preActivate(): InstancedMesh;
  26413. /** @hidden */
  26414. _activate(renderId: number): InstancedMesh;
  26415. /**
  26416. * Returns the current associated LOD AbstractMesh.
  26417. */
  26418. getLOD(camera: Camera): AbstractMesh;
  26419. /** @hidden */
  26420. _syncSubMeshes(): InstancedMesh;
  26421. /** @hidden */
  26422. _generatePointsArray(): boolean;
  26423. /**
  26424. * Creates a new InstancedMesh from the current mesh.
  26425. * - name (string) : the cloned mesh name
  26426. * - newParent (optional Node) : the optional Node to parent the clone to.
  26427. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  26428. *
  26429. * Returns the clone.
  26430. */
  26431. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  26432. /**
  26433. * Disposes the InstancedMesh.
  26434. * Returns nothing.
  26435. */
  26436. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26437. }
  26438. }
  26439. declare module BABYLON {
  26440. /**
  26441. * Line mesh
  26442. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  26443. */
  26444. class LinesMesh extends Mesh {
  26445. /**
  26446. * If vertex color should be applied to the mesh
  26447. */
  26448. useVertexColor?: boolean | undefined;
  26449. /**
  26450. * If vertex alpha should be applied to the mesh
  26451. */
  26452. useVertexAlpha?: boolean | undefined;
  26453. /**
  26454. * Color of the line (Default: White)
  26455. */
  26456. color: Color3;
  26457. /**
  26458. * Alpha of the line (Default: 1)
  26459. */
  26460. alpha: number;
  26461. /**
  26462. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26463. * This margin is expressed in world space coordinates, so its value may vary.
  26464. * Default value is 0.1
  26465. */
  26466. intersectionThreshold: number;
  26467. private _colorShader;
  26468. /**
  26469. * Creates a new LinesMesh
  26470. * @param name defines the name
  26471. * @param scene defines the hosting scene
  26472. * @param parent defines the parent mesh if any
  26473. * @param source defines the optional source LinesMesh used to clone data from
  26474. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26475. * When false, achieved by calling a clone(), also passing False.
  26476. * This will make creation of children, recursive.
  26477. * @param useVertexColor defines if this LinesMesh supports vertex color
  26478. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  26479. */
  26480. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  26481. /**
  26482. * If vertex color should be applied to the mesh
  26483. */
  26484. useVertexColor?: boolean | undefined,
  26485. /**
  26486. * If vertex alpha should be applied to the mesh
  26487. */
  26488. useVertexAlpha?: boolean | undefined);
  26489. /**
  26490. * Returns the string "LineMesh"
  26491. */
  26492. getClassName(): string;
  26493. /**
  26494. * @hidden
  26495. */
  26496. /**
  26497. * @hidden
  26498. */
  26499. material: Material;
  26500. /**
  26501. * @hidden
  26502. */
  26503. readonly checkCollisions: boolean;
  26504. /** @hidden */
  26505. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  26506. /** @hidden */
  26507. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  26508. /**
  26509. * Disposes of the line mesh
  26510. * @param doNotRecurse If children should be disposed
  26511. */
  26512. dispose(doNotRecurse?: boolean): void;
  26513. /**
  26514. * Returns a new LineMesh object cloned from the current one.
  26515. */
  26516. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  26517. /**
  26518. * Creates a new InstancedLinesMesh object from the mesh model.
  26519. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26520. * @param name defines the name of the new instance
  26521. * @returns a new InstancedLinesMesh
  26522. */
  26523. createInstance(name: string): InstancedLinesMesh;
  26524. }
  26525. /**
  26526. * Creates an instance based on a source LinesMesh
  26527. */
  26528. class InstancedLinesMesh extends InstancedMesh {
  26529. /**
  26530. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26531. * This margin is expressed in world space coordinates, so its value may vary.
  26532. * Initilized with the intersectionThreshold value of the source LinesMesh
  26533. */
  26534. intersectionThreshold: number;
  26535. constructor(name: string, source: LinesMesh);
  26536. /**
  26537. * Returns the string "InstancedLinesMesh".
  26538. */
  26539. getClassName(): string;
  26540. }
  26541. }
  26542. declare module BABYLON {
  26543. /**
  26544. * @hidden
  26545. **/
  26546. class _CreationDataStorage {
  26547. closePath?: boolean;
  26548. closeArray?: boolean;
  26549. idx: number[];
  26550. dashSize: number;
  26551. gapSize: number;
  26552. path3D: Path3D;
  26553. pathArray: Vector3[][];
  26554. arc: number;
  26555. radius: number;
  26556. cap: number;
  26557. tessellation: number;
  26558. }
  26559. /**
  26560. * @hidden
  26561. **/
  26562. class _InstanceDataStorage {
  26563. visibleInstances: any;
  26564. renderIdForInstances: number[];
  26565. batchCache: _InstancesBatch;
  26566. instancesBufferSize: number;
  26567. instancesBuffer: Nullable<Buffer>;
  26568. instancesData: Float32Array;
  26569. overridenInstanceCount: number;
  26570. }
  26571. /**
  26572. * @hidden
  26573. **/
  26574. class _InstancesBatch {
  26575. mustReturn: boolean;
  26576. visibleInstances: Nullable<InstancedMesh[]>[];
  26577. renderSelf: boolean[];
  26578. }
  26579. /**
  26580. * Class used to represent renderable models
  26581. */
  26582. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26583. /**
  26584. * Mesh side orientation : usually the external or front surface
  26585. */
  26586. static readonly FRONTSIDE: number;
  26587. /**
  26588. * Mesh side orientation : usually the internal or back surface
  26589. */
  26590. static readonly BACKSIDE: number;
  26591. /**
  26592. * Mesh side orientation : both internal and external or front and back surfaces
  26593. */
  26594. static readonly DOUBLESIDE: number;
  26595. /**
  26596. * Mesh side orientation : by default, `FRONTSIDE`
  26597. */
  26598. static readonly DEFAULTSIDE: number;
  26599. /**
  26600. * Mesh cap setting : no cap
  26601. */
  26602. static readonly NO_CAP: number;
  26603. /**
  26604. * Mesh cap setting : one cap at the beginning of the mesh
  26605. */
  26606. static readonly CAP_START: number;
  26607. /**
  26608. * Mesh cap setting : one cap at the end of the mesh
  26609. */
  26610. static readonly CAP_END: number;
  26611. /**
  26612. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26613. */
  26614. static readonly CAP_ALL: number;
  26615. private _onBeforeRenderObservable;
  26616. private _onAfterRenderObservable;
  26617. private _onBeforeDrawObservable;
  26618. /**
  26619. * An event triggered before rendering the mesh
  26620. */
  26621. readonly onBeforeRenderObservable: Observable<Mesh>;
  26622. /**
  26623. * An event triggered after rendering the mesh
  26624. */
  26625. readonly onAfterRenderObservable: Observable<Mesh>;
  26626. /**
  26627. * An event triggered before drawing the mesh
  26628. */
  26629. readonly onBeforeDrawObservable: Observable<Mesh>;
  26630. private _onBeforeDrawObserver;
  26631. /**
  26632. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26633. */
  26634. onBeforeDraw: () => void;
  26635. /**
  26636. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26637. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26638. */
  26639. delayLoadState: number;
  26640. /**
  26641. * Gets the list of instances created from this mesh
  26642. * it is not supposed to be modified manually.
  26643. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  26644. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26645. */
  26646. instances: InstancedMesh[];
  26647. /**
  26648. * Gets the file containing delay loading data for this mesh
  26649. */
  26650. delayLoadingFile: string;
  26651. /** @hidden */
  26652. _binaryInfo: any;
  26653. private _LODLevels;
  26654. /**
  26655. * User defined function used to change how LOD level selection is done
  26656. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26657. */
  26658. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26659. private _morphTargetManager;
  26660. /**
  26661. * Gets or sets the morph target manager
  26662. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26663. */
  26664. morphTargetManager: Nullable<MorphTargetManager>;
  26665. /** @hidden */
  26666. _creationDataStorage: Nullable<_CreationDataStorage>;
  26667. /** @hidden */
  26668. _geometry: Nullable<Geometry>;
  26669. /** @hidden */
  26670. _delayInfo: Array<string>;
  26671. /** @hidden */
  26672. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26673. /** @hidden */
  26674. _instanceDataStorage: _InstanceDataStorage;
  26675. private _effectiveMaterial;
  26676. /** @hidden */
  26677. _shouldGenerateFlatShading: boolean;
  26678. private _preActivateId;
  26679. /** @hidden */
  26680. _originalBuilderSideOrientation: number;
  26681. /**
  26682. * Use this property to change the original side orientation defined at construction time
  26683. */
  26684. overrideMaterialSideOrientation: Nullable<number>;
  26685. private _areNormalsFrozen;
  26686. private _sourcePositions;
  26687. private _sourceNormals;
  26688. private _source;
  26689. private meshMap;
  26690. /**
  26691. * Gets the source mesh (the one used to clone this one from)
  26692. */
  26693. readonly source: Nullable<Mesh>;
  26694. /**
  26695. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26696. */
  26697. isUnIndexed: boolean;
  26698. /**
  26699. * @constructor
  26700. * @param name The value used by scene.getMeshByName() to do a lookup.
  26701. * @param scene The scene to add this mesh to.
  26702. * @param parent The parent of this mesh, if it has one
  26703. * @param source An optional Mesh from which geometry is shared, cloned.
  26704. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26705. * When false, achieved by calling a clone(), also passing False.
  26706. * This will make creation of children, recursive.
  26707. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26708. */
  26709. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26710. /**
  26711. * Gets the class name
  26712. * @returns the string "Mesh".
  26713. */
  26714. getClassName(): string;
  26715. /**
  26716. * Returns a description of this mesh
  26717. * @param fullDetails define if full details about this mesh must be used
  26718. * @returns a descriptive string representing this mesh
  26719. */
  26720. toString(fullDetails?: boolean): string;
  26721. /** @hidden */
  26722. _unBindEffect(): void;
  26723. /**
  26724. * Gets a boolean indicating if this mesh has LOD
  26725. */
  26726. readonly hasLODLevels: boolean;
  26727. /**
  26728. * Gets the list of MeshLODLevel associated with the current mesh
  26729. * @returns an array of MeshLODLevel
  26730. */
  26731. getLODLevels(): MeshLODLevel[];
  26732. private _sortLODLevels;
  26733. /**
  26734. * Add a mesh as LOD level triggered at the given distance.
  26735. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26736. * @param distance The distance from the center of the object to show this level
  26737. * @param mesh The mesh to be added as LOD level (can be null)
  26738. * @return This mesh (for chaining)
  26739. */
  26740. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  26741. /**
  26742. * Returns the LOD level mesh at the passed distance or null if not found.
  26743. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26744. * @param distance The distance from the center of the object to show this level
  26745. * @returns a Mesh or `null`
  26746. */
  26747. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  26748. /**
  26749. * Remove a mesh from the LOD array
  26750. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26751. * @param mesh defines the mesh to be removed
  26752. * @return This mesh (for chaining)
  26753. */
  26754. removeLODLevel(mesh: Mesh): Mesh;
  26755. /**
  26756. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  26757. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26758. * @param camera defines the camera to use to compute distance
  26759. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  26760. * @return This mesh (for chaining)
  26761. */
  26762. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  26763. /**
  26764. * Gets the mesh internal Geometry object
  26765. */
  26766. readonly geometry: Nullable<Geometry>;
  26767. /**
  26768. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  26769. * @returns the total number of vertices
  26770. */
  26771. getTotalVertices(): number;
  26772. /**
  26773. * Returns the content of an associated vertex buffer
  26774. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26775. * - BABYLON.VertexBuffer.PositionKind
  26776. * - BABYLON.VertexBuffer.UVKind
  26777. * - BABYLON.VertexBuffer.UV2Kind
  26778. * - BABYLON.VertexBuffer.UV3Kind
  26779. * - BABYLON.VertexBuffer.UV4Kind
  26780. * - BABYLON.VertexBuffer.UV5Kind
  26781. * - BABYLON.VertexBuffer.UV6Kind
  26782. * - BABYLON.VertexBuffer.ColorKind
  26783. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26784. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26785. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26786. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26787. * @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
  26788. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  26789. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  26790. */
  26791. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26792. /**
  26793. * Returns the mesh VertexBuffer object from the requested `kind`
  26794. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26795. * - BABYLON.VertexBuffer.PositionKind
  26796. * - BABYLON.VertexBuffer.UVKind
  26797. * - BABYLON.VertexBuffer.UV2Kind
  26798. * - BABYLON.VertexBuffer.UV3Kind
  26799. * - BABYLON.VertexBuffer.UV4Kind
  26800. * - BABYLON.VertexBuffer.UV5Kind
  26801. * - BABYLON.VertexBuffer.UV6Kind
  26802. * - BABYLON.VertexBuffer.ColorKind
  26803. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26804. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26805. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26806. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26807. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  26808. */
  26809. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26810. /**
  26811. * Tests if a specific vertex buffer is associated with this mesh
  26812. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26813. * - BABYLON.VertexBuffer.PositionKind
  26814. * - BABYLON.VertexBuffer.UVKind
  26815. * - BABYLON.VertexBuffer.UV2Kind
  26816. * - BABYLON.VertexBuffer.UV3Kind
  26817. * - BABYLON.VertexBuffer.UV4Kind
  26818. * - BABYLON.VertexBuffer.UV5Kind
  26819. * - BABYLON.VertexBuffer.UV6Kind
  26820. * - BABYLON.VertexBuffer.ColorKind
  26821. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26822. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26823. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26824. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26825. * @returns a boolean
  26826. */
  26827. isVerticesDataPresent(kind: string): boolean;
  26828. /**
  26829. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  26830. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26831. * - BABYLON.VertexBuffer.PositionKind
  26832. * - BABYLON.VertexBuffer.UVKind
  26833. * - BABYLON.VertexBuffer.UV2Kind
  26834. * - BABYLON.VertexBuffer.UV3Kind
  26835. * - BABYLON.VertexBuffer.UV4Kind
  26836. * - BABYLON.VertexBuffer.UV5Kind
  26837. * - BABYLON.VertexBuffer.UV6Kind
  26838. * - BABYLON.VertexBuffer.ColorKind
  26839. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26840. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26841. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26842. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26843. * @returns a boolean
  26844. */
  26845. isVertexBufferUpdatable(kind: string): boolean;
  26846. /**
  26847. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  26848. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26849. * - BABYLON.VertexBuffer.PositionKind
  26850. * - BABYLON.VertexBuffer.UVKind
  26851. * - BABYLON.VertexBuffer.UV2Kind
  26852. * - BABYLON.VertexBuffer.UV3Kind
  26853. * - BABYLON.VertexBuffer.UV4Kind
  26854. * - BABYLON.VertexBuffer.UV5Kind
  26855. * - BABYLON.VertexBuffer.UV6Kind
  26856. * - BABYLON.VertexBuffer.ColorKind
  26857. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26858. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26859. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26860. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26861. * @returns an array of strings
  26862. */
  26863. getVerticesDataKinds(): string[];
  26864. /**
  26865. * Returns a positive integer : the total number of indices in this mesh geometry.
  26866. * @returns the numner of indices or zero if the mesh has no geometry.
  26867. */
  26868. getTotalIndices(): number;
  26869. /**
  26870. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26871. * @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.
  26872. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26873. * @returns the indices array or an empty array if the mesh has no geometry
  26874. */
  26875. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26876. readonly isBlocked: boolean;
  26877. /**
  26878. * Determine if the current mesh is ready to be rendered
  26879. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26880. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  26881. * @returns true if all associated assets are ready (material, textures, shaders)
  26882. */
  26883. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  26884. /**
  26885. * 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.
  26886. */
  26887. readonly areNormalsFrozen: boolean;
  26888. /**
  26889. * 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.
  26890. * @returns the current mesh
  26891. */
  26892. freezeNormals(): Mesh;
  26893. /**
  26894. * 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
  26895. * @returns the current mesh
  26896. */
  26897. unfreezeNormals(): Mesh;
  26898. /**
  26899. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  26900. */
  26901. overridenInstanceCount: number;
  26902. /** @hidden */
  26903. _preActivate(): Mesh;
  26904. /** @hidden */
  26905. _preActivateForIntermediateRendering(renderId: number): Mesh;
  26906. /** @hidden */
  26907. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  26908. /**
  26909. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26910. * This means the mesh underlying bounding box and sphere are recomputed.
  26911. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26912. * @returns the current mesh
  26913. */
  26914. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  26915. /** @hidden */
  26916. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  26917. /**
  26918. * This function will subdivide the mesh into multiple submeshes
  26919. * @param count defines the expected number of submeshes
  26920. */
  26921. subdivide(count: number): void;
  26922. /**
  26923. * Copy a FloatArray into a specific associated vertex buffer
  26924. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26925. * - BABYLON.VertexBuffer.PositionKind
  26926. * - BABYLON.VertexBuffer.UVKind
  26927. * - BABYLON.VertexBuffer.UV2Kind
  26928. * - BABYLON.VertexBuffer.UV3Kind
  26929. * - BABYLON.VertexBuffer.UV4Kind
  26930. * - BABYLON.VertexBuffer.UV5Kind
  26931. * - BABYLON.VertexBuffer.UV6Kind
  26932. * - BABYLON.VertexBuffer.ColorKind
  26933. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26934. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26935. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26936. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26937. * @param data defines the data source
  26938. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26939. * @param stride defines the data stride size (can be null)
  26940. * @returns the current mesh
  26941. */
  26942. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26943. /**
  26944. * Flags an associated vertex buffer as updatable
  26945. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  26946. * - BABYLON.VertexBuffer.PositionKind
  26947. * - BABYLON.VertexBuffer.UVKind
  26948. * - BABYLON.VertexBuffer.UV2Kind
  26949. * - BABYLON.VertexBuffer.UV3Kind
  26950. * - BABYLON.VertexBuffer.UV4Kind
  26951. * - BABYLON.VertexBuffer.UV5Kind
  26952. * - BABYLON.VertexBuffer.UV6Kind
  26953. * - BABYLON.VertexBuffer.ColorKind
  26954. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26955. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26956. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26957. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26958. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26959. */
  26960. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  26961. /**
  26962. * Sets the mesh global Vertex Buffer
  26963. * @param buffer defines the buffer to use
  26964. * @returns the current mesh
  26965. */
  26966. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  26967. /**
  26968. * Update a specific associated vertex buffer
  26969. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26970. * - BABYLON.VertexBuffer.PositionKind
  26971. * - BABYLON.VertexBuffer.UVKind
  26972. * - BABYLON.VertexBuffer.UV2Kind
  26973. * - BABYLON.VertexBuffer.UV3Kind
  26974. * - BABYLON.VertexBuffer.UV4Kind
  26975. * - BABYLON.VertexBuffer.UV5Kind
  26976. * - BABYLON.VertexBuffer.UV6Kind
  26977. * - BABYLON.VertexBuffer.ColorKind
  26978. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26979. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26980. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26981. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26982. * @param data defines the data source
  26983. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26984. * @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)
  26985. * @returns the current mesh
  26986. */
  26987. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26988. /**
  26989. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  26990. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  26991. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  26992. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  26993. * @returns the current mesh
  26994. */
  26995. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  26996. /**
  26997. * Creates a un-shared specific occurence of the geometry for the mesh.
  26998. * @returns the current mesh
  26999. */
  27000. makeGeometryUnique(): Mesh;
  27001. /**
  27002. * Set the index buffer of this mesh
  27003. * @param indices defines the source data
  27004. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27005. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27006. * @returns the current mesh
  27007. */
  27008. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  27009. /**
  27010. * Update the current index buffer
  27011. * @param indices defines the source data
  27012. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27013. * @returns the current mesh
  27014. */
  27015. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  27016. /**
  27017. * Invert the geometry to move from a right handed system to a left handed one.
  27018. * @returns the current mesh
  27019. */
  27020. toLeftHanded(): Mesh;
  27021. /** @hidden */
  27022. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27023. /** @hidden */
  27024. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  27025. /**
  27026. * Registers for this mesh a javascript function called just before the rendering process
  27027. * @param func defines the function to call before rendering this mesh
  27028. * @returns the current mesh
  27029. */
  27030. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27031. /**
  27032. * Disposes a previously registered javascript function called before the rendering
  27033. * @param func defines the function to remove
  27034. * @returns the current mesh
  27035. */
  27036. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27037. /**
  27038. * Registers for this mesh a javascript function called just after the rendering is complete
  27039. * @param func defines the function to call after rendering this mesh
  27040. * @returns the current mesh
  27041. */
  27042. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27043. /**
  27044. * Disposes a previously registered javascript function called after the rendering.
  27045. * @param func defines the function to remove
  27046. * @returns the current mesh
  27047. */
  27048. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27049. /** @hidden */
  27050. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  27051. /** @hidden */
  27052. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27053. /** @hidden */
  27054. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27055. /**
  27056. * 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
  27057. * @param subMesh defines the subMesh to render
  27058. * @param enableAlphaMode defines if alpha mode can be changed
  27059. * @returns the current mesh
  27060. */
  27061. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  27062. private _onBeforeDraw;
  27063. /**
  27064. * Renormalize the mesh and patch it up if there are no weights
  27065. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27066. * However in the case of zero weights then we set just a single influence to 1.
  27067. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27068. */
  27069. cleanMatrixWeights(): void;
  27070. private normalizeSkinFourWeights;
  27071. private normalizeSkinWeightsAndExtra;
  27072. /**
  27073. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27074. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27075. * the user know there was an issue with importing the mesh
  27076. * @returns a validation object with skinned, valid and report string
  27077. */
  27078. validateSkinning(): {
  27079. skinned: boolean;
  27080. valid: boolean;
  27081. report: string;
  27082. };
  27083. /** @hidden */
  27084. _checkDelayState(): Mesh;
  27085. private _queueLoad;
  27086. /**
  27087. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27088. * A mesh is in the frustum if its bounding box intersects the frustum
  27089. * @param frustumPlanes defines the frustum to test
  27090. * @returns true if the mesh is in the frustum planes
  27091. */
  27092. isInFrustum(frustumPlanes: Plane[]): boolean;
  27093. /**
  27094. * Sets the mesh material by the material or multiMaterial `id` property
  27095. * @param id is a string identifying the material or the multiMaterial
  27096. * @returns the current mesh
  27097. */
  27098. setMaterialByID(id: string): Mesh;
  27099. /**
  27100. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27101. * @returns an array of IAnimatable
  27102. */
  27103. getAnimatables(): IAnimatable[];
  27104. /**
  27105. * Modifies the mesh geometry according to the passed transformation matrix.
  27106. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27107. * The mesh normals are modified using the same transformation.
  27108. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27109. * @param transform defines the transform matrix to use
  27110. * @see http://doc.babylonjs.com/resources/baking_transformations
  27111. * @returns the current mesh
  27112. */
  27113. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27114. /**
  27115. * Modifies the mesh geometry according to its own current World Matrix.
  27116. * The mesh World Matrix is then reset.
  27117. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27118. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27119. * @see http://doc.babylonjs.com/resources/baking_transformations
  27120. * @returns the current mesh
  27121. */
  27122. bakeCurrentTransformIntoVertices(): Mesh;
  27123. /** @hidden */
  27124. readonly _positions: Nullable<Vector3[]>;
  27125. /** @hidden */
  27126. _resetPointsArrayCache(): Mesh;
  27127. /** @hidden */
  27128. _generatePointsArray(): boolean;
  27129. /**
  27130. * Returns a new Mesh object generated from the current mesh properties.
  27131. * This method must not get confused with createInstance()
  27132. * @param name is a string, the name given to the new mesh
  27133. * @param newParent can be any Node object (default `null`)
  27134. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27135. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27136. * @returns a new mesh
  27137. */
  27138. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27139. /**
  27140. * Releases resources associated with this mesh.
  27141. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27142. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27143. */
  27144. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27145. /**
  27146. * Modifies the mesh geometry according to a displacement map.
  27147. * 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.
  27148. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27149. * @param url is a string, the URL from the image file is to be downloaded.
  27150. * @param minHeight is the lower limit of the displacement.
  27151. * @param maxHeight is the upper limit of the displacement.
  27152. * @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.
  27153. * @param uvOffset is an optional vector2 used to offset UV.
  27154. * @param uvScale is an optional vector2 used to scale UV.
  27155. * @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.
  27156. * @returns the Mesh.
  27157. */
  27158. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27159. /**
  27160. * Modifies the mesh geometry according to a displacementMap buffer.
  27161. * 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.
  27162. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27163. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27164. * @param heightMapWidth is the width of the buffer image.
  27165. * @param heightMapHeight is the height of the buffer image.
  27166. * @param minHeight is the lower limit of the displacement.
  27167. * @param maxHeight is the upper limit of the displacement.
  27168. * @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.
  27169. * @param uvOffset is an optional vector2 used to offset UV.
  27170. * @param uvScale is an optional vector2 used to scale UV.
  27171. * @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.
  27172. * @returns the Mesh.
  27173. */
  27174. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27175. /**
  27176. * Modify the mesh to get a flat shading rendering.
  27177. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27178. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27179. * @returns current mesh
  27180. */
  27181. convertToFlatShadedMesh(): Mesh;
  27182. /**
  27183. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27184. * In other words, more vertices, no more indices and a single bigger VBO.
  27185. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27186. * @returns current mesh
  27187. */
  27188. convertToUnIndexedMesh(): Mesh;
  27189. /**
  27190. * Inverses facet orientations.
  27191. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27192. * @param flipNormals will also inverts the normals
  27193. * @returns current mesh
  27194. */
  27195. flipFaces(flipNormals?: boolean): Mesh;
  27196. /**
  27197. * Creates a new InstancedMesh object from the mesh model.
  27198. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27199. * @param name defines the name of the new instance
  27200. * @returns a new InstancedMesh
  27201. */
  27202. createInstance(name: string): InstancedMesh;
  27203. /**
  27204. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27205. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27206. * @returns the current mesh
  27207. */
  27208. synchronizeInstances(): Mesh;
  27209. /**
  27210. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27211. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27212. * This should be used together with the simplification to avoid disappearing triangles.
  27213. * @param successCallback an optional success callback to be called after the optimization finished.
  27214. * @returns the current mesh
  27215. */
  27216. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27217. /**
  27218. * Serialize current mesh
  27219. * @param serializationObject defines the object which will receive the serialization data
  27220. */
  27221. serialize(serializationObject: any): void;
  27222. /** @hidden */
  27223. _syncGeometryWithMorphTargetManager(): void;
  27224. /**
  27225. * Returns a new Mesh object parsed from the source provided.
  27226. * @param parsedMesh is the source
  27227. * @param scene defines the hosting scene
  27228. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27229. * @returns a new Mesh
  27230. */
  27231. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27232. /**
  27233. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27234. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27235. * @param name defines the name of the mesh to create
  27236. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27237. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27238. * @param closePath creates a seam between the first and the last points of each path of the path array
  27239. * @param offset is taken in account only if the `pathArray` is containing a single path
  27240. * @param scene defines the hosting scene
  27241. * @param updatable defines if the mesh must be flagged as updatable
  27242. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27243. * @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)
  27244. * @returns a new Mesh
  27245. */
  27246. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27247. /**
  27248. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27249. * @param name defines the name of the mesh to create
  27250. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27251. * @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
  27252. * @param scene defines the hosting scene
  27253. * @param updatable defines if the mesh must be flagged as updatable
  27254. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27255. * @returns a new Mesh
  27256. */
  27257. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27258. /**
  27259. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27260. * @param name defines the name of the mesh to create
  27261. * @param size sets the size (float) of each box side (default 1)
  27262. * @param scene defines the hosting scene
  27263. * @param updatable defines if the mesh must be flagged as updatable
  27264. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27265. * @returns a new Mesh
  27266. */
  27267. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27268. /**
  27269. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27270. * @param name defines the name of the mesh to create
  27271. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27272. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27273. * @param scene defines the hosting scene
  27274. * @param updatable defines if the mesh must be flagged as updatable
  27275. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27276. * @returns a new Mesh
  27277. */
  27278. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27279. /**
  27280. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27281. * @param name defines the name of the mesh to create
  27282. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27283. * @param diameterTop set the top cap diameter (floats, default 1)
  27284. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27285. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27286. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27287. * @param scene defines the hosting scene
  27288. * @param updatable defines if the mesh must be flagged as updatable
  27289. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27290. * @returns a new Mesh
  27291. */
  27292. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27293. /**
  27294. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  27295. * @param name defines the name of the mesh to create
  27296. * @param diameter sets the diameter size (float) of the torus (default 1)
  27297. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  27298. * @param tessellation sets the number of torus sides (postive integer, default 16)
  27299. * @param scene defines the hosting scene
  27300. * @param updatable defines if the mesh must be flagged as updatable
  27301. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27302. * @returns a new Mesh
  27303. */
  27304. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27305. /**
  27306. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  27307. * @param name defines the name of the mesh to create
  27308. * @param radius sets the global radius size (float) of the torus knot (default 2)
  27309. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  27310. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  27311. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  27312. * @param p the number of windings on X axis (positive integers, default 2)
  27313. * @param q the number of windings on Y axis (positive integers, default 3)
  27314. * @param scene defines the hosting scene
  27315. * @param updatable defines if the mesh must be flagged as updatable
  27316. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27317. * @returns a new Mesh
  27318. */
  27319. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27320. /**
  27321. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  27322. * @param name defines the name of the mesh to create
  27323. * @param points is an array successive Vector3
  27324. * @param scene defines the hosting scene
  27325. * @param updatable defines if the mesh must be flagged as updatable
  27326. * @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).
  27327. * @returns a new Mesh
  27328. */
  27329. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  27330. /**
  27331. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  27332. * @param name defines the name of the mesh to create
  27333. * @param points is an array successive Vector3
  27334. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  27335. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27336. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  27337. * @param scene defines the hosting scene
  27338. * @param updatable defines if the mesh must be flagged as updatable
  27339. * @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)
  27340. * @returns a new Mesh
  27341. */
  27342. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  27343. /**
  27344. * Creates a polygon mesh.
  27345. * Please consider using the same method from the MeshBuilder class instead.
  27346. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  27347. * 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.
  27348. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27349. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27350. * Remember you can only change the shape positions, not their number when updating a polygon.
  27351. */
  27352. /**
  27353. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  27354. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  27355. * @param name defines the name of the mesh to create
  27356. * @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
  27357. * @param scene defines the hosting scene
  27358. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27359. * @param updatable defines if the mesh must be flagged as updatable
  27360. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27361. * @returns a new Mesh
  27362. */
  27363. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27364. /**
  27365. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  27366. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  27367. * @param name defines the name of the mesh to create
  27368. * @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
  27369. * @param depth defines the height of extrusion
  27370. * @param scene defines the hosting scene
  27371. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27372. * @param updatable defines if the mesh must be flagged as updatable
  27373. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27374. * @returns a new Mesh
  27375. */
  27376. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27377. /**
  27378. * Creates an extruded shape mesh.
  27379. * 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
  27380. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27381. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27382. * @param name defines the name of the mesh to create
  27383. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  27384. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27385. * @param scale is the value to scale the shape
  27386. * @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
  27387. * @param cap sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  27388. * @param scene defines the hosting scene
  27389. * @param updatable defines if the mesh must be flagged as updatable
  27390. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27391. * @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)
  27392. * @returns a new Mesh
  27393. */
  27394. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27395. /**
  27396. * Creates an custom extruded shape mesh.
  27397. * The custom extrusion is a parametric shape.
  27398. * It has no predefined shape. Its final shape will depend on the input parameters.
  27399. * Please consider using the same method from the MeshBuilder class instead
  27400. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27401. * @param name defines the name of the mesh to create
  27402. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  27403. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27404. * @param scaleFunction is a custom Javascript function called on each path point
  27405. * @param rotationFunction is a custom Javascript function called on each path point
  27406. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27407. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  27408. * @param cap sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  27409. * @param scene defines the hosting scene
  27410. * @param updatable defines if the mesh must be flagged as updatable
  27411. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27412. * @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)
  27413. * @returns a new Mesh
  27414. */
  27415. 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;
  27416. /**
  27417. * Creates lathe mesh.
  27418. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  27419. * Please consider using the same method from the MeshBuilder class instead
  27420. * @param name defines the name of the mesh to create
  27421. * @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
  27422. * @param radius is the radius value of the lathe
  27423. * @param tessellation is the side number of the lathe.
  27424. * @param scene defines the hosting scene
  27425. * @param updatable defines if the mesh must be flagged as updatable
  27426. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27427. * @returns a new Mesh
  27428. */
  27429. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27430. /**
  27431. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  27432. * @param name defines the name of the mesh to create
  27433. * @param size sets the size (float) of both sides of the plane at once (default 1)
  27434. * @param scene defines the hosting scene
  27435. * @param updatable defines if the mesh must be flagged as updatable
  27436. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27437. * @returns a new Mesh
  27438. */
  27439. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27440. /**
  27441. * Creates a ground mesh.
  27442. * Please consider using the same method from the MeshBuilder class instead
  27443. * @param name defines the name of the mesh to create
  27444. * @param width set the width of the ground
  27445. * @param height set the height of the ground
  27446. * @param subdivisions sets the number of subdivisions per side
  27447. * @param scene defines the hosting scene
  27448. * @param updatable defines if the mesh must be flagged as updatable
  27449. * @returns a new Mesh
  27450. */
  27451. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  27452. /**
  27453. * Creates a tiled ground mesh.
  27454. * Please consider using the same method from the MeshBuilder class instead
  27455. * @param name defines the name of the mesh to create
  27456. * @param xmin set the ground minimum X coordinate
  27457. * @param zmin set the ground minimum Y coordinate
  27458. * @param xmax set the ground maximum X coordinate
  27459. * @param zmax set the ground maximum Z coordinate
  27460. * @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
  27461. * @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
  27462. * @param scene defines the hosting scene
  27463. * @param updatable defines if the mesh must be flagged as updatable
  27464. * @returns a new Mesh
  27465. */
  27466. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  27467. w: number;
  27468. h: number;
  27469. }, precision: {
  27470. w: number;
  27471. h: number;
  27472. }, scene: Scene, updatable?: boolean): Mesh;
  27473. /**
  27474. * Creates a ground mesh from a height map.
  27475. * Please consider using the same method from the MeshBuilder class instead
  27476. * @see http://doc.babylonjs.com/babylon101/height_map
  27477. * @param name defines the name of the mesh to create
  27478. * @param url sets the URL of the height map image resource
  27479. * @param width set the ground width size
  27480. * @param height set the ground height size
  27481. * @param subdivisions sets the number of subdivision per side
  27482. * @param minHeight is the minimum altitude on the ground
  27483. * @param maxHeight is the maximum altitude on the ground
  27484. * @param scene defines the hosting scene
  27485. * @param updatable defines if the mesh must be flagged as updatable
  27486. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  27487. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27488. * @returns a new Mesh
  27489. */
  27490. 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;
  27491. /**
  27492. * Creates a tube mesh.
  27493. * The tube is a parametric shape.
  27494. * It has no predefined shape. Its final shape will depend on the input parameters.
  27495. * Please consider using the same method from the MeshBuilder class instead
  27496. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27497. * @param name defines the name of the mesh to create
  27498. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  27499. * @param radius sets the tube radius size
  27500. * @param tessellation is the number of sides on the tubular surface
  27501. * @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
  27502. * @param cap sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  27503. * @param scene defines the hosting scene
  27504. * @param updatable defines if the mesh must be flagged as updatable
  27505. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27506. * @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)
  27507. * @returns a new Mesh
  27508. */
  27509. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  27510. (i: number, distance: number): number;
  27511. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27512. /**
  27513. * Creates a polyhedron mesh.
  27514. * Please consider using the same method from the MeshBuilder class instead.
  27515. * * 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
  27516. * * The parameter `size` (positive float, default 1) sets the polygon size
  27517. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27518. * * 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`
  27519. * * 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
  27520. * * 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)`)
  27521. * * 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
  27522. * * 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
  27523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27524. * * 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
  27525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27526. * @param name defines the name of the mesh to create
  27527. * @param options defines the options used to create the mesh
  27528. * @param scene defines the hosting scene
  27529. * @returns a new Mesh
  27530. */
  27531. static CreatePolyhedron(name: string, options: {
  27532. type?: number;
  27533. size?: number;
  27534. sizeX?: number;
  27535. sizeY?: number;
  27536. sizeZ?: number;
  27537. custom?: any;
  27538. faceUV?: Vector4[];
  27539. faceColors?: Color4[];
  27540. updatable?: boolean;
  27541. sideOrientation?: number;
  27542. }, scene: Scene): Mesh;
  27543. /**
  27544. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27545. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27546. * * 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`)
  27547. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27548. * * 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
  27549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27550. * * 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
  27551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27552. * @param name defines the name of the mesh
  27553. * @param options defines the options used to create the mesh
  27554. * @param scene defines the hosting scene
  27555. * @returns a new Mesh
  27556. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27557. */
  27558. static CreateIcoSphere(name: string, options: {
  27559. radius?: number;
  27560. flat?: boolean;
  27561. subdivisions?: number;
  27562. sideOrientation?: number;
  27563. updatable?: boolean;
  27564. }, scene: Scene): Mesh;
  27565. /**
  27566. * Creates a decal mesh.
  27567. * Please consider using the same method from the MeshBuilder class instead.
  27568. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27569. * @param name defines the name of the mesh
  27570. * @param sourceMesh defines the mesh receiving the decal
  27571. * @param position sets the position of the decal in world coordinates
  27572. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27573. * @param size sets the decal scaling
  27574. * @param angle sets the angle to rotate the decal
  27575. * @returns a new Mesh
  27576. */
  27577. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  27578. /**
  27579. * Prepare internal position array for software CPU skinning
  27580. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27581. */
  27582. setPositionsForCPUSkinning(): Float32Array;
  27583. /**
  27584. * Prepare internal normal array for software CPU skinning
  27585. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27586. */
  27587. setNormalsForCPUSkinning(): Float32Array;
  27588. /**
  27589. * Updates the vertex buffer by applying transformation from the bones
  27590. * @param skeleton defines the skeleton to apply to current mesh
  27591. * @returns the current mesh
  27592. */
  27593. applySkeleton(skeleton: Skeleton): Mesh;
  27594. /**
  27595. * 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
  27596. * @param meshes defines the list of meshes to scan
  27597. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27598. */
  27599. static MinMax(meshes: AbstractMesh[]): {
  27600. min: Vector3;
  27601. max: Vector3;
  27602. };
  27603. /**
  27604. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27605. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27606. * @returns a vector3
  27607. */
  27608. static Center(meshesOrMinMaxVector: {
  27609. min: Vector3;
  27610. max: Vector3;
  27611. } | AbstractMesh[]): Vector3;
  27612. /**
  27613. * Merge the array of meshes into a single mesh for performance reasons.
  27614. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27615. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27616. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27617. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27618. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27619. * @returns a new mesh
  27620. */
  27621. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27622. /** @hidden */
  27623. addInstance(instance: InstancedMesh): void;
  27624. /** @hidden */
  27625. removeInstance(instance: InstancedMesh): void;
  27626. }
  27627. }
  27628. declare module BABYLON {
  27629. /**
  27630. * Define an interface for all classes that will get and set the data on vertices
  27631. */
  27632. interface IGetSetVerticesData {
  27633. /**
  27634. * Gets a boolean indicating if specific vertex data is present
  27635. * @param kind defines the vertex data kind to use
  27636. * @returns true is data kind is present
  27637. */
  27638. isVerticesDataPresent(kind: string): boolean;
  27639. /**
  27640. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  27641. * @param kind defines the data kind (Position, normal, etc...)
  27642. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  27643. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27644. * @returns a float array containing vertex data
  27645. */
  27646. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27647. /**
  27648. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27649. * @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.
  27650. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27651. * @returns the indices array or an empty array if the mesh has no geometry
  27652. */
  27653. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27654. /**
  27655. * Set specific vertex data
  27656. * @param kind defines the data kind (Position, normal, etc...)
  27657. * @param data defines the vertex data to use
  27658. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27659. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27660. */
  27661. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27662. /**
  27663. * Update a specific associated vertex buffer
  27664. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27665. * - BABYLON.VertexBuffer.PositionKind
  27666. * - BABYLON.VertexBuffer.UVKind
  27667. * - BABYLON.VertexBuffer.UV2Kind
  27668. * - BABYLON.VertexBuffer.UV3Kind
  27669. * - BABYLON.VertexBuffer.UV4Kind
  27670. * - BABYLON.VertexBuffer.UV5Kind
  27671. * - BABYLON.VertexBuffer.UV6Kind
  27672. * - BABYLON.VertexBuffer.ColorKind
  27673. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27674. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27675. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27676. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27677. * @param data defines the data source
  27678. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27679. * @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)
  27680. */
  27681. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27682. /**
  27683. * Creates a new index buffer
  27684. * @param indices defines the indices to store in the index buffer
  27685. * @param totalVertices defines the total number of vertices (could be null)
  27686. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27687. */
  27688. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27689. }
  27690. /**
  27691. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27692. */
  27693. class VertexData {
  27694. /**
  27695. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27696. */
  27697. positions: Nullable<FloatArray>;
  27698. /**
  27699. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27700. */
  27701. normals: Nullable<FloatArray>;
  27702. /**
  27703. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27704. */
  27705. tangents: Nullable<FloatArray>;
  27706. /**
  27707. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27708. */
  27709. uvs: Nullable<FloatArray>;
  27710. /**
  27711. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27712. */
  27713. uvs2: Nullable<FloatArray>;
  27714. /**
  27715. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27716. */
  27717. uvs3: Nullable<FloatArray>;
  27718. /**
  27719. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27720. */
  27721. uvs4: Nullable<FloatArray>;
  27722. /**
  27723. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27724. */
  27725. uvs5: Nullable<FloatArray>;
  27726. /**
  27727. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27728. */
  27729. uvs6: Nullable<FloatArray>;
  27730. /**
  27731. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27732. */
  27733. colors: Nullable<FloatArray>;
  27734. /**
  27735. * 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).
  27736. */
  27737. matricesIndices: Nullable<FloatArray>;
  27738. /**
  27739. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27740. */
  27741. matricesWeights: Nullable<FloatArray>;
  27742. /**
  27743. * An array extending the number of possible indices
  27744. */
  27745. matricesIndicesExtra: Nullable<FloatArray>;
  27746. /**
  27747. * An array extending the number of possible weights when the number of indices is extended
  27748. */
  27749. matricesWeightsExtra: Nullable<FloatArray>;
  27750. /**
  27751. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27752. */
  27753. indices: Nullable<IndicesArray>;
  27754. /**
  27755. * Uses the passed data array to set the set the values for the specified kind of data
  27756. * @param data a linear array of floating numbers
  27757. * @param kind the type of data that is being set, eg positions, colors etc
  27758. */
  27759. set(data: FloatArray, kind: string): void;
  27760. /**
  27761. * Associates the vertexData to the passed Mesh.
  27762. * Sets it as updatable or not (default `false`)
  27763. * @param mesh the mesh the vertexData is applied to
  27764. * @param updatable when used and having the value true allows new data to update the vertexData
  27765. * @returns the VertexData
  27766. */
  27767. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27768. /**
  27769. * Associates the vertexData to the passed Geometry.
  27770. * Sets it as updatable or not (default `false`)
  27771. * @param geometry the geometry the vertexData is applied to
  27772. * @param updatable when used and having the value true allows new data to update the vertexData
  27773. * @returns VertexData
  27774. */
  27775. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27776. /**
  27777. * Updates the associated mesh
  27778. * @param mesh the mesh to be updated
  27779. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27780. * @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
  27781. * @returns VertexData
  27782. */
  27783. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27784. /**
  27785. * Updates the associated geometry
  27786. * @param geometry the geometry to be updated
  27787. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27788. * @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
  27789. * @returns VertexData.
  27790. */
  27791. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27792. private _applyTo;
  27793. private _update;
  27794. /**
  27795. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27796. * @param matrix the transforming matrix
  27797. * @returns the VertexData
  27798. */
  27799. transform(matrix: Matrix): VertexData;
  27800. /**
  27801. * Merges the passed VertexData into the current one
  27802. * @param other the VertexData to be merged into the current one
  27803. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27804. * @returns the modified VertexData
  27805. */
  27806. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27807. private _mergeElement;
  27808. private _validate;
  27809. /**
  27810. * Serializes the VertexData
  27811. * @returns a serialized object
  27812. */
  27813. serialize(): any;
  27814. /**
  27815. * Extracts the vertexData from a mesh
  27816. * @param mesh the mesh from which to extract the VertexData
  27817. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27818. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27819. * @returns the object VertexData associated to the passed mesh
  27820. */
  27821. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27822. /**
  27823. * Extracts the vertexData from the geometry
  27824. * @param geometry the geometry from which to extract the VertexData
  27825. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27826. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27827. * @returns the object VertexData associated to the passed mesh
  27828. */
  27829. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27830. private static _ExtractFrom;
  27831. /**
  27832. * Creates the VertexData for a Ribbon
  27833. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27834. * * pathArray array of paths, each of which an array of successive Vector3
  27835. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27836. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27837. * * 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
  27838. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27839. * * 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)
  27840. * * 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)
  27841. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27842. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27843. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27844. * @returns the VertexData of the ribbon
  27845. */
  27846. static CreateRibbon(options: {
  27847. pathArray: Vector3[][];
  27848. closeArray?: boolean;
  27849. closePath?: boolean;
  27850. offset?: number;
  27851. sideOrientation?: number;
  27852. frontUVs?: Vector4;
  27853. backUVs?: Vector4;
  27854. invertUV?: boolean;
  27855. uvs?: Vector2[];
  27856. colors?: Color4[];
  27857. }): VertexData;
  27858. /**
  27859. * Creates the VertexData for a box
  27860. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27861. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27862. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27863. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27864. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27865. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27866. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27867. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27868. * * 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)
  27869. * * 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)
  27870. * @returns the VertexData of the box
  27871. */
  27872. static CreateBox(options: {
  27873. size?: number;
  27874. width?: number;
  27875. height?: number;
  27876. depth?: number;
  27877. faceUV?: Vector4[];
  27878. faceColors?: Color4[];
  27879. sideOrientation?: number;
  27880. frontUVs?: Vector4;
  27881. backUVs?: Vector4;
  27882. }): VertexData;
  27883. /**
  27884. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27885. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27886. * * segments sets the number of horizontal strips optional, default 32
  27887. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27888. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27889. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27890. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27891. * * 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
  27892. * * 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
  27893. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27894. * * 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)
  27895. * * 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)
  27896. * @returns the VertexData of the ellipsoid
  27897. */
  27898. static CreateSphere(options: {
  27899. segments?: number;
  27900. diameter?: number;
  27901. diameterX?: number;
  27902. diameterY?: number;
  27903. diameterZ?: number;
  27904. arc?: number;
  27905. slice?: number;
  27906. sideOrientation?: number;
  27907. frontUVs?: Vector4;
  27908. backUVs?: Vector4;
  27909. }): VertexData;
  27910. /**
  27911. * Creates the VertexData for a cylinder, cone or prism
  27912. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27913. * * height sets the height (y direction) of the cylinder, optional, default 2
  27914. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27915. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27916. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27917. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27918. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27919. * * 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
  27920. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27921. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27922. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27923. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27924. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27925. * * 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)
  27926. * * 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)
  27927. * @returns the VertexData of the cylinder, cone or prism
  27928. */
  27929. static CreateCylinder(options: {
  27930. height?: number;
  27931. diameterTop?: number;
  27932. diameterBottom?: number;
  27933. diameter?: number;
  27934. tessellation?: number;
  27935. subdivisions?: number;
  27936. arc?: number;
  27937. faceColors?: Color4[];
  27938. faceUV?: Vector4[];
  27939. hasRings?: boolean;
  27940. enclose?: boolean;
  27941. sideOrientation?: number;
  27942. frontUVs?: Vector4;
  27943. backUVs?: Vector4;
  27944. }): VertexData;
  27945. /**
  27946. * Creates the VertexData for a torus
  27947. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27948. * * diameter the diameter of the torus, optional default 1
  27949. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27950. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27951. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27952. * * 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)
  27953. * * 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)
  27954. * @returns the VertexData of the torus
  27955. */
  27956. static CreateTorus(options: {
  27957. diameter?: number;
  27958. thickness?: number;
  27959. tessellation?: number;
  27960. sideOrientation?: number;
  27961. frontUVs?: Vector4;
  27962. backUVs?: Vector4;
  27963. }): VertexData;
  27964. /**
  27965. * Creates the VertexData of the LineSystem
  27966. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27967. * - lines an array of lines, each line being an array of successive Vector3
  27968. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27969. * @returns the VertexData of the LineSystem
  27970. */
  27971. static CreateLineSystem(options: {
  27972. lines: Vector3[][];
  27973. colors?: Nullable<Color4[][]>;
  27974. }): VertexData;
  27975. /**
  27976. * Create the VertexData for a DashedLines
  27977. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27978. * - points an array successive Vector3
  27979. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27980. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27981. * - dashNb the intended total number of dashes, optional, default 200
  27982. * @returns the VertexData for the DashedLines
  27983. */
  27984. static CreateDashedLines(options: {
  27985. points: Vector3[];
  27986. dashSize?: number;
  27987. gapSize?: number;
  27988. dashNb?: number;
  27989. }): VertexData;
  27990. /**
  27991. * Creates the VertexData for a Ground
  27992. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27993. * - width the width (x direction) of the ground, optional, default 1
  27994. * - height the height (z direction) of the ground, optional, default 1
  27995. * - subdivisions the number of subdivisions per side, optional, default 1
  27996. * @returns the VertexData of the Ground
  27997. */
  27998. static CreateGround(options: {
  27999. width?: number;
  28000. height?: number;
  28001. subdivisions?: number;
  28002. subdivisionsX?: number;
  28003. subdivisionsY?: number;
  28004. }): VertexData;
  28005. /**
  28006. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  28007. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  28008. * * xmin the ground minimum X coordinate, optional, default -1
  28009. * * zmin the ground minimum Z coordinate, optional, default -1
  28010. * * xmax the ground maximum X coordinate, optional, default 1
  28011. * * zmax the ground maximum Z coordinate, optional, default 1
  28012. * * 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}
  28013. * * 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}
  28014. * @returns the VertexData of the TiledGround
  28015. */
  28016. static CreateTiledGround(options: {
  28017. xmin: number;
  28018. zmin: number;
  28019. xmax: number;
  28020. zmax: number;
  28021. subdivisions?: {
  28022. w: number;
  28023. h: number;
  28024. };
  28025. precision?: {
  28026. w: number;
  28027. h: number;
  28028. };
  28029. }): VertexData;
  28030. /**
  28031. * Creates the VertexData of the Ground designed from a heightmap
  28032. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  28033. * * width the width (x direction) of the ground
  28034. * * height the height (z direction) of the ground
  28035. * * subdivisions the number of subdivisions per side
  28036. * * minHeight the minimum altitude on the ground, optional, default 0
  28037. * * maxHeight the maximum altitude on the ground, optional default 1
  28038. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  28039. * * buffer the array holding the image color data
  28040. * * bufferWidth the width of image
  28041. * * bufferHeight the height of image
  28042. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  28043. * @returns the VertexData of the Ground designed from a heightmap
  28044. */
  28045. static CreateGroundFromHeightMap(options: {
  28046. width: number;
  28047. height: number;
  28048. subdivisions: number;
  28049. minHeight: number;
  28050. maxHeight: number;
  28051. colorFilter: Color3;
  28052. buffer: Uint8Array;
  28053. bufferWidth: number;
  28054. bufferHeight: number;
  28055. alphaFilter: number;
  28056. }): VertexData;
  28057. /**
  28058. * Creates the VertexData for a Plane
  28059. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  28060. * * size sets the width and height of the plane to the value of size, optional default 1
  28061. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  28062. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  28063. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28064. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  28065. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  28066. * @returns the VertexData of the box
  28067. */
  28068. static CreatePlane(options: {
  28069. size?: number;
  28070. width?: number;
  28071. height?: number;
  28072. sideOrientation?: number;
  28073. frontUVs?: Vector4;
  28074. backUVs?: Vector4;
  28075. }): VertexData;
  28076. /**
  28077. * Creates the VertexData of the Disc or regular Polygon
  28078. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  28079. * * radius the radius of the disc, optional default 0.5
  28080. * * tessellation the number of polygon sides, optional, default 64
  28081. * * 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
  28082. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28083. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  28084. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  28085. * @returns the VertexData of the box
  28086. */
  28087. static CreateDisc(options: {
  28088. radius?: number;
  28089. tessellation?: number;
  28090. arc?: number;
  28091. sideOrientation?: number;
  28092. frontUVs?: Vector4;
  28093. backUVs?: Vector4;
  28094. }): VertexData;
  28095. /**
  28096. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  28097. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  28098. * @param polygon a mesh built from polygonTriangulation.build()
  28099. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28100. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28101. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28102. * @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)
  28103. * @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)
  28104. * @returns the VertexData of the Polygon
  28105. */
  28106. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  28107. /**
  28108. * Creates the VertexData of the IcoSphere
  28109. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  28110. * * radius the radius of the IcoSphere, optional default 1
  28111. * * radiusX allows stretching in the x direction, optional, default radius
  28112. * * radiusY allows stretching in the y direction, optional, default radius
  28113. * * radiusZ allows stretching in the z direction, optional, default radius
  28114. * * flat when true creates a flat shaded mesh, optional, default true
  28115. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28116. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28117. * * 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)
  28118. * * 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)
  28119. * @returns the VertexData of the IcoSphere
  28120. */
  28121. static CreateIcoSphere(options: {
  28122. radius?: number;
  28123. radiusX?: number;
  28124. radiusY?: number;
  28125. radiusZ?: number;
  28126. flat?: boolean;
  28127. subdivisions?: number;
  28128. sideOrientation?: number;
  28129. frontUVs?: Vector4;
  28130. backUVs?: Vector4;
  28131. }): VertexData;
  28132. /**
  28133. * Creates the VertexData for a Polyhedron
  28134. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  28135. * * type provided types are:
  28136. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  28137. * * 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)
  28138. * * size the size of the IcoSphere, optional default 1
  28139. * * sizeX allows stretching in the x direction, optional, default size
  28140. * * sizeY allows stretching in the y direction, optional, default size
  28141. * * sizeZ allows stretching in the z direction, optional, default size
  28142. * * 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
  28143. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28144. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28145. * * flat when true creates a flat shaded mesh, optional, default true
  28146. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28147. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28148. * * 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)
  28149. * * 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)
  28150. * @returns the VertexData of the Polyhedron
  28151. */
  28152. static CreatePolyhedron(options: {
  28153. type?: number;
  28154. size?: number;
  28155. sizeX?: number;
  28156. sizeY?: number;
  28157. sizeZ?: number;
  28158. custom?: any;
  28159. faceUV?: Vector4[];
  28160. faceColors?: Color4[];
  28161. flat?: boolean;
  28162. sideOrientation?: number;
  28163. frontUVs?: Vector4;
  28164. backUVs?: Vector4;
  28165. }): VertexData;
  28166. /**
  28167. * Creates the VertexData for a TorusKnot
  28168. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  28169. * * radius the radius of the torus knot, optional, default 2
  28170. * * tube the thickness of the tube, optional, default 0.5
  28171. * * radialSegments the number of sides on each tube segments, optional, default 32
  28172. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  28173. * * p the number of windings around the z axis, optional, default 2
  28174. * * q the number of windings around the x axis, optional, default 3
  28175. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28176. * * 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)
  28177. * * 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)
  28178. * @returns the VertexData of the Torus Knot
  28179. */
  28180. static CreateTorusKnot(options: {
  28181. radius?: number;
  28182. tube?: number;
  28183. radialSegments?: number;
  28184. tubularSegments?: number;
  28185. p?: number;
  28186. q?: number;
  28187. sideOrientation?: number;
  28188. frontUVs?: Vector4;
  28189. backUVs?: Vector4;
  28190. }): VertexData;
  28191. /**
  28192. * Compute normals for given positions and indices
  28193. * @param positions an array of vertex positions, [...., x, y, z, ......]
  28194. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  28195. * @param normals an array of vertex normals, [...., x, y, z, ......]
  28196. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  28197. * * facetNormals : optional array of facet normals (vector3)
  28198. * * facetPositions : optional array of facet positions (vector3)
  28199. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  28200. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  28201. * * bInfo : optional bounding info, required for facetPartitioning computation
  28202. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  28203. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  28204. * * useRightHandedSystem: optional boolean to for right handed system computation
  28205. * * depthSort : optional boolean to enable the facet depth sort computation
  28206. * * distanceTo : optional Vector3 to compute the facet depth from this location
  28207. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  28208. */
  28209. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  28210. facetNormals?: any;
  28211. facetPositions?: any;
  28212. facetPartitioning?: any;
  28213. ratio?: number;
  28214. bInfo?: any;
  28215. bbSize?: Vector3;
  28216. subDiv?: any;
  28217. useRightHandedSystem?: boolean;
  28218. depthSort?: boolean;
  28219. distanceTo?: Vector3;
  28220. depthSortedFacets?: any;
  28221. }): void;
  28222. private static _ComputeSides;
  28223. /**
  28224. * Applies VertexData created from the imported parameters to the geometry
  28225. * @param parsedVertexData the parsed data from an imported file
  28226. * @param geometry the geometry to apply the VertexData to
  28227. */
  28228. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  28229. }
  28230. }
  28231. declare module BABYLON {
  28232. /**
  28233. * Class containing static functions to help procedurally build meshes
  28234. */
  28235. class MeshBuilder {
  28236. private static updateSideOrientation;
  28237. /**
  28238. * Creates a box mesh
  28239. * * The parameter `size` sets the size (float) of each box side (default 1)
  28240. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  28241. * * 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)
  28242. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  28243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28244. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28246. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  28247. * @param name defines the name of the mesh
  28248. * @param options defines the options used to create the mesh
  28249. * @param scene defines the hosting scene
  28250. * @returns the box mesh
  28251. */
  28252. static CreateBox(name: string, options: {
  28253. size?: number;
  28254. width?: number;
  28255. height?: number;
  28256. depth?: number;
  28257. faceUV?: Vector4[];
  28258. faceColors?: Color4[];
  28259. sideOrientation?: number;
  28260. frontUVs?: Vector4;
  28261. backUVs?: Vector4;
  28262. updatable?: boolean;
  28263. }, scene?: Nullable<Scene>): Mesh;
  28264. /**
  28265. * Creates a sphere mesh
  28266. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  28267. * * 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`)
  28268. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  28269. * * 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
  28270. * * 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)
  28271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28272. * * 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
  28273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28274. * @param name defines the name of the mesh
  28275. * @param options defines the options used to create the mesh
  28276. * @param scene defines the hosting scene
  28277. * @returns the sphere mesh
  28278. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  28279. */
  28280. static CreateSphere(name: string, options: {
  28281. segments?: number;
  28282. diameter?: number;
  28283. diameterX?: number;
  28284. diameterY?: number;
  28285. diameterZ?: number;
  28286. arc?: number;
  28287. slice?: number;
  28288. sideOrientation?: number;
  28289. frontUVs?: Vector4;
  28290. backUVs?: Vector4;
  28291. updatable?: boolean;
  28292. }, scene: any): Mesh;
  28293. /**
  28294. * Creates a plane polygonal mesh. By default, this is a disc
  28295. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28296. * * 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
  28297. * * 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
  28298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28299. * * 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
  28300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28301. * @param name defines the name of the mesh
  28302. * @param options defines the options used to create the mesh
  28303. * @param scene defines the hosting scene
  28304. * @returns the plane polygonal mesh
  28305. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28306. */
  28307. static CreateDisc(name: string, options: {
  28308. radius?: number;
  28309. tessellation?: number;
  28310. arc?: number;
  28311. updatable?: boolean;
  28312. sideOrientation?: number;
  28313. frontUVs?: Vector4;
  28314. backUVs?: Vector4;
  28315. }, scene?: Nullable<Scene>): Mesh;
  28316. /**
  28317. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28318. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28319. * * 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`)
  28320. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28321. * * 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
  28322. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28323. * * 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
  28324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28325. * @param name defines the name of the mesh
  28326. * @param options defines the options used to create the mesh
  28327. * @param scene defines the hosting scene
  28328. * @returns the icosahedron mesh
  28329. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28330. */
  28331. static CreateIcoSphere(name: string, options: {
  28332. radius?: number;
  28333. radiusX?: number;
  28334. radiusY?: number;
  28335. radiusZ?: number;
  28336. flat?: boolean;
  28337. subdivisions?: number;
  28338. sideOrientation?: number;
  28339. frontUVs?: Vector4;
  28340. backUVs?: Vector4;
  28341. updatable?: boolean;
  28342. }, scene: Scene): Mesh;
  28343. /**
  28344. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28345. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  28346. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  28347. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  28348. * * 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
  28349. * * 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
  28350. * * 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
  28351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28352. * * 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
  28353. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28354. * * 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
  28355. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  28356. * * 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
  28357. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  28358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28359. * @param name defines the name of the mesh
  28360. * @param options defines the options used to create the mesh
  28361. * @param scene defines the hosting scene
  28362. * @returns the ribbon mesh
  28363. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  28364. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28365. */
  28366. static CreateRibbon(name: string, options: {
  28367. pathArray: Vector3[][];
  28368. closeArray?: boolean;
  28369. closePath?: boolean;
  28370. offset?: number;
  28371. updatable?: boolean;
  28372. sideOrientation?: number;
  28373. frontUVs?: Vector4;
  28374. backUVs?: Vector4;
  28375. instance?: Mesh;
  28376. invertUV?: boolean;
  28377. uvs?: Vector2[];
  28378. colors?: Color4[];
  28379. }, scene?: Nullable<Scene>): Mesh;
  28380. /**
  28381. * Creates a cylinder or a cone mesh
  28382. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  28383. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  28384. * * 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.
  28385. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  28386. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  28387. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  28388. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  28389. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  28390. * * 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).
  28391. * * 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
  28392. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  28393. * * 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
  28394. * * 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.
  28395. * * If `enclose` is false, a ring surface is one element.
  28396. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  28397. * * 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
  28398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28399. * * 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
  28400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28401. * @param name defines the name of the mesh
  28402. * @param options defines the options used to create the mesh
  28403. * @param scene defines the hosting scene
  28404. * @returns the cylinder mesh
  28405. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  28406. */
  28407. static CreateCylinder(name: string, options: {
  28408. height?: number;
  28409. diameterTop?: number;
  28410. diameterBottom?: number;
  28411. diameter?: number;
  28412. tessellation?: number;
  28413. subdivisions?: number;
  28414. arc?: number;
  28415. faceColors?: Color4[];
  28416. faceUV?: Vector4[];
  28417. updatable?: boolean;
  28418. hasRings?: boolean;
  28419. enclose?: boolean;
  28420. sideOrientation?: number;
  28421. frontUVs?: Vector4;
  28422. backUVs?: Vector4;
  28423. }, scene: any): Mesh;
  28424. /**
  28425. * Creates a torus mesh
  28426. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  28427. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  28428. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  28429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28430. * * 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
  28431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28432. * @param name defines the name of the mesh
  28433. * @param options defines the options used to create the mesh
  28434. * @param scene defines the hosting scene
  28435. * @returns the torus mesh
  28436. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  28437. */
  28438. static CreateTorus(name: string, options: {
  28439. diameter?: number;
  28440. thickness?: number;
  28441. tessellation?: number;
  28442. updatable?: boolean;
  28443. sideOrientation?: number;
  28444. frontUVs?: Vector4;
  28445. backUVs?: Vector4;
  28446. }, scene: any): Mesh;
  28447. /**
  28448. * Creates a torus knot mesh
  28449. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  28450. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  28451. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  28452. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  28453. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28454. * * 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
  28455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28456. * @param name defines the name of the mesh
  28457. * @param options defines the options used to create the mesh
  28458. * @param scene defines the hosting scene
  28459. * @returns the torus knot mesh
  28460. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  28461. */
  28462. static CreateTorusKnot(name: string, options: {
  28463. radius?: number;
  28464. tube?: number;
  28465. radialSegments?: number;
  28466. tubularSegments?: number;
  28467. p?: number;
  28468. q?: number;
  28469. updatable?: boolean;
  28470. sideOrientation?: number;
  28471. frontUVs?: Vector4;
  28472. backUVs?: Vector4;
  28473. }, scene: any): Mesh;
  28474. /**
  28475. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  28476. * * 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
  28477. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  28478. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  28479. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  28480. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  28481. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  28482. * * 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
  28483. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  28484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28485. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  28486. * @param name defines the name of the new line system
  28487. * @param options defines the options used to create the line system
  28488. * @param scene defines the hosting scene
  28489. * @returns a new line system mesh
  28490. */
  28491. static CreateLineSystem(name: string, options: {
  28492. lines: Vector3[][];
  28493. updatable?: boolean;
  28494. instance?: Nullable<LinesMesh>;
  28495. colors?: Nullable<Color4[][]>;
  28496. useVertexAlpha?: boolean;
  28497. }, scene: Nullable<Scene>): LinesMesh;
  28498. /**
  28499. * Creates a line mesh
  28500. * 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
  28501. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28502. * * The parameter `points` is an array successive Vector3
  28503. * * 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
  28504. * * The optional parameter `colors` is an array of successive Color4, one per line point
  28505. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  28506. * * When updating an instance, remember that only point positions can change, not the number of points
  28507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28508. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  28509. * @param name defines the name of the new line system
  28510. * @param options defines the options used to create the line system
  28511. * @param scene defines the hosting scene
  28512. * @returns a new line mesh
  28513. */
  28514. static CreateLines(name: string, options: {
  28515. points: Vector3[];
  28516. updatable?: boolean;
  28517. instance?: Nullable<LinesMesh>;
  28518. colors?: Color4[];
  28519. useVertexAlpha?: boolean;
  28520. }, scene?: Nullable<Scene>): LinesMesh;
  28521. /**
  28522. * Creates a dashed line mesh
  28523. * * 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
  28524. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28525. * * The parameter `points` is an array successive Vector3
  28526. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  28527. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  28528. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28529. * * 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
  28530. * * When updating an instance, remember that only point positions can change, not the number of points
  28531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28532. * @param name defines the name of the mesh
  28533. * @param options defines the options used to create the mesh
  28534. * @param scene defines the hosting scene
  28535. * @returns the dashed line mesh
  28536. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  28537. */
  28538. static CreateDashedLines(name: string, options: {
  28539. points: Vector3[];
  28540. dashSize?: number;
  28541. gapSize?: number;
  28542. dashNb?: number;
  28543. updatable?: boolean;
  28544. instance?: LinesMesh;
  28545. }, scene?: Nullable<Scene>): LinesMesh;
  28546. /**
  28547. * 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.
  28548. * * 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.
  28549. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28550. * * 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.
  28551. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  28552. * * 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
  28553. * * 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
  28554. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  28555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28556. * * 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
  28557. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  28558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28559. * @param name defines the name of the mesh
  28560. * @param options defines the options used to create the mesh
  28561. * @param scene defines the hosting scene
  28562. * @returns the extruded shape mesh
  28563. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28564. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28565. */
  28566. static ExtrudeShape(name: string, options: {
  28567. shape: Vector3[];
  28568. path: Vector3[];
  28569. scale?: number;
  28570. rotation?: number;
  28571. cap?: number;
  28572. updatable?: boolean;
  28573. sideOrientation?: number;
  28574. frontUVs?: Vector4;
  28575. backUVs?: Vector4;
  28576. instance?: Mesh;
  28577. invertUV?: boolean;
  28578. }, scene?: Nullable<Scene>): Mesh;
  28579. /**
  28580. * Creates an custom extruded shape mesh.
  28581. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  28582. * * 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.
  28583. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28584. * * 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
  28585. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  28586. * * 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
  28587. * * It must returns a float value that will be the scale value applied to the shape on each path point
  28588. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28589. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  28590. * * 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
  28591. * * 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
  28592. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  28593. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28594. * * 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
  28595. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28597. * @param name defines the name of the mesh
  28598. * @param options defines the options used to create the mesh
  28599. * @param scene defines the hosting scene
  28600. * @returns the custom extruded shape mesh
  28601. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  28602. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28603. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28604. */
  28605. static ExtrudeShapeCustom(name: string, options: {
  28606. shape: Vector3[];
  28607. path: Vector3[];
  28608. scaleFunction?: any;
  28609. rotationFunction?: any;
  28610. ribbonCloseArray?: boolean;
  28611. ribbonClosePath?: boolean;
  28612. cap?: number;
  28613. updatable?: boolean;
  28614. sideOrientation?: number;
  28615. frontUVs?: Vector4;
  28616. backUVs?: Vector4;
  28617. instance?: Mesh;
  28618. invertUV?: boolean;
  28619. }, scene: Scene): Mesh;
  28620. /**
  28621. * Creates lathe mesh.
  28622. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  28623. * * 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
  28624. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  28625. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  28626. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  28627. * * 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
  28628. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  28629. * * 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
  28630. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28631. * * 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
  28632. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28634. * @param name defines the name of the mesh
  28635. * @param options defines the options used to create the mesh
  28636. * @param scene defines the hosting scene
  28637. * @returns the lathe mesh
  28638. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  28639. */
  28640. static CreateLathe(name: string, options: {
  28641. shape: Vector3[];
  28642. radius?: number;
  28643. tessellation?: number;
  28644. clip?: number;
  28645. arc?: number;
  28646. closed?: boolean;
  28647. updatable?: boolean;
  28648. sideOrientation?: number;
  28649. frontUVs?: Vector4;
  28650. backUVs?: Vector4;
  28651. cap?: number;
  28652. invertUV?: boolean;
  28653. }, scene: Scene): Mesh;
  28654. /**
  28655. * Creates a plane mesh
  28656. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  28657. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  28658. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  28659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28660. * * 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
  28661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28662. * @param name defines the name of the mesh
  28663. * @param options defines the options used to create the mesh
  28664. * @param scene defines the hosting scene
  28665. * @returns the plane mesh
  28666. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  28667. */
  28668. static CreatePlane(name: string, options: {
  28669. size?: number;
  28670. width?: number;
  28671. height?: number;
  28672. sideOrientation?: number;
  28673. frontUVs?: Vector4;
  28674. backUVs?: Vector4;
  28675. updatable?: boolean;
  28676. sourcePlane?: Plane;
  28677. }, scene: Scene): Mesh;
  28678. /**
  28679. * Creates a ground mesh
  28680. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  28681. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  28682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28683. * @param name defines the name of the mesh
  28684. * @param options defines the options used to create the mesh
  28685. * @param scene defines the hosting scene
  28686. * @returns the ground mesh
  28687. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  28688. */
  28689. static CreateGround(name: string, options: {
  28690. width?: number;
  28691. height?: number;
  28692. subdivisions?: number;
  28693. subdivisionsX?: number;
  28694. subdivisionsY?: number;
  28695. updatable?: boolean;
  28696. }, scene: any): Mesh;
  28697. /**
  28698. * Creates a tiled ground mesh
  28699. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  28700. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  28701. * * 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
  28702. * * 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
  28703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28704. * @param name defines the name of the mesh
  28705. * @param options defines the options used to create the mesh
  28706. * @param scene defines the hosting scene
  28707. * @returns the tiled ground mesh
  28708. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  28709. */
  28710. static CreateTiledGround(name: string, options: {
  28711. xmin: number;
  28712. zmin: number;
  28713. xmax: number;
  28714. zmax: number;
  28715. subdivisions?: {
  28716. w: number;
  28717. h: number;
  28718. };
  28719. precision?: {
  28720. w: number;
  28721. h: number;
  28722. };
  28723. updatable?: boolean;
  28724. }, scene: Scene): Mesh;
  28725. /**
  28726. * Creates a ground mesh from a height map
  28727. * * The parameter `url` sets the URL of the height map image resource.
  28728. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  28729. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  28730. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  28731. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  28732. * * 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.
  28733. * * 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).
  28734. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28736. * @param name defines the name of the mesh
  28737. * @param url defines the url to the height map
  28738. * @param options defines the options used to create the mesh
  28739. * @param scene defines the hosting scene
  28740. * @returns the ground mesh
  28741. * @see https://doc.babylonjs.com/babylon101/height_map
  28742. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  28743. */
  28744. static CreateGroundFromHeightMap(name: string, url: string, options: {
  28745. width?: number;
  28746. height?: number;
  28747. subdivisions?: number;
  28748. minHeight?: number;
  28749. maxHeight?: number;
  28750. colorFilter?: Color3;
  28751. alphaFilter?: number;
  28752. updatable?: boolean;
  28753. onReady?: (mesh: GroundMesh) => void;
  28754. }, scene: Scene): GroundMesh;
  28755. /**
  28756. * Creates a polygon mesh
  28757. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  28758. * * 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
  28759. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28761. * * 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)
  28762. * * Remember you can only change the shape positions, not their number when updating a polygon
  28763. * @param name defines the name of the mesh
  28764. * @param options defines the options used to create the mesh
  28765. * @param scene defines the hosting scene
  28766. * @returns the polygon mesh
  28767. */
  28768. static CreatePolygon(name: string, options: {
  28769. shape: Vector3[];
  28770. holes?: Vector3[][];
  28771. depth?: number;
  28772. faceUV?: Vector4[];
  28773. faceColors?: Color4[];
  28774. updatable?: boolean;
  28775. sideOrientation?: number;
  28776. frontUVs?: Vector4;
  28777. backUVs?: Vector4;
  28778. }, scene: Scene): Mesh;
  28779. /**
  28780. * Creates an extruded polygon mesh, with depth in the Y direction.
  28781. * * 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)
  28782. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  28783. * @param name defines the name of the mesh
  28784. * @param options defines the options used to create the mesh
  28785. * @param scene defines the hosting scene
  28786. * @returns the polygon mesh
  28787. */
  28788. static ExtrudePolygon(name: string, options: {
  28789. shape: Vector3[];
  28790. holes?: Vector3[][];
  28791. depth?: number;
  28792. faceUV?: Vector4[];
  28793. faceColors?: Color4[];
  28794. updatable?: boolean;
  28795. sideOrientation?: number;
  28796. frontUVs?: Vector4;
  28797. backUVs?: Vector4;
  28798. }, scene: Scene): Mesh;
  28799. /**
  28800. * Creates a tube mesh.
  28801. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28802. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  28803. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  28804. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  28805. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  28806. * * 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)
  28807. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  28808. * * 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
  28809. * * 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
  28810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28811. * * 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
  28812. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28814. * @param name defines the name of the mesh
  28815. * @param options defines the options used to create the mesh
  28816. * @param scene defines the hosting scene
  28817. * @returns the tube mesh
  28818. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28819. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  28820. */
  28821. static CreateTube(name: string, options: {
  28822. path: Vector3[];
  28823. radius?: number;
  28824. tessellation?: number;
  28825. radiusFunction?: {
  28826. (i: number, distance: number): number;
  28827. };
  28828. cap?: number;
  28829. arc?: number;
  28830. updatable?: boolean;
  28831. sideOrientation?: number;
  28832. frontUVs?: Vector4;
  28833. backUVs?: Vector4;
  28834. instance?: Mesh;
  28835. invertUV?: boolean;
  28836. }, scene: Scene): Mesh;
  28837. /**
  28838. * Creates a polyhedron mesh
  28839. * * 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
  28840. * * The parameter `size` (positive float, default 1) sets the polygon size
  28841. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28842. * * 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`
  28843. * * 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
  28844. * * 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)`)
  28845. * * 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
  28846. * * 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
  28847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28848. * * 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
  28849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28850. * @param name defines the name of the mesh
  28851. * @param options defines the options used to create the mesh
  28852. * @param scene defines the hosting scene
  28853. * @returns the polyhedron mesh
  28854. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  28855. */
  28856. static CreatePolyhedron(name: string, options: {
  28857. type?: number;
  28858. size?: number;
  28859. sizeX?: number;
  28860. sizeY?: number;
  28861. sizeZ?: number;
  28862. custom?: any;
  28863. faceUV?: Vector4[];
  28864. faceColors?: Color4[];
  28865. flat?: boolean;
  28866. updatable?: boolean;
  28867. sideOrientation?: number;
  28868. frontUVs?: Vector4;
  28869. backUVs?: Vector4;
  28870. }, scene: Scene): Mesh;
  28871. /**
  28872. * Creates a decal mesh.
  28873. * 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
  28874. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  28875. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  28876. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  28877. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  28878. * @param name defines the name of the mesh
  28879. * @param sourceMesh defines the mesh where the decal must be applied
  28880. * @param options defines the options used to create the mesh
  28881. * @param scene defines the hosting scene
  28882. * @returns the decal mesh
  28883. * @see https://doc.babylonjs.com/how_to/decals
  28884. */
  28885. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  28886. position?: Vector3;
  28887. normal?: Vector3;
  28888. size?: Vector3;
  28889. angle?: number;
  28890. }): Mesh;
  28891. private static _ExtrudeShapeGeneric;
  28892. }
  28893. }
  28894. declare module BABYLON {
  28895. /**
  28896. * Class used to represent a specific level of detail of a mesh
  28897. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28898. */
  28899. class MeshLODLevel {
  28900. /** Defines the distance where this level should star being displayed */
  28901. distance: number;
  28902. /** Defines the mesh to use to render this level */
  28903. mesh: Nullable<Mesh>;
  28904. /**
  28905. * Creates a new LOD level
  28906. * @param distance defines the distance where this level should star being displayed
  28907. * @param mesh defines the mesh to use to render this level
  28908. */
  28909. constructor(
  28910. /** Defines the distance where this level should star being displayed */
  28911. distance: number,
  28912. /** Defines the mesh to use to render this level */
  28913. mesh: Nullable<Mesh>);
  28914. }
  28915. }
  28916. declare module BABYLON {
  28917. /**
  28918. * A simplifier interface for future simplification implementations
  28919. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28920. */
  28921. interface ISimplifier {
  28922. /**
  28923. * Simplification of a given mesh according to the given settings.
  28924. * Since this requires computation, it is assumed that the function runs async.
  28925. * @param settings The settings of the simplification, including quality and distance
  28926. * @param successCallback A callback that will be called after the mesh was simplified.
  28927. * @param errorCallback in case of an error, this callback will be called. optional.
  28928. */
  28929. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  28930. }
  28931. /**
  28932. * Expected simplification settings.
  28933. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  28934. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28935. */
  28936. interface ISimplificationSettings {
  28937. /**
  28938. * Gets or sets the expected quality
  28939. */
  28940. quality: number;
  28941. /**
  28942. * Gets or sets the distance when this optimized version should be used
  28943. */
  28944. distance: number;
  28945. /**
  28946. * Gets an already optimized mesh
  28947. */
  28948. optimizeMesh?: boolean;
  28949. }
  28950. /**
  28951. * Class used to specify simplification options
  28952. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28953. */
  28954. class SimplificationSettings implements ISimplificationSettings {
  28955. /** expected quality */
  28956. quality: number;
  28957. /** distance when this optimized version should be used */
  28958. distance: number;
  28959. /** already optimized mesh */
  28960. optimizeMesh?: boolean | undefined;
  28961. /**
  28962. * Creates a SimplificationSettings
  28963. * @param quality expected quality
  28964. * @param distance distance when this optimized version should be used
  28965. * @param optimizeMesh already optimized mesh
  28966. */
  28967. constructor(
  28968. /** expected quality */
  28969. quality: number,
  28970. /** distance when this optimized version should be used */
  28971. distance: number,
  28972. /** already optimized mesh */
  28973. optimizeMesh?: boolean | undefined);
  28974. }
  28975. /**
  28976. * Interface used to define a simplification task
  28977. */
  28978. interface ISimplificationTask {
  28979. /**
  28980. * Array of settings
  28981. */
  28982. settings: Array<ISimplificationSettings>;
  28983. /**
  28984. * Simplification type
  28985. */
  28986. simplificationType: SimplificationType;
  28987. /**
  28988. * Mesh to simplify
  28989. */
  28990. mesh: Mesh;
  28991. /**
  28992. * Callback called on success
  28993. */
  28994. successCallback?: () => void;
  28995. /**
  28996. * Defines if parallel processing can be used
  28997. */
  28998. parallelProcessing: boolean;
  28999. }
  29000. /**
  29001. * Queue used to order the simplification tasks
  29002. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29003. */
  29004. class SimplificationQueue {
  29005. private _simplificationArray;
  29006. /**
  29007. * Gets a boolean indicating that the process is still running
  29008. */
  29009. running: boolean;
  29010. /**
  29011. * Creates a new queue
  29012. */
  29013. constructor();
  29014. /**
  29015. * Adds a new simplification task
  29016. * @param task defines a task to add
  29017. */
  29018. addTask(task: ISimplificationTask): void;
  29019. /**
  29020. * Execute next task
  29021. */
  29022. executeNext(): void;
  29023. /**
  29024. * Execute a simplification task
  29025. * @param task defines the task to run
  29026. */
  29027. runSimplification(task: ISimplificationTask): void;
  29028. private getSimplifier;
  29029. }
  29030. /**
  29031. * The implemented types of simplification
  29032. * At the moment only Quadratic Error Decimation is implemented
  29033. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29034. */
  29035. enum SimplificationType {
  29036. /** Quadratic error decimation */
  29037. QUADRATIC = 0
  29038. }
  29039. }
  29040. declare module BABYLON {
  29041. interface Scene {
  29042. /** @hidden (Backing field) */
  29043. _simplificationQueue: SimplificationQueue;
  29044. /**
  29045. * Gets or sets the simplification queue attached to the scene
  29046. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29047. */
  29048. simplificationQueue: SimplificationQueue;
  29049. }
  29050. interface Mesh {
  29051. /**
  29052. * Simplify the mesh according to the given array of settings.
  29053. * Function will return immediately and will simplify async
  29054. * @param settings a collection of simplification settings
  29055. * @param parallelProcessing should all levels calculate parallel or one after the other
  29056. * @param simplificationType the type of simplification to run
  29057. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  29058. * @returns the current mesh
  29059. */
  29060. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  29061. }
  29062. /**
  29063. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  29064. * created in a scene
  29065. */
  29066. class SimplicationQueueSceneComponent implements ISceneComponent {
  29067. /**
  29068. * The component name helpfull to identify the component in the list of scene components.
  29069. */
  29070. readonly name: string;
  29071. /**
  29072. * The scene the component belongs to.
  29073. */
  29074. scene: Scene;
  29075. /**
  29076. * Creates a new instance of the component for the given scene
  29077. * @param scene Defines the scene to register the component in
  29078. */
  29079. constructor(scene: Scene);
  29080. /**
  29081. * Registers the component in a given scene
  29082. */
  29083. register(): void;
  29084. /**
  29085. * Rebuilds the elements related to this component in case of
  29086. * context lost for instance.
  29087. */
  29088. rebuild(): void;
  29089. /**
  29090. * Disposes the component and the associated ressources
  29091. */
  29092. dispose(): void;
  29093. private _beforeCameraUpdate;
  29094. }
  29095. }
  29096. declare module BABYLON {
  29097. /**
  29098. * Polygon
  29099. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29100. */
  29101. class Polygon {
  29102. /**
  29103. * Creates a rectangle
  29104. * @param xmin bottom X coord
  29105. * @param ymin bottom Y coord
  29106. * @param xmax top X coord
  29107. * @param ymax top Y coord
  29108. * @returns points that make the resulting rectation
  29109. */
  29110. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  29111. /**
  29112. * Creates a circle
  29113. * @param radius radius of circle
  29114. * @param cx scale in x
  29115. * @param cy scale in y
  29116. * @param numberOfSides number of sides that make up the circle
  29117. * @returns points that make the resulting circle
  29118. */
  29119. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  29120. /**
  29121. * Creates a polygon from input string
  29122. * @param input Input polygon data
  29123. * @returns the parsed points
  29124. */
  29125. static Parse(input: string): Vector2[];
  29126. /**
  29127. * Starts building a polygon from x and y coordinates
  29128. * @param x x coordinate
  29129. * @param y y coordinate
  29130. * @returns the started path2
  29131. */
  29132. static StartingAt(x: number, y: number): Path2;
  29133. }
  29134. /**
  29135. * Builds a polygon
  29136. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  29137. */
  29138. class PolygonMeshBuilder {
  29139. private _points;
  29140. private _outlinepoints;
  29141. private _holes;
  29142. private _name;
  29143. private _scene;
  29144. private _epoints;
  29145. private _eholes;
  29146. private _addToepoint;
  29147. /**
  29148. * Creates a PolygonMeshBuilder
  29149. * @param name name of the builder
  29150. * @param contours Path of the polygon
  29151. * @param scene scene to add to
  29152. */
  29153. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  29154. /**
  29155. * Adds a whole within the polygon
  29156. * @param hole Array of points defining the hole
  29157. * @returns this
  29158. */
  29159. addHole(hole: Vector2[]): PolygonMeshBuilder;
  29160. /**
  29161. * Creates the polygon
  29162. * @param updatable If the mesh should be updatable
  29163. * @param depth The depth of the mesh created
  29164. * @returns the created mesh
  29165. */
  29166. build(updatable?: boolean, depth?: number): Mesh;
  29167. /**
  29168. * Adds a side to the polygon
  29169. * @param positions points that make the polygon
  29170. * @param normals normals of the polygon
  29171. * @param uvs uvs of the polygon
  29172. * @param indices indices of the polygon
  29173. * @param bounds bounds of the polygon
  29174. * @param points points of the polygon
  29175. * @param depth depth of the polygon
  29176. * @param flip flip of the polygon
  29177. */
  29178. private addSide;
  29179. }
  29180. }
  29181. declare module BABYLON {
  29182. /**
  29183. * Base class for submeshes
  29184. */
  29185. class BaseSubMesh {
  29186. /** @hidden */
  29187. _materialDefines: Nullable<MaterialDefines>;
  29188. /** @hidden */
  29189. _materialEffect: Nullable<Effect>;
  29190. /**
  29191. * Gets associated effect
  29192. */
  29193. readonly effect: Nullable<Effect>;
  29194. /**
  29195. * Sets associated effect (effect used to render this submesh)
  29196. * @param effect defines the effect to associate with
  29197. * @param defines defines the set of defines used to compile this effect
  29198. */
  29199. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29200. }
  29201. /**
  29202. * Defines a subdivision inside a mesh
  29203. */
  29204. class SubMesh extends BaseSubMesh implements ICullable {
  29205. /** the material index to use */
  29206. materialIndex: number;
  29207. /** vertex index start */
  29208. verticesStart: number;
  29209. /** vertices count */
  29210. verticesCount: number;
  29211. /** index start */
  29212. indexStart: number;
  29213. /** indices count */
  29214. indexCount: number;
  29215. /** @hidden */
  29216. _linesIndexCount: number;
  29217. private _mesh;
  29218. private _renderingMesh;
  29219. private _boundingInfo;
  29220. private _linesIndexBuffer;
  29221. /** @hidden */
  29222. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29223. /** @hidden */
  29224. _trianglePlanes: Plane[];
  29225. /** @hidden */
  29226. _lastColliderTransformMatrix: Matrix;
  29227. /** @hidden */
  29228. _renderId: number;
  29229. /** @hidden */
  29230. _alphaIndex: number;
  29231. /** @hidden */
  29232. _distanceToCamera: number;
  29233. /** @hidden */
  29234. _id: number;
  29235. private _currentMaterial;
  29236. /**
  29237. * Add a new submesh to a mesh
  29238. * @param materialIndex defines the material index to use
  29239. * @param verticesStart defines vertex index start
  29240. * @param verticesCount defines vertices count
  29241. * @param indexStart defines index start
  29242. * @param indexCount defines indices count
  29243. * @param mesh defines the parent mesh
  29244. * @param renderingMesh defines an optional rendering mesh
  29245. * @param createBoundingBox defines if bounding box should be created for this submesh
  29246. * @returns the new submesh
  29247. */
  29248. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29249. /**
  29250. * Creates a new submesh
  29251. * @param materialIndex defines the material index to use
  29252. * @param verticesStart defines vertex index start
  29253. * @param verticesCount defines vertices count
  29254. * @param indexStart defines index start
  29255. * @param indexCount defines indices count
  29256. * @param mesh defines the parent mesh
  29257. * @param renderingMesh defines an optional rendering mesh
  29258. * @param createBoundingBox defines if bounding box should be created for this submesh
  29259. */
  29260. constructor(
  29261. /** the material index to use */
  29262. materialIndex: number,
  29263. /** vertex index start */
  29264. verticesStart: number,
  29265. /** vertices count */
  29266. verticesCount: number,
  29267. /** index start */
  29268. indexStart: number,
  29269. /** indices count */
  29270. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  29271. /**
  29272. * Returns true if this submesh covers the entire parent mesh
  29273. * @ignorenaming
  29274. */
  29275. readonly IsGlobal: boolean;
  29276. /**
  29277. * Returns the submesh BoudingInfo object
  29278. * @returns current bounding info (or mesh's one if the submesh is global)
  29279. */
  29280. getBoundingInfo(): BoundingInfo;
  29281. /**
  29282. * Sets the submesh BoundingInfo
  29283. * @param boundingInfo defines the new bounding info to use
  29284. * @returns the SubMesh
  29285. */
  29286. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29287. /**
  29288. * Returns the mesh of the current submesh
  29289. * @return the parent mesh
  29290. */
  29291. getMesh(): AbstractMesh;
  29292. /**
  29293. * Returns the rendering mesh of the submesh
  29294. * @returns the rendering mesh (could be different from parent mesh)
  29295. */
  29296. getRenderingMesh(): Mesh;
  29297. /**
  29298. * Returns the submesh material
  29299. * @returns null or the current material
  29300. */
  29301. getMaterial(): Nullable<Material>;
  29302. /**
  29303. * Sets a new updated BoundingInfo object to the submesh
  29304. * @returns the SubMesh
  29305. */
  29306. refreshBoundingInfo(): SubMesh;
  29307. /** @hidden */
  29308. _checkCollision(collider: Collider): boolean;
  29309. /**
  29310. * Updates the submesh BoundingInfo
  29311. * @param world defines the world matrix to use to update the bounding info
  29312. * @returns the submesh
  29313. */
  29314. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  29315. /**
  29316. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29317. * @param frustumPlanes defines the frustum planes
  29318. * @returns true if the submesh is intersecting with the frustum
  29319. */
  29320. isInFrustum(frustumPlanes: Plane[]): boolean;
  29321. /**
  29322. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29323. * @param frustumPlanes defines the frustum planes
  29324. * @returns true if the submesh is inside the frustum
  29325. */
  29326. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29327. /**
  29328. * Renders the submesh
  29329. * @param enableAlphaMode defines if alpha needs to be used
  29330. * @returns the submesh
  29331. */
  29332. render(enableAlphaMode: boolean): SubMesh;
  29333. /**
  29334. * @hidden
  29335. */
  29336. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  29337. /**
  29338. * Checks if the submesh intersects with a ray
  29339. * @param ray defines the ray to test
  29340. * @returns true is the passed ray intersects the submesh bounding box
  29341. */
  29342. canIntersects(ray: Ray): boolean;
  29343. /**
  29344. * Intersects current submesh with a ray
  29345. * @param ray defines the ray to test
  29346. * @param positions defines mesh's positions array
  29347. * @param indices defines mesh's indices array
  29348. * @param fastCheck defines if only bounding info should be used
  29349. * @returns intersection info or null if no intersection
  29350. */
  29351. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  29352. /** @hidden */
  29353. private _intersectLines;
  29354. /** @hidden */
  29355. private _intersectTriangles;
  29356. /** @hidden */
  29357. _rebuild(): void;
  29358. /**
  29359. * Creates a new submesh from the passed mesh
  29360. * @param newMesh defines the new hosting mesh
  29361. * @param newRenderingMesh defines an optional rendering mesh
  29362. * @returns the new submesh
  29363. */
  29364. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29365. /**
  29366. * Release associated resources
  29367. */
  29368. dispose(): void;
  29369. /**
  29370. * Creates a new submesh from indices data
  29371. * @param materialIndex the index of the main mesh material
  29372. * @param startIndex the index where to start the copy in the mesh indices array
  29373. * @param indexCount the number of indices to copy then from the startIndex
  29374. * @param mesh the main mesh to create the submesh from
  29375. * @param renderingMesh the optional rendering mesh
  29376. * @returns a new submesh
  29377. */
  29378. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29379. }
  29380. }
  29381. declare module BABYLON {
  29382. /**
  29383. * 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.
  29384. * @see https://doc.babylonjs.com/how_to/transformnode
  29385. */
  29386. class TransformNode extends Node {
  29387. /**
  29388. * Object will not rotate to face the camera
  29389. */
  29390. static BILLBOARDMODE_NONE: number;
  29391. /**
  29392. * Object will rotate to face the camera but only on the x axis
  29393. */
  29394. static BILLBOARDMODE_X: number;
  29395. /**
  29396. * Object will rotate to face the camera but only on the y axis
  29397. */
  29398. static BILLBOARDMODE_Y: number;
  29399. /**
  29400. * Object will rotate to face the camera but only on the z axis
  29401. */
  29402. static BILLBOARDMODE_Z: number;
  29403. /**
  29404. * Object will rotate to face the camera
  29405. */
  29406. static BILLBOARDMODE_ALL: number;
  29407. private _forward;
  29408. private _forwardInverted;
  29409. private _up;
  29410. private _right;
  29411. private _rightInverted;
  29412. private _position;
  29413. private _rotation;
  29414. private _rotationQuaternion;
  29415. protected _scaling: Vector3;
  29416. protected _isDirty: boolean;
  29417. private _transformToBoneReferal;
  29418. /**
  29419. * Set the billboard mode. Default is 0.
  29420. *
  29421. * | Value | Type | Description |
  29422. * | --- | --- | --- |
  29423. * | 0 | BILLBOARDMODE_NONE | |
  29424. * | 1 | BILLBOARDMODE_X | |
  29425. * | 2 | BILLBOARDMODE_Y | |
  29426. * | 4 | BILLBOARDMODE_Z | |
  29427. * | 7 | BILLBOARDMODE_ALL | |
  29428. *
  29429. */
  29430. billboardMode: number;
  29431. /**
  29432. * 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
  29433. */
  29434. scalingDeterminant: number;
  29435. /**
  29436. * Sets the distance of the object to max, often used by skybox
  29437. */
  29438. infiniteDistance: boolean;
  29439. /**
  29440. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  29441. * By default the system will update normals to compensate
  29442. */
  29443. ignoreNonUniformScaling: boolean;
  29444. /** @hidden */
  29445. _poseMatrix: Matrix;
  29446. /** @hidden */
  29447. _localMatrix: Matrix;
  29448. private _absolutePosition;
  29449. private _pivotMatrix;
  29450. private _pivotMatrixInverse;
  29451. protected _postMultiplyPivotMatrix: boolean;
  29452. protected _isWorldMatrixFrozen: boolean;
  29453. /** @hidden */
  29454. _indexInSceneTransformNodesArray: number;
  29455. /**
  29456. * An event triggered after the world matrix is updated
  29457. */
  29458. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  29459. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  29460. /**
  29461. * Gets a string identifying the name of the class
  29462. * @returns "TransformNode" string
  29463. */
  29464. getClassName(): string;
  29465. /**
  29466. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  29467. */
  29468. position: Vector3;
  29469. /**
  29470. * 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)).
  29471. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  29472. */
  29473. rotation: Vector3;
  29474. /**
  29475. * 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)).
  29476. */
  29477. scaling: Vector3;
  29478. /**
  29479. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  29480. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  29481. */
  29482. rotationQuaternion: Nullable<Quaternion>;
  29483. /**
  29484. * The forward direction of that transform in world space.
  29485. */
  29486. readonly forward: Vector3;
  29487. /**
  29488. * The up direction of that transform in world space.
  29489. */
  29490. readonly up: Vector3;
  29491. /**
  29492. * The right direction of that transform in world space.
  29493. */
  29494. readonly right: Vector3;
  29495. /**
  29496. * Copies the parameter passed Matrix into the mesh Pose matrix.
  29497. * @param matrix the matrix to copy the pose from
  29498. * @returns this TransformNode.
  29499. */
  29500. updatePoseMatrix(matrix: Matrix): TransformNode;
  29501. /**
  29502. * Returns the mesh Pose matrix.
  29503. * @returns the pose matrix
  29504. */
  29505. getPoseMatrix(): Matrix;
  29506. /** @hidden */
  29507. _isSynchronized(): boolean;
  29508. /** @hidden */
  29509. _initCache(): void;
  29510. /**
  29511. * Flag the transform node as dirty (Forcing it to update everything)
  29512. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  29513. * @returns this transform node
  29514. */
  29515. markAsDirty(property: string): TransformNode;
  29516. /**
  29517. * Returns the current mesh absolute position.
  29518. * Returns a Vector3.
  29519. */
  29520. readonly absolutePosition: Vector3;
  29521. /**
  29522. * Sets a new matrix to apply before all other transformation
  29523. * @param matrix defines the transform matrix
  29524. * @returns the current TransformNode
  29525. */
  29526. setPreTransformMatrix(matrix: Matrix): TransformNode;
  29527. /**
  29528. * Sets a new pivot matrix to the current node
  29529. * @param matrix defines the new pivot matrix to use
  29530. * @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
  29531. * @returns the current TransformNode
  29532. */
  29533. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  29534. /**
  29535. * Returns the mesh pivot matrix.
  29536. * Default : Identity.
  29537. * @returns the matrix
  29538. */
  29539. getPivotMatrix(): Matrix;
  29540. /**
  29541. * Prevents the World matrix to be computed any longer.
  29542. * @returns the TransformNode.
  29543. */
  29544. freezeWorldMatrix(): TransformNode;
  29545. /**
  29546. * Allows back the World matrix computation.
  29547. * @returns the TransformNode.
  29548. */
  29549. unfreezeWorldMatrix(): this;
  29550. /**
  29551. * True if the World matrix has been frozen.
  29552. */
  29553. readonly isWorldMatrixFrozen: boolean;
  29554. /**
  29555. * Retuns the mesh absolute position in the World.
  29556. * @returns a Vector3.
  29557. */
  29558. getAbsolutePosition(): Vector3;
  29559. /**
  29560. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  29561. * @param absolutePosition the absolute position to set
  29562. * @returns the TransformNode.
  29563. */
  29564. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  29565. /**
  29566. * Sets the mesh position in its local space.
  29567. * @param vector3 the position to set in localspace
  29568. * @returns the TransformNode.
  29569. */
  29570. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  29571. /**
  29572. * Returns the mesh position in the local space from the current World matrix values.
  29573. * @returns a new Vector3.
  29574. */
  29575. getPositionExpressedInLocalSpace(): Vector3;
  29576. /**
  29577. * Translates the mesh along the passed Vector3 in its local space.
  29578. * @param vector3 the distance to translate in localspace
  29579. * @returns the TransformNode.
  29580. */
  29581. locallyTranslate(vector3: Vector3): TransformNode;
  29582. private static _lookAtVectorCache;
  29583. /**
  29584. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  29585. * @param targetPoint the position (must be in same space as current mesh) to look at
  29586. * @param yawCor optional yaw (y-axis) correction in radians
  29587. * @param pitchCor optional pitch (x-axis) correction in radians
  29588. * @param rollCor optional roll (z-axis) correction in radians
  29589. * @param space the choosen space of the target
  29590. * @returns the TransformNode.
  29591. */
  29592. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  29593. /**
  29594. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29595. * This Vector3 is expressed in the World space.
  29596. * @param localAxis axis to rotate
  29597. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29598. */
  29599. getDirection(localAxis: Vector3): Vector3;
  29600. /**
  29601. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  29602. * localAxis is expressed in the mesh local space.
  29603. * result is computed in the Wordl space from the mesh World matrix.
  29604. * @param localAxis axis to rotate
  29605. * @param result the resulting transformnode
  29606. * @returns this TransformNode.
  29607. */
  29608. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  29609. /**
  29610. * Sets this transform node rotation to the given local axis.
  29611. * @param localAxis the axis in local space
  29612. * @param yawCor optional yaw (y-axis) correction in radians
  29613. * @param pitchCor optional pitch (x-axis) correction in radians
  29614. * @param rollCor optional roll (z-axis) correction in radians
  29615. * @returns this TransformNode
  29616. */
  29617. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  29618. /**
  29619. * Sets a new pivot point to the current node
  29620. * @param point defines the new pivot point to use
  29621. * @param space defines if the point is in world or local space (local by default)
  29622. * @returns the current TransformNode
  29623. */
  29624. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  29625. /**
  29626. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  29627. * @returns the pivot point
  29628. */
  29629. getPivotPoint(): Vector3;
  29630. /**
  29631. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  29632. * @param result the vector3 to store the result
  29633. * @returns this TransformNode.
  29634. */
  29635. getPivotPointToRef(result: Vector3): TransformNode;
  29636. /**
  29637. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  29638. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  29639. */
  29640. getAbsolutePivotPoint(): Vector3;
  29641. /**
  29642. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  29643. * @param result vector3 to store the result
  29644. * @returns this TransformNode.
  29645. */
  29646. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  29647. /**
  29648. * Defines the passed node as the parent of the current node.
  29649. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  29650. * @param node the node ot set as the parent
  29651. * @returns this TransformNode.
  29652. */
  29653. setParent(node: Nullable<Node>): TransformNode;
  29654. private _nonUniformScaling;
  29655. /**
  29656. * True if the scaling property of this object is non uniform eg. (1,2,1)
  29657. */
  29658. readonly nonUniformScaling: boolean;
  29659. /** @hidden */
  29660. _updateNonUniformScalingState(value: boolean): boolean;
  29661. /**
  29662. * Attach the current TransformNode to another TransformNode associated with a bone
  29663. * @param bone Bone affecting the TransformNode
  29664. * @param affectedTransformNode TransformNode associated with the bone
  29665. * @returns this object
  29666. */
  29667. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  29668. /**
  29669. * Detach the transform node if its associated with a bone
  29670. * @returns this object
  29671. */
  29672. detachFromBone(): TransformNode;
  29673. private static _rotationAxisCache;
  29674. /**
  29675. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  29676. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29677. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29678. * The passed axis is also normalized.
  29679. * @param axis the axis to rotate around
  29680. * @param amount the amount to rotate in radians
  29681. * @param space Space to rotate in (Default: local)
  29682. * @returns the TransformNode.
  29683. */
  29684. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  29685. /**
  29686. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  29687. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29688. * The passed axis is also normalized. .
  29689. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  29690. * @param point the point to rotate around
  29691. * @param axis the axis to rotate around
  29692. * @param amount the amount to rotate in radians
  29693. * @returns the TransformNode
  29694. */
  29695. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  29696. /**
  29697. * Translates the mesh along the axis vector for the passed distance in the given space.
  29698. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29699. * @param axis the axis to translate in
  29700. * @param distance the distance to translate
  29701. * @param space Space to rotate in (Default: local)
  29702. * @returns the TransformNode.
  29703. */
  29704. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  29705. /**
  29706. * Adds a rotation step to the mesh current rotation.
  29707. * x, y, z are Euler angles expressed in radians.
  29708. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  29709. * This means this rotation is made in the mesh local space only.
  29710. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  29711. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  29712. * ```javascript
  29713. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  29714. * ```
  29715. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  29716. * 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.
  29717. * @param x Rotation to add
  29718. * @param y Rotation to add
  29719. * @param z Rotation to add
  29720. * @returns the TransformNode.
  29721. */
  29722. addRotation(x: number, y: number, z: number): TransformNode;
  29723. /**
  29724. * Computes the world matrix of the node
  29725. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29726. * @returns the world matrix
  29727. */
  29728. computeWorldMatrix(force?: boolean): Matrix;
  29729. protected _afterComputeWorldMatrix(): void;
  29730. /**
  29731. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  29732. * @param func callback function to add
  29733. *
  29734. * @returns the TransformNode.
  29735. */
  29736. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29737. /**
  29738. * Removes a registered callback function.
  29739. * @param func callback function to remove
  29740. * @returns the TransformNode.
  29741. */
  29742. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29743. /**
  29744. * Gets the position of the current mesh in camera space
  29745. * @param camera defines the camera to use
  29746. * @returns a position
  29747. */
  29748. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  29749. /**
  29750. * Returns the distance from the mesh to the active camera
  29751. * @param camera defines the camera to use
  29752. * @returns the distance
  29753. */
  29754. getDistanceToCamera(camera?: Nullable<Camera>): number;
  29755. /**
  29756. * Clone the current transform node
  29757. * @param name Name of the new clone
  29758. * @param newParent New parent for the clone
  29759. * @param doNotCloneChildren Do not clone children hierarchy
  29760. * @returns the new transform node
  29761. */
  29762. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  29763. /**
  29764. * Serializes the objects information.
  29765. * @param currentSerializationObject defines the object to serialize in
  29766. * @returns the serialized object
  29767. */
  29768. serialize(currentSerializationObject?: any): any;
  29769. /**
  29770. * Returns a new TransformNode object parsed from the source provided.
  29771. * @param parsedTransformNode is the source.
  29772. * @param scene the scne the object belongs to
  29773. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  29774. * @returns a new TransformNode object parsed from the source provided.
  29775. */
  29776. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  29777. /**
  29778. * Releases resources associated with this transform node.
  29779. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29780. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29781. */
  29782. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29783. }
  29784. }
  29785. declare module BABYLON {
  29786. /**
  29787. * Specialized buffer used to store vertex data
  29788. */
  29789. class VertexBuffer {
  29790. /** @hidden */
  29791. _buffer: Buffer;
  29792. private _kind;
  29793. private _size;
  29794. private _ownsBuffer;
  29795. private _instanced;
  29796. private _instanceDivisor;
  29797. /**
  29798. * The byte type.
  29799. */
  29800. static readonly BYTE: number;
  29801. /**
  29802. * The unsigned byte type.
  29803. */
  29804. static readonly UNSIGNED_BYTE: number;
  29805. /**
  29806. * The short type.
  29807. */
  29808. static readonly SHORT: number;
  29809. /**
  29810. * The unsigned short type.
  29811. */
  29812. static readonly UNSIGNED_SHORT: number;
  29813. /**
  29814. * The integer type.
  29815. */
  29816. static readonly INT: number;
  29817. /**
  29818. * The unsigned integer type.
  29819. */
  29820. static readonly UNSIGNED_INT: number;
  29821. /**
  29822. * The float type.
  29823. */
  29824. static readonly FLOAT: number;
  29825. /**
  29826. * Gets or sets the instance divisor when in instanced mode
  29827. */
  29828. instanceDivisor: number;
  29829. /**
  29830. * Gets the byte stride.
  29831. */
  29832. readonly byteStride: number;
  29833. /**
  29834. * Gets the byte offset.
  29835. */
  29836. readonly byteOffset: number;
  29837. /**
  29838. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  29839. */
  29840. readonly normalized: boolean;
  29841. /**
  29842. * Gets the data type of each component in the array.
  29843. */
  29844. readonly type: number;
  29845. /**
  29846. * Constructor
  29847. * @param engine the engine
  29848. * @param data the data to use for this vertex buffer
  29849. * @param kind the vertex buffer kind
  29850. * @param updatable whether the data is updatable
  29851. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  29852. * @param stride the stride (optional)
  29853. * @param instanced whether the buffer is instanced (optional)
  29854. * @param offset the offset of the data (optional)
  29855. * @param size the number of components (optional)
  29856. * @param type the type of the component (optional)
  29857. * @param normalized whether the data contains normalized data (optional)
  29858. * @param useBytes set to true if stride and offset are in bytes (optional)
  29859. */
  29860. 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);
  29861. /** @hidden */
  29862. _rebuild(): void;
  29863. /**
  29864. * Returns the kind of the VertexBuffer (string)
  29865. * @returns a string
  29866. */
  29867. getKind(): string;
  29868. /**
  29869. * Gets a boolean indicating if the VertexBuffer is updatable?
  29870. * @returns true if the buffer is updatable
  29871. */
  29872. isUpdatable(): boolean;
  29873. /**
  29874. * Gets current buffer's data
  29875. * @returns a DataArray or null
  29876. */
  29877. getData(): Nullable<DataArray>;
  29878. /**
  29879. * Gets underlying native buffer
  29880. * @returns underlying native buffer
  29881. */
  29882. getBuffer(): Nullable<WebGLBuffer>;
  29883. /**
  29884. * Gets the stride in float32 units (i.e. byte stride / 4).
  29885. * May not be an integer if the byte stride is not divisible by 4.
  29886. * DEPRECATED. Use byteStride instead.
  29887. * @returns the stride in float32 units
  29888. */
  29889. getStrideSize(): number;
  29890. /**
  29891. * Returns the offset as a multiple of the type byte length.
  29892. * DEPRECATED. Use byteOffset instead.
  29893. * @returns the offset in bytes
  29894. */
  29895. getOffset(): number;
  29896. /**
  29897. * Returns the number of components per vertex attribute (integer)
  29898. * @returns the size in float
  29899. */
  29900. getSize(): number;
  29901. /**
  29902. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  29903. * @returns true if this buffer is instanced
  29904. */
  29905. getIsInstanced(): boolean;
  29906. /**
  29907. * Returns the instancing divisor, zero for non-instanced (integer).
  29908. * @returns a number
  29909. */
  29910. getInstanceDivisor(): number;
  29911. /**
  29912. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  29913. * @param data defines the data to store
  29914. */
  29915. create(data?: DataArray): void;
  29916. /**
  29917. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  29918. * This function will create a new buffer if the current one is not updatable
  29919. * @param data defines the data to store
  29920. */
  29921. update(data: DataArray): void;
  29922. /**
  29923. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  29924. * Returns the directly updated WebGLBuffer.
  29925. * @param data the new data
  29926. * @param offset the new offset
  29927. * @param useBytes set to true if the offset is in bytes
  29928. */
  29929. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  29930. /**
  29931. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  29932. */
  29933. dispose(): void;
  29934. /**
  29935. * Enumerates each value of this vertex buffer as numbers.
  29936. * @param count the number of values to enumerate
  29937. * @param callback the callback function called for each value
  29938. */
  29939. forEach(count: number, callback: (value: number, index: number) => void): void;
  29940. /**
  29941. * Positions
  29942. */
  29943. static readonly PositionKind: string;
  29944. /**
  29945. * Normals
  29946. */
  29947. static readonly NormalKind: string;
  29948. /**
  29949. * Tangents
  29950. */
  29951. static readonly TangentKind: string;
  29952. /**
  29953. * Texture coordinates
  29954. */
  29955. static readonly UVKind: string;
  29956. /**
  29957. * Texture coordinates 2
  29958. */
  29959. static readonly UV2Kind: string;
  29960. /**
  29961. * Texture coordinates 3
  29962. */
  29963. static readonly UV3Kind: string;
  29964. /**
  29965. * Texture coordinates 4
  29966. */
  29967. static readonly UV4Kind: string;
  29968. /**
  29969. * Texture coordinates 5
  29970. */
  29971. static readonly UV5Kind: string;
  29972. /**
  29973. * Texture coordinates 6
  29974. */
  29975. static readonly UV6Kind: string;
  29976. /**
  29977. * Colors
  29978. */
  29979. static readonly ColorKind: string;
  29980. /**
  29981. * Matrix indices (for bones)
  29982. */
  29983. static readonly MatricesIndicesKind: string;
  29984. /**
  29985. * Matrix weights (for bones)
  29986. */
  29987. static readonly MatricesWeightsKind: string;
  29988. /**
  29989. * Additional matrix indices (for bones)
  29990. */
  29991. static readonly MatricesIndicesExtraKind: string;
  29992. /**
  29993. * Additional matrix weights (for bones)
  29994. */
  29995. static readonly MatricesWeightsExtraKind: string;
  29996. /**
  29997. * Deduces the stride given a kind.
  29998. * @param kind The kind string to deduce
  29999. * @returns The deduced stride
  30000. */
  30001. static DeduceStride(kind: string): number;
  30002. /**
  30003. * Gets the byte length of the given type.
  30004. * @param type the type
  30005. * @returns the number of bytes
  30006. */
  30007. static GetTypeByteLength(type: number): number;
  30008. /**
  30009. * Enumerates each value of the given parameters as numbers.
  30010. * @param data the data to enumerate
  30011. * @param byteOffset the byte offset of the data
  30012. * @param byteStride the byte stride of the data
  30013. * @param componentCount the number of components per element
  30014. * @param componentType the type of the component
  30015. * @param count the total number of components
  30016. * @param normalized whether the data is normalized
  30017. * @param callback the callback function called for each value
  30018. */
  30019. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  30020. private static _GetFloatValue;
  30021. }
  30022. }
  30023. declare module BABYLON {
  30024. /**
  30025. * Defines a target to use with MorphTargetManager
  30026. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30027. */
  30028. class MorphTarget implements IAnimatable {
  30029. /** defines the name of the target */
  30030. name: string;
  30031. /**
  30032. * Gets or sets the list of animations
  30033. */
  30034. animations: Animation[];
  30035. private _scene;
  30036. private _positions;
  30037. private _normals;
  30038. private _tangents;
  30039. private _influence;
  30040. /**
  30041. * Observable raised when the influence changes
  30042. */
  30043. onInfluenceChanged: Observable<boolean>;
  30044. /** @hidden */
  30045. _onDataLayoutChanged: Observable<void>;
  30046. /**
  30047. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  30048. */
  30049. influence: number;
  30050. /**
  30051. * Gets or sets the id of the morph Target
  30052. */
  30053. id: string;
  30054. private _animationPropertiesOverride;
  30055. /**
  30056. * Gets or sets the animation properties override
  30057. */
  30058. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  30059. /**
  30060. * Creates a new MorphTarget
  30061. * @param name defines the name of the target
  30062. * @param influence defines the influence to use
  30063. */
  30064. constructor(
  30065. /** defines the name of the target */
  30066. name: string, influence?: number, scene?: Nullable<Scene>);
  30067. /**
  30068. * Gets a boolean defining if the target contains position data
  30069. */
  30070. readonly hasPositions: boolean;
  30071. /**
  30072. * Gets a boolean defining if the target contains normal data
  30073. */
  30074. readonly hasNormals: boolean;
  30075. /**
  30076. * Gets a boolean defining if the target contains tangent data
  30077. */
  30078. readonly hasTangents: boolean;
  30079. /**
  30080. * Affects position data to this target
  30081. * @param data defines the position data to use
  30082. */
  30083. setPositions(data: Nullable<FloatArray>): void;
  30084. /**
  30085. * Gets the position data stored in this target
  30086. * @returns a FloatArray containing the position data (or null if not present)
  30087. */
  30088. getPositions(): Nullable<FloatArray>;
  30089. /**
  30090. * Affects normal data to this target
  30091. * @param data defines the normal data to use
  30092. */
  30093. setNormals(data: Nullable<FloatArray>): void;
  30094. /**
  30095. * Gets the normal data stored in this target
  30096. * @returns a FloatArray containing the normal data (or null if not present)
  30097. */
  30098. getNormals(): Nullable<FloatArray>;
  30099. /**
  30100. * Affects tangent data to this target
  30101. * @param data defines the tangent data to use
  30102. */
  30103. setTangents(data: Nullable<FloatArray>): void;
  30104. /**
  30105. * Gets the tangent data stored in this target
  30106. * @returns a FloatArray containing the tangent data (or null if not present)
  30107. */
  30108. getTangents(): Nullable<FloatArray>;
  30109. /**
  30110. * Serializes the current target into a Serialization object
  30111. * @returns the serialized object
  30112. */
  30113. serialize(): any;
  30114. /**
  30115. * Returns the string "MorphTarget"
  30116. * @returns "MorphTarget"
  30117. */
  30118. getClassName(): string;
  30119. /**
  30120. * Creates a new target from serialized data
  30121. * @param serializationObject defines the serialized data to use
  30122. * @returns a new MorphTarget
  30123. */
  30124. static Parse(serializationObject: any): MorphTarget;
  30125. /**
  30126. * Creates a MorphTarget from mesh data
  30127. * @param mesh defines the source mesh
  30128. * @param name defines the name to use for the new target
  30129. * @param influence defines the influence to attach to the target
  30130. * @returns a new MorphTarget
  30131. */
  30132. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30133. }
  30134. }
  30135. declare module BABYLON {
  30136. /**
  30137. * This class is used to deform meshes using morphing between different targets
  30138. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30139. */
  30140. class MorphTargetManager {
  30141. private _targets;
  30142. private _targetInfluenceChangedObservers;
  30143. private _targetDataLayoutChangedObservers;
  30144. private _activeTargets;
  30145. private _scene;
  30146. private _influences;
  30147. private _supportsNormals;
  30148. private _supportsTangents;
  30149. private _vertexCount;
  30150. private _uniqueId;
  30151. private _tempInfluences;
  30152. /**
  30153. * Creates a new MorphTargetManager
  30154. * @param scene defines the current scene
  30155. */
  30156. constructor(scene?: Nullable<Scene>);
  30157. /**
  30158. * Gets the unique ID of this manager
  30159. */
  30160. readonly uniqueId: number;
  30161. /**
  30162. * Gets the number of vertices handled by this manager
  30163. */
  30164. readonly vertexCount: number;
  30165. /**
  30166. * Gets a boolean indicating if this manager supports morphing of normals
  30167. */
  30168. readonly supportsNormals: boolean;
  30169. /**
  30170. * Gets a boolean indicating if this manager supports morphing of tangents
  30171. */
  30172. readonly supportsTangents: boolean;
  30173. /**
  30174. * Gets the number of targets stored in this manager
  30175. */
  30176. readonly numTargets: number;
  30177. /**
  30178. * Gets the number of influencers (ie. the number of targets with influences > 0)
  30179. */
  30180. readonly numInfluencers: number;
  30181. /**
  30182. * Gets the list of influences (one per target)
  30183. */
  30184. readonly influences: Float32Array;
  30185. /**
  30186. * Gets the active target at specified index. An active target is a target with an influence > 0
  30187. * @param index defines the index to check
  30188. * @returns the requested target
  30189. */
  30190. getActiveTarget(index: number): MorphTarget;
  30191. /**
  30192. * Gets the target at specified index
  30193. * @param index defines the index to check
  30194. * @returns the requested target
  30195. */
  30196. getTarget(index: number): MorphTarget;
  30197. /**
  30198. * Add a new target to this manager
  30199. * @param target defines the target to add
  30200. */
  30201. addTarget(target: MorphTarget): void;
  30202. /**
  30203. * Removes a target from the manager
  30204. * @param target defines the target to remove
  30205. */
  30206. removeTarget(target: MorphTarget): void;
  30207. /**
  30208. * Serializes the current manager into a Serialization object
  30209. * @returns the serialized object
  30210. */
  30211. serialize(): any;
  30212. private _syncActiveTargets;
  30213. /**
  30214. * Syncrhonize the targets with all the meshes using this morph target manager
  30215. */
  30216. synchronize(): void;
  30217. /**
  30218. * Creates a new MorphTargetManager from serialized data
  30219. * @param serializationObject defines the serialized data
  30220. * @param scene defines the hosting scene
  30221. * @returns the new MorphTargetManager
  30222. */
  30223. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  30224. }
  30225. }
  30226. declare module BABYLON {
  30227. /**
  30228. * Class used to enable access to IndexedDB
  30229. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30230. */
  30231. class Database implements IOfflineProvider {
  30232. private _callbackManifestChecked;
  30233. private _currentSceneUrl;
  30234. private _db;
  30235. private _enableSceneOffline;
  30236. private _enableTexturesOffline;
  30237. private _manifestVersionFound;
  30238. private _mustUpdateRessources;
  30239. private _hasReachedQuota;
  30240. private _isSupported;
  30241. private _idbFactory;
  30242. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  30243. private static IsUASupportingBlobStorage;
  30244. /**
  30245. * Gets a boolean indicating if Database storate is enabled (off by default)
  30246. */
  30247. static IDBStorageEnabled: boolean;
  30248. /**
  30249. * Gets a boolean indicating if scene must be saved in the database
  30250. */
  30251. readonly enableSceneOffline: boolean;
  30252. /**
  30253. * Gets a boolean indicating if textures must be saved in the database
  30254. */
  30255. readonly enableTexturesOffline: boolean;
  30256. /**
  30257. * Creates a new Database
  30258. * @param urlToScene defines the url to load the scene
  30259. * @param callbackManifestChecked defines the callback to use when manifest is checked
  30260. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  30261. */
  30262. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  30263. private static _ParseURL;
  30264. private static _ReturnFullUrlLocation;
  30265. private _checkManifestFile;
  30266. /**
  30267. * Open the database and make it available
  30268. * @param successCallback defines the callback to call on success
  30269. * @param errorCallback defines the callback to call on error
  30270. */
  30271. open(successCallback: () => void, errorCallback: () => void): void;
  30272. /**
  30273. * Loads an image from the database
  30274. * @param url defines the url to load from
  30275. * @param image defines the target DOM image
  30276. */
  30277. loadImage(url: string, image: HTMLImageElement): void;
  30278. private _loadImageFromDBAsync;
  30279. private _saveImageIntoDBAsync;
  30280. private _checkVersionFromDB;
  30281. private _loadVersionFromDBAsync;
  30282. private _saveVersionIntoDBAsync;
  30283. /**
  30284. * Loads a file from database
  30285. * @param url defines the URL to load from
  30286. * @param sceneLoaded defines a callback to call on success
  30287. * @param progressCallBack defines a callback to call when progress changed
  30288. * @param errorCallback defines a callback to call on error
  30289. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30290. */
  30291. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30292. private _loadFileAsync;
  30293. private _saveFileAsync;
  30294. }
  30295. }
  30296. declare module BABYLON {
  30297. /**
  30298. * Class used to enable access to offline support
  30299. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30300. */
  30301. interface IOfflineProvider {
  30302. /**
  30303. * Gets a boolean indicating if scene must be saved in the database
  30304. */
  30305. enableSceneOffline: boolean;
  30306. /**
  30307. * Gets a boolean indicating if textures must be saved in the database
  30308. */
  30309. enableTexturesOffline: boolean;
  30310. /**
  30311. * Open the offline support and make it available
  30312. * @param successCallback defines the callback to call on success
  30313. * @param errorCallback defines the callback to call on error
  30314. */
  30315. open(successCallback: () => void, errorCallback: () => void): void;
  30316. /**
  30317. * Loads an image from the offline support
  30318. * @param url defines the url to load from
  30319. * @param image defines the target DOM image
  30320. */
  30321. loadImage(url: string, image: HTMLImageElement): void;
  30322. /**
  30323. * Loads a file from offline support
  30324. * @param url defines the URL to load from
  30325. * @param sceneLoaded defines a callback to call on success
  30326. * @param progressCallBack defines a callback to call when progress changed
  30327. * @param errorCallback defines a callback to call on error
  30328. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30329. */
  30330. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30331. }
  30332. }
  30333. declare module BABYLON {
  30334. /**
  30335. * This represents the base class for particle system in Babylon.
  30336. * 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.
  30337. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  30338. * @example https://doc.babylonjs.com/babylon101/particles
  30339. */
  30340. class BaseParticleSystem {
  30341. /**
  30342. * Source color is added to the destination color without alpha affecting the result
  30343. */
  30344. static BLENDMODE_ONEONE: number;
  30345. /**
  30346. * Blend current color and particle color using particle’s alpha
  30347. */
  30348. static BLENDMODE_STANDARD: number;
  30349. /**
  30350. * Add current color and particle color multiplied by particle’s alpha
  30351. */
  30352. static BLENDMODE_ADD: number;
  30353. /**
  30354. * Multiply current color with particle color
  30355. */
  30356. static BLENDMODE_MULTIPLY: number;
  30357. /**
  30358. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  30359. */
  30360. static BLENDMODE_MULTIPLYADD: number;
  30361. /**
  30362. * List of animations used by the particle system.
  30363. */
  30364. animations: Animation[];
  30365. /**
  30366. * The id of the Particle system.
  30367. */
  30368. id: string;
  30369. /**
  30370. * The friendly name of the Particle system.
  30371. */
  30372. name: string;
  30373. /**
  30374. * The rendering group used by the Particle system to chose when to render.
  30375. */
  30376. renderingGroupId: number;
  30377. /**
  30378. * The emitter represents the Mesh or position we are attaching the particle system to.
  30379. */
  30380. emitter: Nullable<AbstractMesh | Vector3>;
  30381. /**
  30382. * The maximum number of particles to emit per frame
  30383. */
  30384. emitRate: number;
  30385. /**
  30386. * If you want to launch only a few particles at once, that can be done, as well.
  30387. */
  30388. manualEmitCount: number;
  30389. /**
  30390. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  30391. */
  30392. updateSpeed: number;
  30393. /**
  30394. * The amount of time the particle system is running (depends of the overall update speed).
  30395. */
  30396. targetStopDuration: number;
  30397. /**
  30398. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  30399. */
  30400. disposeOnStop: boolean;
  30401. /**
  30402. * Minimum power of emitting particles.
  30403. */
  30404. minEmitPower: number;
  30405. /**
  30406. * Maximum power of emitting particles.
  30407. */
  30408. maxEmitPower: number;
  30409. /**
  30410. * Minimum life time of emitting particles.
  30411. */
  30412. minLifeTime: number;
  30413. /**
  30414. * Maximum life time of emitting particles.
  30415. */
  30416. maxLifeTime: number;
  30417. /**
  30418. * Minimum Size of emitting particles.
  30419. */
  30420. minSize: number;
  30421. /**
  30422. * Maximum Size of emitting particles.
  30423. */
  30424. maxSize: number;
  30425. /**
  30426. * Minimum scale of emitting particles on X axis.
  30427. */
  30428. minScaleX: number;
  30429. /**
  30430. * Maximum scale of emitting particles on X axis.
  30431. */
  30432. maxScaleX: number;
  30433. /**
  30434. * Minimum scale of emitting particles on Y axis.
  30435. */
  30436. minScaleY: number;
  30437. /**
  30438. * Maximum scale of emitting particles on Y axis.
  30439. */
  30440. maxScaleY: number;
  30441. /**
  30442. * Gets or sets the minimal initial rotation in radians.
  30443. */
  30444. minInitialRotation: number;
  30445. /**
  30446. * Gets or sets the maximal initial rotation in radians.
  30447. */
  30448. maxInitialRotation: number;
  30449. /**
  30450. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  30451. */
  30452. minAngularSpeed: number;
  30453. /**
  30454. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  30455. */
  30456. maxAngularSpeed: number;
  30457. /**
  30458. * The texture used to render each particle. (this can be a spritesheet)
  30459. */
  30460. particleTexture: Nullable<Texture>;
  30461. /**
  30462. * The layer mask we are rendering the particles through.
  30463. */
  30464. layerMask: number;
  30465. /**
  30466. * This can help using your own shader to render the particle system.
  30467. * The according effect will be created
  30468. */
  30469. customShader: any;
  30470. /**
  30471. * By default particle system starts as soon as they are created. This prevents the
  30472. * automatic start to happen and let you decide when to start emitting particles.
  30473. */
  30474. preventAutoStart: boolean;
  30475. private _noiseTexture;
  30476. /**
  30477. * Gets or sets a texture used to add random noise to particle positions
  30478. */
  30479. noiseTexture: Nullable<ProceduralTexture>;
  30480. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  30481. noiseStrength: Vector3;
  30482. /**
  30483. * Callback triggered when the particle animation is ending.
  30484. */
  30485. onAnimationEnd: Nullable<() => void>;
  30486. /**
  30487. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  30488. */
  30489. blendMode: number;
  30490. /**
  30491. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30492. * to override the particles.
  30493. */
  30494. forceDepthWrite: boolean;
  30495. /** 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 */
  30496. preWarmCycles: number;
  30497. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  30498. preWarmStepOffset: number;
  30499. /**
  30500. * 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)
  30501. */
  30502. spriteCellChangeSpeed: number;
  30503. /**
  30504. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  30505. */
  30506. startSpriteCellID: number;
  30507. /**
  30508. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  30509. */
  30510. endSpriteCellID: number;
  30511. /**
  30512. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  30513. */
  30514. spriteCellWidth: number;
  30515. /**
  30516. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  30517. */
  30518. spriteCellHeight: number;
  30519. /**
  30520. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  30521. */
  30522. spriteRandomStartCell: boolean;
  30523. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  30524. translationPivot: Vector2;
  30525. /** @hidden */
  30526. protected _isAnimationSheetEnabled: boolean;
  30527. /**
  30528. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  30529. */
  30530. beginAnimationOnStart: boolean;
  30531. /**
  30532. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  30533. */
  30534. beginAnimationFrom: number;
  30535. /**
  30536. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  30537. */
  30538. beginAnimationTo: number;
  30539. /**
  30540. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  30541. */
  30542. beginAnimationLoop: boolean;
  30543. /**
  30544. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  30545. */
  30546. isAnimationSheetEnabled: boolean;
  30547. /**
  30548. * Get hosting scene
  30549. * @returns the scene
  30550. */
  30551. getScene(): Scene;
  30552. /**
  30553. * You can use gravity if you want to give an orientation to your particles.
  30554. */
  30555. gravity: Vector3;
  30556. protected _colorGradients: Nullable<Array<ColorGradient>>;
  30557. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  30558. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  30559. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  30560. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  30561. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  30562. protected _dragGradients: Nullable<Array<FactorGradient>>;
  30563. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  30564. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  30565. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  30566. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  30567. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  30568. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  30569. /**
  30570. * Defines the delay in milliseconds before starting the system (0 by default)
  30571. */
  30572. startDelay: number;
  30573. /**
  30574. * Gets the current list of drag gradients.
  30575. * You must use addDragGradient and removeDragGradient to udpate this list
  30576. * @returns the list of drag gradients
  30577. */
  30578. getDragGradients(): Nullable<Array<FactorGradient>>;
  30579. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  30580. limitVelocityDamping: number;
  30581. /**
  30582. * Gets the current list of limit velocity gradients.
  30583. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  30584. * @returns the list of limit velocity gradients
  30585. */
  30586. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  30587. /**
  30588. * Gets the current list of color gradients.
  30589. * You must use addColorGradient and removeColorGradient to udpate this list
  30590. * @returns the list of color gradients
  30591. */
  30592. getColorGradients(): Nullable<Array<ColorGradient>>;
  30593. /**
  30594. * Gets the current list of size gradients.
  30595. * You must use addSizeGradient and removeSizeGradient to udpate this list
  30596. * @returns the list of size gradients
  30597. */
  30598. getSizeGradients(): Nullable<Array<FactorGradient>>;
  30599. /**
  30600. * Gets the current list of color remap gradients.
  30601. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  30602. * @returns the list of color remap gradients
  30603. */
  30604. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  30605. /**
  30606. * Gets the current list of alpha remap gradients.
  30607. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  30608. * @returns the list of alpha remap gradients
  30609. */
  30610. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  30611. /**
  30612. * Gets the current list of life time gradients.
  30613. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  30614. * @returns the list of life time gradients
  30615. */
  30616. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  30617. /**
  30618. * Gets the current list of angular speed gradients.
  30619. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  30620. * @returns the list of angular speed gradients
  30621. */
  30622. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  30623. /**
  30624. * Gets the current list of velocity gradients.
  30625. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  30626. * @returns the list of velocity gradients
  30627. */
  30628. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  30629. /**
  30630. * Gets the current list of start size gradients.
  30631. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  30632. * @returns the list of start size gradients
  30633. */
  30634. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  30635. /**
  30636. * Gets the current list of emit rate gradients.
  30637. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  30638. * @returns the list of emit rate gradients
  30639. */
  30640. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  30641. /**
  30642. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30643. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30644. */
  30645. direction1: Vector3;
  30646. /**
  30647. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30648. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30649. */
  30650. direction2: Vector3;
  30651. /**
  30652. * 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.
  30653. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30654. */
  30655. minEmitBox: Vector3;
  30656. /**
  30657. * 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.
  30658. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30659. */
  30660. maxEmitBox: Vector3;
  30661. /**
  30662. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30663. */
  30664. color1: Color4;
  30665. /**
  30666. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30667. */
  30668. color2: Color4;
  30669. /**
  30670. * Color the particle will have at the end of its lifetime
  30671. */
  30672. colorDead: Color4;
  30673. /**
  30674. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  30675. */
  30676. textureMask: Color4;
  30677. /**
  30678. * The particle emitter type defines the emitter used by the particle system.
  30679. * It can be for example box, sphere, or cone...
  30680. */
  30681. particleEmitterType: IParticleEmitterType;
  30682. /** @hidden */
  30683. _isSubEmitter: boolean;
  30684. /**
  30685. * Gets or sets the billboard mode to use when isBillboardBased = true.
  30686. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  30687. */
  30688. billboardMode: number;
  30689. protected _isBillboardBased: boolean;
  30690. /**
  30691. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  30692. */
  30693. isBillboardBased: boolean;
  30694. /**
  30695. * The scene the particle system belongs to.
  30696. */
  30697. protected _scene: Scene;
  30698. /**
  30699. * Local cache of defines for image processing.
  30700. */
  30701. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  30702. /**
  30703. * Default configuration related to image processing available in the standard Material.
  30704. */
  30705. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30706. /**
  30707. * Gets the image processing configuration used either in this material.
  30708. */
  30709. /**
  30710. * Sets the Default image processing configuration used either in the this material.
  30711. *
  30712. * If sets to null, the scene one is in use.
  30713. */
  30714. imageProcessingConfiguration: ImageProcessingConfiguration;
  30715. /**
  30716. * Attaches a new image processing configuration to the Standard Material.
  30717. * @param configuration
  30718. */
  30719. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30720. /** @hidden */
  30721. protected _reset(): void;
  30722. /** @hidden */
  30723. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  30724. /**
  30725. * Instantiates a particle system.
  30726. * 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.
  30727. * @param name The name of the particle system
  30728. */
  30729. constructor(name: string);
  30730. /**
  30731. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  30732. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30733. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30734. * @returns the emitter
  30735. */
  30736. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  30737. /**
  30738. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  30739. * @param radius The radius of the hemisphere to emit from
  30740. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30741. * @returns the emitter
  30742. */
  30743. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  30744. /**
  30745. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  30746. * @param radius The radius of the sphere to emit from
  30747. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30748. * @returns the emitter
  30749. */
  30750. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  30751. /**
  30752. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  30753. * @param radius The radius of the sphere to emit from
  30754. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  30755. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  30756. * @returns the emitter
  30757. */
  30758. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  30759. /**
  30760. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  30761. * @param radius The radius of the emission cylinder
  30762. * @param height The height of the emission cylinder
  30763. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  30764. * @param directionRandomizer How much to randomize the particle direction [0-1]
  30765. * @returns the emitter
  30766. */
  30767. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  30768. /**
  30769. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  30770. * @param radius The radius of the cylinder to emit from
  30771. * @param height The height of the emission cylinder
  30772. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  30773. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  30774. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  30775. * @returns the emitter
  30776. */
  30777. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  30778. /**
  30779. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  30780. * @param radius The radius of the cone to emit from
  30781. * @param angle The base angle of the cone
  30782. * @returns the emitter
  30783. */
  30784. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  30785. /**
  30786. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  30787. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30788. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30789. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30790. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30791. * @returns the emitter
  30792. */
  30793. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  30794. }
  30795. }
  30796. declare module BABYLON {
  30797. /**
  30798. * This represents a GPU particle system in Babylon
  30799. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  30800. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  30801. */
  30802. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  30803. /**
  30804. * The layer mask we are rendering the particles through.
  30805. */
  30806. layerMask: number;
  30807. private _capacity;
  30808. private _activeCount;
  30809. private _currentActiveCount;
  30810. private _accumulatedCount;
  30811. private _renderEffect;
  30812. private _updateEffect;
  30813. private _buffer0;
  30814. private _buffer1;
  30815. private _spriteBuffer;
  30816. private _updateVAO;
  30817. private _renderVAO;
  30818. private _targetIndex;
  30819. private _sourceBuffer;
  30820. private _targetBuffer;
  30821. private _engine;
  30822. private _currentRenderId;
  30823. private _started;
  30824. private _stopped;
  30825. private _timeDelta;
  30826. private _randomTexture;
  30827. private _randomTexture2;
  30828. private _attributesStrideSize;
  30829. private _updateEffectOptions;
  30830. private _randomTextureSize;
  30831. private _actualFrame;
  30832. private readonly _rawTextureWidth;
  30833. /**
  30834. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  30835. */
  30836. static readonly IsSupported: boolean;
  30837. /**
  30838. * An event triggered when the system is disposed.
  30839. */
  30840. onDisposeObservable: Observable<GPUParticleSystem>;
  30841. /**
  30842. * Gets the maximum number of particles active at the same time.
  30843. * @returns The max number of active particles.
  30844. */
  30845. getCapacity(): number;
  30846. /**
  30847. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30848. * to override the particles.
  30849. */
  30850. forceDepthWrite: boolean;
  30851. /**
  30852. * Gets or set the number of active particles
  30853. */
  30854. activeParticleCount: number;
  30855. private _preWarmDone;
  30856. /**
  30857. * Is this system ready to be used/rendered
  30858. * @return true if the system is ready
  30859. */
  30860. isReady(): boolean;
  30861. /**
  30862. * Gets if the system has been started. (Note: this will still be true after stop is called)
  30863. * @returns True if it has been started, otherwise false.
  30864. */
  30865. isStarted(): boolean;
  30866. /**
  30867. * Starts the particle system and begins to emit
  30868. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  30869. */
  30870. start(delay?: number): void;
  30871. /**
  30872. * Stops the particle system.
  30873. */
  30874. stop(): void;
  30875. /**
  30876. * Remove all active particles
  30877. */
  30878. reset(): void;
  30879. /**
  30880. * Returns the string "GPUParticleSystem"
  30881. * @returns a string containing the class name
  30882. */
  30883. getClassName(): string;
  30884. private _colorGradientsTexture;
  30885. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  30886. /**
  30887. * Adds a new color gradient
  30888. * @param gradient defines the gradient to use (between 0 and 1)
  30889. * @param color1 defines the color to affect to the specified gradient
  30890. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  30891. * @returns the current particle system
  30892. */
  30893. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  30894. /**
  30895. * Remove a specific color gradient
  30896. * @param gradient defines the gradient to remove
  30897. * @returns the current particle system
  30898. */
  30899. removeColorGradient(gradient: number): GPUParticleSystem;
  30900. private _angularSpeedGradientsTexture;
  30901. private _sizeGradientsTexture;
  30902. private _velocityGradientsTexture;
  30903. private _limitVelocityGradientsTexture;
  30904. private _dragGradientsTexture;
  30905. private _addFactorGradient;
  30906. /**
  30907. * Adds a new size gradient
  30908. * @param gradient defines the gradient to use (between 0 and 1)
  30909. * @param factor defines the size factor to affect to the specified gradient
  30910. * @returns the current particle system
  30911. */
  30912. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  30913. /**
  30914. * Remove a specific size gradient
  30915. * @param gradient defines the gradient to remove
  30916. * @returns the current particle system
  30917. */
  30918. removeSizeGradient(gradient: number): GPUParticleSystem;
  30919. /**
  30920. * Adds a new angular speed gradient
  30921. * @param gradient defines the gradient to use (between 0 and 1)
  30922. * @param factor defines the angular speed to affect to the specified gradient
  30923. * @returns the current particle system
  30924. */
  30925. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  30926. /**
  30927. * Remove a specific angular speed gradient
  30928. * @param gradient defines the gradient to remove
  30929. * @returns the current particle system
  30930. */
  30931. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  30932. /**
  30933. * Adds a new velocity gradient
  30934. * @param gradient defines the gradient to use (between 0 and 1)
  30935. * @param factor defines the velocity to affect to the specified gradient
  30936. * @returns the current particle system
  30937. */
  30938. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30939. /**
  30940. * Remove a specific velocity gradient
  30941. * @param gradient defines the gradient to remove
  30942. * @returns the current particle system
  30943. */
  30944. removeVelocityGradient(gradient: number): GPUParticleSystem;
  30945. /**
  30946. * Adds a new limit velocity gradient
  30947. * @param gradient defines the gradient to use (between 0 and 1)
  30948. * @param factor defines the limit velocity value to affect to the specified gradient
  30949. * @returns the current particle system
  30950. */
  30951. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30952. /**
  30953. * Remove a specific limit velocity gradient
  30954. * @param gradient defines the gradient to remove
  30955. * @returns the current particle system
  30956. */
  30957. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  30958. /**
  30959. * Adds a new drag gradient
  30960. * @param gradient defines the gradient to use (between 0 and 1)
  30961. * @param factor defines the drag value to affect to the specified gradient
  30962. * @returns the current particle system
  30963. */
  30964. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  30965. /**
  30966. * Remove a specific drag gradient
  30967. * @param gradient defines the gradient to remove
  30968. * @returns the current particle system
  30969. */
  30970. removeDragGradient(gradient: number): GPUParticleSystem;
  30971. /**
  30972. * Not supported by GPUParticleSystem
  30973. * @param gradient defines the gradient to use (between 0 and 1)
  30974. * @param factor defines the emit rate value to affect to the specified gradient
  30975. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30976. * @returns the current particle system
  30977. */
  30978. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30979. /**
  30980. * Not supported by GPUParticleSystem
  30981. * @param gradient defines the gradient to remove
  30982. * @returns the current particle system
  30983. */
  30984. removeEmitRateGradient(gradient: number): IParticleSystem;
  30985. /**
  30986. * Not supported by GPUParticleSystem
  30987. * @param gradient defines the gradient to use (between 0 and 1)
  30988. * @param factor defines the start size value to affect to the specified gradient
  30989. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30990. * @returns the current particle system
  30991. */
  30992. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30993. /**
  30994. * Not supported by GPUParticleSystem
  30995. * @param gradient defines the gradient to remove
  30996. * @returns the current particle system
  30997. */
  30998. removeStartSizeGradient(gradient: number): IParticleSystem;
  30999. /**
  31000. * Not supported by GPUParticleSystem
  31001. * @param gradient defines the gradient to use (between 0 and 1)
  31002. * @param min defines the color remap minimal range
  31003. * @param max defines the color remap maximal range
  31004. * @returns the current particle system
  31005. */
  31006. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31007. /**
  31008. * Not supported by GPUParticleSystem
  31009. * @param gradient defines the gradient to remove
  31010. * @returns the current particle system
  31011. */
  31012. removeColorRemapGradient(gradient: number): IParticleSystem;
  31013. /**
  31014. * Not supported by GPUParticleSystem
  31015. * @param gradient defines the gradient to use (between 0 and 1)
  31016. * @param min defines the alpha remap minimal range
  31017. * @param max defines the alpha remap maximal range
  31018. * @returns the current particle system
  31019. */
  31020. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31021. /**
  31022. * Not supported by GPUParticleSystem
  31023. * @param gradient defines the gradient to remove
  31024. * @returns the current particle system
  31025. */
  31026. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  31027. /**
  31028. * Not supported by GPUParticleSystem
  31029. * @param gradient defines the gradient to use (between 0 and 1)
  31030. * @param color defines the color to affect to the specified gradient
  31031. * @returns the current particle system
  31032. */
  31033. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31034. /**
  31035. * Not supported by GPUParticleSystem
  31036. * @param gradient defines the gradient to remove
  31037. * @returns the current particle system
  31038. */
  31039. removeRampGradient(gradient: number): IParticleSystem;
  31040. /**
  31041. * Not supported by GPUParticleSystem
  31042. * @returns the list of ramp gradients
  31043. */
  31044. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31045. /**
  31046. * Not supported by GPUParticleSystem
  31047. * Gets or sets a boolean indicating that ramp gradients must be used
  31048. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31049. */
  31050. useRampGradients: boolean;
  31051. /**
  31052. * Not supported by GPUParticleSystem
  31053. * @param gradient defines the gradient to use (between 0 and 1)
  31054. * @param factor defines the life time factor to affect to the specified gradient
  31055. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31056. * @returns the current particle system
  31057. */
  31058. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31059. /**
  31060. * Not supported by GPUParticleSystem
  31061. * @param gradient defines the gradient to remove
  31062. * @returns the current particle system
  31063. */
  31064. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31065. /**
  31066. * Instantiates a GPU particle system.
  31067. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  31068. * @param name The name of the particle system
  31069. * @param options The options used to create the system
  31070. * @param scene The scene the particle system belongs to
  31071. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  31072. */
  31073. constructor(name: string, options: Partial<{
  31074. capacity: number;
  31075. randomTextureSize: number;
  31076. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  31077. protected _reset(): void;
  31078. private _createUpdateVAO;
  31079. private _createRenderVAO;
  31080. private _initialize;
  31081. /** @hidden */
  31082. _recreateUpdateEffect(): void;
  31083. /** @hidden */
  31084. _recreateRenderEffect(): void;
  31085. /**
  31086. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  31087. * @param preWarm defines if we are in the pre-warmimg phase
  31088. */
  31089. animate(preWarm?: boolean): void;
  31090. private _createFactorGradientTexture;
  31091. private _createSizeGradientTexture;
  31092. private _createAngularSpeedGradientTexture;
  31093. private _createVelocityGradientTexture;
  31094. private _createLimitVelocityGradientTexture;
  31095. private _createDragGradientTexture;
  31096. private _createColorGradientTexture;
  31097. /**
  31098. * Renders the particle system in its current state
  31099. * @param preWarm defines if the system should only update the particles but not render them
  31100. * @returns the current number of particles
  31101. */
  31102. render(preWarm?: boolean): number;
  31103. /**
  31104. * Rebuilds the particle system
  31105. */
  31106. rebuild(): void;
  31107. private _releaseBuffers;
  31108. private _releaseVAOs;
  31109. /**
  31110. * Disposes the particle system and free the associated resources
  31111. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31112. */
  31113. dispose(disposeTexture?: boolean): void;
  31114. /**
  31115. * Clones the particle system.
  31116. * @param name The name of the cloned object
  31117. * @param newEmitter The new emitter to use
  31118. * @returns the cloned particle system
  31119. */
  31120. clone(name: string, newEmitter: any): GPUParticleSystem;
  31121. /**
  31122. * Serializes the particle system to a JSON object.
  31123. * @returns the JSON object
  31124. */
  31125. serialize(): any;
  31126. /**
  31127. * Parses a JSON object to create a GPU particle system.
  31128. * @param parsedParticleSystem The JSON object to parse
  31129. * @param scene The scene to create the particle system in
  31130. * @param rootUrl The root url to use to load external dependencies like texture
  31131. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  31132. * @returns the parsed GPU particle system
  31133. */
  31134. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  31135. }
  31136. }
  31137. declare module BABYLON {
  31138. /**
  31139. * Interface representing a particle system in Babylon.js.
  31140. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  31141. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  31142. */
  31143. interface IParticleSystem {
  31144. /**
  31145. * List of animations used by the particle system.
  31146. */
  31147. animations: Animation[];
  31148. /**
  31149. * The id of the Particle system.
  31150. */
  31151. id: string;
  31152. /**
  31153. * The name of the Particle system.
  31154. */
  31155. name: string;
  31156. /**
  31157. * The emitter represents the Mesh or position we are attaching the particle system to.
  31158. */
  31159. emitter: Nullable<AbstractMesh | Vector3>;
  31160. /**
  31161. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  31162. */
  31163. isBillboardBased: boolean;
  31164. /**
  31165. * The rendering group used by the Particle system to chose when to render.
  31166. */
  31167. renderingGroupId: number;
  31168. /**
  31169. * The layer mask we are rendering the particles through.
  31170. */
  31171. layerMask: number;
  31172. /**
  31173. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  31174. */
  31175. updateSpeed: number;
  31176. /**
  31177. * The amount of time the particle system is running (depends of the overall update speed).
  31178. */
  31179. targetStopDuration: number;
  31180. /**
  31181. * The texture used to render each particle. (this can be a spritesheet)
  31182. */
  31183. particleTexture: Nullable<Texture>;
  31184. /**
  31185. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  31186. */
  31187. blendMode: number;
  31188. /**
  31189. * Minimum life time of emitting particles.
  31190. */
  31191. minLifeTime: number;
  31192. /**
  31193. * Maximum life time of emitting particles.
  31194. */
  31195. maxLifeTime: number;
  31196. /**
  31197. * Minimum Size of emitting particles.
  31198. */
  31199. minSize: number;
  31200. /**
  31201. * Maximum Size of emitting particles.
  31202. */
  31203. maxSize: number;
  31204. /**
  31205. * Minimum scale of emitting particles on X axis.
  31206. */
  31207. minScaleX: number;
  31208. /**
  31209. * Maximum scale of emitting particles on X axis.
  31210. */
  31211. maxScaleX: number;
  31212. /**
  31213. * Minimum scale of emitting particles on Y axis.
  31214. */
  31215. minScaleY: number;
  31216. /**
  31217. * Maximum scale of emitting particles on Y axis.
  31218. */
  31219. maxScaleY: number;
  31220. /**
  31221. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31222. */
  31223. color1: Color4;
  31224. /**
  31225. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31226. */
  31227. color2: Color4;
  31228. /**
  31229. * Color the particle will have at the end of its lifetime.
  31230. */
  31231. colorDead: Color4;
  31232. /**
  31233. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  31234. */
  31235. emitRate: number;
  31236. /**
  31237. * You can use gravity if you want to give an orientation to your particles.
  31238. */
  31239. gravity: Vector3;
  31240. /**
  31241. * Minimum power of emitting particles.
  31242. */
  31243. minEmitPower: number;
  31244. /**
  31245. * Maximum power of emitting particles.
  31246. */
  31247. maxEmitPower: number;
  31248. /**
  31249. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  31250. */
  31251. minAngularSpeed: number;
  31252. /**
  31253. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  31254. */
  31255. maxAngularSpeed: number;
  31256. /**
  31257. * Gets or sets the minimal initial rotation in radians.
  31258. */
  31259. minInitialRotation: number;
  31260. /**
  31261. * Gets or sets the maximal initial rotation in radians.
  31262. */
  31263. maxInitialRotation: number;
  31264. /**
  31265. * The particle emitter type defines the emitter used by the particle system.
  31266. * It can be for example box, sphere, or cone...
  31267. */
  31268. particleEmitterType: Nullable<IParticleEmitterType>;
  31269. /**
  31270. * Defines the delay in milliseconds before starting the system (0 by default)
  31271. */
  31272. startDelay: number;
  31273. /**
  31274. * 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
  31275. */
  31276. preWarmCycles: number;
  31277. /**
  31278. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  31279. */
  31280. preWarmStepOffset: number;
  31281. /**
  31282. * 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)
  31283. */
  31284. spriteCellChangeSpeed: number;
  31285. /**
  31286. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  31287. */
  31288. startSpriteCellID: number;
  31289. /**
  31290. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  31291. */
  31292. endSpriteCellID: number;
  31293. /**
  31294. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  31295. */
  31296. spriteCellWidth: number;
  31297. /**
  31298. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  31299. */
  31300. spriteCellHeight: number;
  31301. /**
  31302. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  31303. */
  31304. spriteRandomStartCell: boolean;
  31305. /**
  31306. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  31307. */
  31308. isAnimationSheetEnabled: boolean;
  31309. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  31310. translationPivot: Vector2;
  31311. /**
  31312. * Gets or sets a texture used to add random noise to particle positions
  31313. */
  31314. noiseTexture: Nullable<BaseTexture>;
  31315. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  31316. noiseStrength: Vector3;
  31317. /**
  31318. * Gets or sets the billboard mode to use when isBillboardBased = true.
  31319. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  31320. */
  31321. billboardMode: number;
  31322. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  31323. limitVelocityDamping: number;
  31324. /**
  31325. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  31326. */
  31327. beginAnimationOnStart: boolean;
  31328. /**
  31329. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  31330. */
  31331. beginAnimationFrom: number;
  31332. /**
  31333. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  31334. */
  31335. beginAnimationTo: number;
  31336. /**
  31337. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  31338. */
  31339. beginAnimationLoop: boolean;
  31340. /**
  31341. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  31342. */
  31343. disposeOnStop: boolean;
  31344. /**
  31345. * Gets the maximum number of particles active at the same time.
  31346. * @returns The max number of active particles.
  31347. */
  31348. getCapacity(): number;
  31349. /**
  31350. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31351. * @returns True if it has been started, otherwise false.
  31352. */
  31353. isStarted(): boolean;
  31354. /**
  31355. * Animates the particle system for this frame.
  31356. */
  31357. animate(): void;
  31358. /**
  31359. * Renders the particle system in its current state.
  31360. * @returns the current number of particles
  31361. */
  31362. render(): number;
  31363. /**
  31364. * Dispose the particle system and frees its associated resources.
  31365. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31366. */
  31367. dispose(disposeTexture?: boolean): void;
  31368. /**
  31369. * Clones the particle system.
  31370. * @param name The name of the cloned object
  31371. * @param newEmitter The new emitter to use
  31372. * @returns the cloned particle system
  31373. */
  31374. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  31375. /**
  31376. * Serializes the particle system to a JSON object.
  31377. * @returns the JSON object
  31378. */
  31379. serialize(): any;
  31380. /**
  31381. * Rebuild the particle system
  31382. */
  31383. rebuild(): void;
  31384. /**
  31385. * Starts the particle system and begins to emit
  31386. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  31387. */
  31388. start(delay?: number): void;
  31389. /**
  31390. * Stops the particle system.
  31391. */
  31392. stop(): void;
  31393. /**
  31394. * Remove all active particles
  31395. */
  31396. reset(): void;
  31397. /**
  31398. * Is this system ready to be used/rendered
  31399. * @return true if the system is ready
  31400. */
  31401. isReady(): boolean;
  31402. /**
  31403. * Adds a new color gradient
  31404. * @param gradient defines the gradient to use (between 0 and 1)
  31405. * @param color1 defines the color to affect to the specified gradient
  31406. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31407. * @returns the current particle system
  31408. */
  31409. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  31410. /**
  31411. * Remove a specific color gradient
  31412. * @param gradient defines the gradient to remove
  31413. * @returns the current particle system
  31414. */
  31415. removeColorGradient(gradient: number): IParticleSystem;
  31416. /**
  31417. * Adds a new size gradient
  31418. * @param gradient defines the gradient to use (between 0 and 1)
  31419. * @param factor defines the size factor to affect to the specified gradient
  31420. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31421. * @returns the current particle system
  31422. */
  31423. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31424. /**
  31425. * Remove a specific size gradient
  31426. * @param gradient defines the gradient to remove
  31427. * @returns the current particle system
  31428. */
  31429. removeSizeGradient(gradient: number): IParticleSystem;
  31430. /**
  31431. * Gets the current list of color gradients.
  31432. * You must use addColorGradient and removeColorGradient to udpate this list
  31433. * @returns the list of color gradients
  31434. */
  31435. getColorGradients(): Nullable<Array<ColorGradient>>;
  31436. /**
  31437. * Gets the current list of size gradients.
  31438. * You must use addSizeGradient and removeSizeGradient to udpate this list
  31439. * @returns the list of size gradients
  31440. */
  31441. getSizeGradients(): Nullable<Array<FactorGradient>>;
  31442. /**
  31443. * Gets the current list of angular speed gradients.
  31444. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  31445. * @returns the list of angular speed gradients
  31446. */
  31447. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  31448. /**
  31449. * Adds a new angular speed gradient
  31450. * @param gradient defines the gradient to use (between 0 and 1)
  31451. * @param factor defines the angular speed to affect to the specified gradient
  31452. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31453. * @returns the current particle system
  31454. */
  31455. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31456. /**
  31457. * Remove a specific angular speed gradient
  31458. * @param gradient defines the gradient to remove
  31459. * @returns the current particle system
  31460. */
  31461. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31462. /**
  31463. * Gets the current list of velocity gradients.
  31464. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  31465. * @returns the list of velocity gradients
  31466. */
  31467. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  31468. /**
  31469. * Adds a new velocity gradient
  31470. * @param gradient defines the gradient to use (between 0 and 1)
  31471. * @param factor defines the velocity to affect to the specified gradient
  31472. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31473. * @returns the current particle system
  31474. */
  31475. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31476. /**
  31477. * Remove a specific velocity gradient
  31478. * @param gradient defines the gradient to remove
  31479. * @returns the current particle system
  31480. */
  31481. removeVelocityGradient(gradient: number): IParticleSystem;
  31482. /**
  31483. * Gets the current list of limit velocity gradients.
  31484. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  31485. * @returns the list of limit velocity gradients
  31486. */
  31487. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  31488. /**
  31489. * Adds a new limit velocity gradient
  31490. * @param gradient defines the gradient to use (between 0 and 1)
  31491. * @param factor defines the limit velocity to affect to the specified gradient
  31492. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31493. * @returns the current particle system
  31494. */
  31495. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31496. /**
  31497. * Remove a specific limit velocity gradient
  31498. * @param gradient defines the gradient to remove
  31499. * @returns the current particle system
  31500. */
  31501. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31502. /**
  31503. * Adds a new drag gradient
  31504. * @param gradient defines the gradient to use (between 0 and 1)
  31505. * @param factor defines the drag to affect to the specified gradient
  31506. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31507. * @returns the current particle system
  31508. */
  31509. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31510. /**
  31511. * Remove a specific drag gradient
  31512. * @param gradient defines the gradient to remove
  31513. * @returns the current particle system
  31514. */
  31515. removeDragGradient(gradient: number): IParticleSystem;
  31516. /**
  31517. * Gets the current list of drag gradients.
  31518. * You must use addDragGradient and removeDragGradient to udpate this list
  31519. * @returns the list of drag gradients
  31520. */
  31521. getDragGradients(): Nullable<Array<FactorGradient>>;
  31522. /**
  31523. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31524. * @param gradient defines the gradient to use (between 0 and 1)
  31525. * @param factor defines the emit rate to affect to the specified gradient
  31526. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31527. * @returns the current particle system
  31528. */
  31529. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31530. /**
  31531. * Remove a specific emit rate gradient
  31532. * @param gradient defines the gradient to remove
  31533. * @returns the current particle system
  31534. */
  31535. removeEmitRateGradient(gradient: number): IParticleSystem;
  31536. /**
  31537. * Gets the current list of emit rate gradients.
  31538. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  31539. * @returns the list of emit rate gradients
  31540. */
  31541. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  31542. /**
  31543. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31544. * @param gradient defines the gradient to use (between 0 and 1)
  31545. * @param factor defines the start size to affect to the specified gradient
  31546. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31547. * @returns the current particle system
  31548. */
  31549. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31550. /**
  31551. * Remove a specific start size gradient
  31552. * @param gradient defines the gradient to remove
  31553. * @returns the current particle system
  31554. */
  31555. removeStartSizeGradient(gradient: number): IParticleSystem;
  31556. /**
  31557. * Gets the current list of start size gradients.
  31558. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  31559. * @returns the list of start size gradients
  31560. */
  31561. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  31562. /**
  31563. * Adds a new life time gradient
  31564. * @param gradient defines the gradient to use (between 0 and 1)
  31565. * @param factor defines the life time factor to affect to the specified gradient
  31566. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31567. * @returns the current particle system
  31568. */
  31569. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31570. /**
  31571. * Remove a specific life time gradient
  31572. * @param gradient defines the gradient to remove
  31573. * @returns the current particle system
  31574. */
  31575. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31576. /**
  31577. * Gets the current list of life time gradients.
  31578. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  31579. * @returns the list of life time gradients
  31580. */
  31581. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  31582. /**
  31583. * Gets the current list of color gradients.
  31584. * You must use addColorGradient and removeColorGradient to udpate this list
  31585. * @returns the list of color gradients
  31586. */
  31587. getColorGradients(): Nullable<Array<ColorGradient>>;
  31588. /**
  31589. * Adds a new ramp gradient used to remap particle colors
  31590. * @param gradient defines the gradient to use (between 0 and 1)
  31591. * @param color defines the color to affect to the specified gradient
  31592. * @returns the current particle system
  31593. */
  31594. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31595. /**
  31596. * Gets the current list of ramp gradients.
  31597. * You must use addRampGradient and removeRampGradient to udpate this list
  31598. * @returns the list of ramp gradients
  31599. */
  31600. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31601. /** Gets or sets a boolean indicating that ramp gradients must be used
  31602. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31603. */
  31604. useRampGradients: boolean;
  31605. /**
  31606. * Adds a new color remap gradient
  31607. * @param gradient defines the gradient to use (between 0 and 1)
  31608. * @param min defines the color remap minimal range
  31609. * @param max defines the color remap maximal range
  31610. * @returns the current particle system
  31611. */
  31612. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31613. /**
  31614. * Gets the current list of color remap gradients.
  31615. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  31616. * @returns the list of color remap gradients
  31617. */
  31618. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  31619. /**
  31620. * Adds a new alpha remap gradient
  31621. * @param gradient defines the gradient to use (between 0 and 1)
  31622. * @param min defines the alpha remap minimal range
  31623. * @param max defines the alpha remap maximal range
  31624. * @returns the current particle system
  31625. */
  31626. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31627. /**
  31628. * Gets the current list of alpha remap gradients.
  31629. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  31630. * @returns the list of alpha remap gradients
  31631. */
  31632. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  31633. /**
  31634. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  31635. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31636. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31637. * @returns the emitter
  31638. */
  31639. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  31640. /**
  31641. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  31642. * @param radius The radius of the hemisphere to emit from
  31643. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31644. * @returns the emitter
  31645. */
  31646. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  31647. /**
  31648. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  31649. * @param radius The radius of the sphere to emit from
  31650. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31651. * @returns the emitter
  31652. */
  31653. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  31654. /**
  31655. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  31656. * @param radius The radius of the sphere to emit from
  31657. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  31658. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  31659. * @returns the emitter
  31660. */
  31661. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31662. /**
  31663. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  31664. * @param radius The radius of the emission cylinder
  31665. * @param height The height of the emission cylinder
  31666. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  31667. * @param directionRandomizer How much to randomize the particle direction [0-1]
  31668. * @returns the emitter
  31669. */
  31670. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  31671. /**
  31672. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  31673. * @param radius The radius of the cylinder to emit from
  31674. * @param height The height of the emission cylinder
  31675. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  31676. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  31677. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  31678. * @returns the emitter
  31679. */
  31680. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31681. /**
  31682. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  31683. * @param radius The radius of the cone to emit from
  31684. * @param angle The base angle of the cone
  31685. * @returns the emitter
  31686. */
  31687. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  31688. /**
  31689. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  31690. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31691. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31692. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31693. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31694. * @returns the emitter
  31695. */
  31696. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  31697. /**
  31698. * Get hosting scene
  31699. * @returns the scene
  31700. */
  31701. getScene(): Scene;
  31702. }
  31703. }
  31704. declare module BABYLON {
  31705. /**
  31706. * A particle represents one of the element emitted by a particle system.
  31707. * This is mainly define by its coordinates, direction, velocity and age.
  31708. */
  31709. class Particle {
  31710. /**
  31711. * The particle system the particle belongs to.
  31712. */
  31713. particleSystem: ParticleSystem;
  31714. private static _Count;
  31715. /**
  31716. * Unique ID of the particle
  31717. */
  31718. id: number;
  31719. /**
  31720. * The world position of the particle in the scene.
  31721. */
  31722. position: Vector3;
  31723. /**
  31724. * The world direction of the particle in the scene.
  31725. */
  31726. direction: Vector3;
  31727. /**
  31728. * The color of the particle.
  31729. */
  31730. color: Color4;
  31731. /**
  31732. * The color change of the particle per step.
  31733. */
  31734. colorStep: Color4;
  31735. /**
  31736. * Defines how long will the life of the particle be.
  31737. */
  31738. lifeTime: number;
  31739. /**
  31740. * The current age of the particle.
  31741. */
  31742. age: number;
  31743. /**
  31744. * The current size of the particle.
  31745. */
  31746. size: number;
  31747. /**
  31748. * The current scale of the particle.
  31749. */
  31750. scale: Vector2;
  31751. /**
  31752. * The current angle of the particle.
  31753. */
  31754. angle: number;
  31755. /**
  31756. * Defines how fast is the angle changing.
  31757. */
  31758. angularSpeed: number;
  31759. /**
  31760. * Defines the cell index used by the particle to be rendered from a sprite.
  31761. */
  31762. cellIndex: number;
  31763. /**
  31764. * The information required to support color remapping
  31765. */
  31766. remapData: Vector4;
  31767. /** @hidden */
  31768. _randomCellOffset?: number;
  31769. /** @hidden */
  31770. _initialDirection: Nullable<Vector3>;
  31771. /** @hidden */
  31772. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  31773. /** @hidden */
  31774. _initialStartSpriteCellID: number;
  31775. /** @hidden */
  31776. _initialEndSpriteCellID: number;
  31777. /** @hidden */
  31778. _currentColorGradient: Nullable<ColorGradient>;
  31779. /** @hidden */
  31780. _currentColor1: Color4;
  31781. /** @hidden */
  31782. _currentColor2: Color4;
  31783. /** @hidden */
  31784. _currentSizeGradient: Nullable<FactorGradient>;
  31785. /** @hidden */
  31786. _currentSize1: number;
  31787. /** @hidden */
  31788. _currentSize2: number;
  31789. /** @hidden */
  31790. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  31791. /** @hidden */
  31792. _currentAngularSpeed1: number;
  31793. /** @hidden */
  31794. _currentAngularSpeed2: number;
  31795. /** @hidden */
  31796. _currentVelocityGradient: Nullable<FactorGradient>;
  31797. /** @hidden */
  31798. _currentVelocity1: number;
  31799. /** @hidden */
  31800. _currentVelocity2: number;
  31801. /** @hidden */
  31802. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  31803. /** @hidden */
  31804. _currentLimitVelocity1: number;
  31805. /** @hidden */
  31806. _currentLimitVelocity2: number;
  31807. /** @hidden */
  31808. _currentDragGradient: Nullable<FactorGradient>;
  31809. /** @hidden */
  31810. _currentDrag1: number;
  31811. /** @hidden */
  31812. _currentDrag2: number;
  31813. /** @hidden */
  31814. _randomNoiseCoordinates1: Vector3;
  31815. /** @hidden */
  31816. _randomNoiseCoordinates2: Vector3;
  31817. /**
  31818. * Creates a new instance Particle
  31819. * @param particleSystem the particle system the particle belongs to
  31820. */
  31821. constructor(
  31822. /**
  31823. * The particle system the particle belongs to.
  31824. */
  31825. particleSystem: ParticleSystem);
  31826. private updateCellInfoFromSystem;
  31827. /**
  31828. * Defines how the sprite cell index is updated for the particle
  31829. */
  31830. updateCellIndex(): void;
  31831. /** @hidden */
  31832. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  31833. /** @hidden */
  31834. _inheritParticleInfoToSubEmitters(): void;
  31835. /** @hidden */
  31836. _reset(): void;
  31837. /**
  31838. * Copy the properties of particle to another one.
  31839. * @param other the particle to copy the information to.
  31840. */
  31841. copyTo(other: Particle): void;
  31842. }
  31843. }
  31844. declare module BABYLON {
  31845. /**
  31846. * This class is made for on one-liner static method to help creating particle system set.
  31847. */
  31848. class ParticleHelper {
  31849. /**
  31850. * Gets or sets base Assets URL
  31851. */
  31852. static BaseAssetsUrl: string;
  31853. /**
  31854. * Create a default particle system that you can tweak
  31855. * @param emitter defines the emitter to use
  31856. * @param capacity defines the system capacity (default is 500 particles)
  31857. * @param scene defines the hosting scene
  31858. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  31859. * @returns the new Particle system
  31860. */
  31861. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  31862. /**
  31863. * This is the main static method (one-liner) of this helper to create different particle systems
  31864. * @param type This string represents the type to the particle system to create
  31865. * @param scene The scene where the particle system should live
  31866. * @param gpu If the system will use gpu
  31867. * @returns the ParticleSystemSet created
  31868. */
  31869. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  31870. /**
  31871. * Static function used to export a particle system to a ParticleSystemSet variable.
  31872. * Please note that the emitter shape is not exported
  31873. * @param systems defines the particle systems to export
  31874. * @returns the created particle system set
  31875. */
  31876. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  31877. }
  31878. }
  31879. declare module BABYLON {
  31880. /**
  31881. * This represents a particle system in Babylon.
  31882. * 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.
  31883. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  31884. * @example https://doc.babylonjs.com/babylon101/particles
  31885. */
  31886. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  31887. /**
  31888. * Billboard mode will only apply to Y axis
  31889. */
  31890. static readonly BILLBOARDMODE_Y: number;
  31891. /**
  31892. * Billboard mode will apply to all axes
  31893. */
  31894. static readonly BILLBOARDMODE_ALL: number;
  31895. /**
  31896. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  31897. */
  31898. static readonly BILLBOARDMODE_STRETCHED: number;
  31899. /**
  31900. * This function can be defined to provide custom update for active particles.
  31901. * This function will be called instead of regular update (age, position, color, etc.).
  31902. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  31903. */
  31904. updateFunction: (particles: Particle[]) => void;
  31905. private _emitterWorldMatrix;
  31906. /**
  31907. * This function can be defined to specify initial direction for every new particle.
  31908. * It by default use the emitterType defined function
  31909. */
  31910. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  31911. /**
  31912. * This function can be defined to specify initial position for every new particle.
  31913. * It by default use the emitterType defined function
  31914. */
  31915. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  31916. /**
  31917. * @hidden
  31918. */
  31919. _inheritedVelocityOffset: Vector3;
  31920. /**
  31921. * An event triggered when the system is disposed
  31922. */
  31923. onDisposeObservable: Observable<ParticleSystem>;
  31924. private _onDisposeObserver;
  31925. /**
  31926. * Sets a callback that will be triggered when the system is disposed
  31927. */
  31928. onDispose: () => void;
  31929. private _particles;
  31930. private _epsilon;
  31931. private _capacity;
  31932. private _stockParticles;
  31933. private _newPartsExcess;
  31934. private _vertexData;
  31935. private _vertexBuffer;
  31936. private _vertexBuffers;
  31937. private _spriteBuffer;
  31938. private _indexBuffer;
  31939. private _effect;
  31940. private _customEffect;
  31941. private _cachedDefines;
  31942. private _scaledColorStep;
  31943. private _colorDiff;
  31944. private _scaledDirection;
  31945. private _scaledGravity;
  31946. private _currentRenderId;
  31947. private _alive;
  31948. private _useInstancing;
  31949. private _started;
  31950. private _stopped;
  31951. private _actualFrame;
  31952. private _scaledUpdateSpeed;
  31953. private _vertexBufferSize;
  31954. /** @hidden */
  31955. _currentEmitRateGradient: Nullable<FactorGradient>;
  31956. /** @hidden */
  31957. _currentEmitRate1: number;
  31958. /** @hidden */
  31959. _currentEmitRate2: number;
  31960. /** @hidden */
  31961. _currentStartSizeGradient: Nullable<FactorGradient>;
  31962. /** @hidden */
  31963. _currentStartSize1: number;
  31964. /** @hidden */
  31965. _currentStartSize2: number;
  31966. private readonly _rawTextureWidth;
  31967. private _rampGradientsTexture;
  31968. private _useRampGradients;
  31969. /** Gets or sets a boolean indicating that ramp gradients must be used
  31970. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31971. */
  31972. useRampGradients: boolean;
  31973. /**
  31974. * 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.
  31975. * 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: [])
  31976. */
  31977. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  31978. private _subEmitters;
  31979. /**
  31980. * @hidden
  31981. * If the particle systems emitter should be disposed when the particle system is disposed
  31982. */
  31983. _disposeEmitterOnDispose: boolean;
  31984. /**
  31985. * The current active Sub-systems, this property is used by the root particle system only.
  31986. */
  31987. activeSubSystems: Array<ParticleSystem>;
  31988. private _rootParticleSystem;
  31989. /**
  31990. * Gets the current list of active particles
  31991. */
  31992. readonly particles: Particle[];
  31993. /**
  31994. * Returns the string "ParticleSystem"
  31995. * @returns a string containing the class name
  31996. */
  31997. getClassName(): string;
  31998. /**
  31999. * Instantiates a particle system.
  32000. * 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.
  32001. * @param name The name of the particle system
  32002. * @param capacity The max number of particles alive at the same time
  32003. * @param scene The scene the particle system belongs to
  32004. * @param customEffect a custom effect used to change the way particles are rendered by default
  32005. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  32006. * @param epsilon Offset used to render the particles
  32007. */
  32008. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  32009. private _addFactorGradient;
  32010. private _removeFactorGradient;
  32011. /**
  32012. * Adds a new life time gradient
  32013. * @param gradient defines the gradient to use (between 0 and 1)
  32014. * @param factor defines the life time factor to affect to the specified gradient
  32015. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32016. * @returns the current particle system
  32017. */
  32018. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32019. /**
  32020. * Remove a specific life time gradient
  32021. * @param gradient defines the gradient to remove
  32022. * @returns the current particle system
  32023. */
  32024. removeLifeTimeGradient(gradient: number): IParticleSystem;
  32025. /**
  32026. * Adds a new size gradient
  32027. * @param gradient defines the gradient to use (between 0 and 1)
  32028. * @param factor defines the size factor to affect to the specified gradient
  32029. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32030. * @returns the current particle system
  32031. */
  32032. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32033. /**
  32034. * Remove a specific size gradient
  32035. * @param gradient defines the gradient to remove
  32036. * @returns the current particle system
  32037. */
  32038. removeSizeGradient(gradient: number): IParticleSystem;
  32039. /**
  32040. * Adds a new color remap gradient
  32041. * @param gradient defines the gradient to use (between 0 and 1)
  32042. * @param min defines the color remap minimal range
  32043. * @param max defines the color remap maximal range
  32044. * @returns the current particle system
  32045. */
  32046. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32047. /**
  32048. * Remove a specific color remap gradient
  32049. * @param gradient defines the gradient to remove
  32050. * @returns the current particle system
  32051. */
  32052. removeColorRemapGradient(gradient: number): IParticleSystem;
  32053. /**
  32054. * Adds a new alpha remap gradient
  32055. * @param gradient defines the gradient to use (between 0 and 1)
  32056. * @param min defines the alpha remap minimal range
  32057. * @param max defines the alpha remap maximal range
  32058. * @returns the current particle system
  32059. */
  32060. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  32061. /**
  32062. * Remove a specific alpha remap gradient
  32063. * @param gradient defines the gradient to remove
  32064. * @returns the current particle system
  32065. */
  32066. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  32067. /**
  32068. * Adds a new angular speed gradient
  32069. * @param gradient defines the gradient to use (between 0 and 1)
  32070. * @param factor defines the angular speed to affect to the specified gradient
  32071. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32072. * @returns the current particle system
  32073. */
  32074. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32075. /**
  32076. * Remove a specific angular speed gradient
  32077. * @param gradient defines the gradient to remove
  32078. * @returns the current particle system
  32079. */
  32080. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  32081. /**
  32082. * Adds a new velocity gradient
  32083. * @param gradient defines the gradient to use (between 0 and 1)
  32084. * @param factor defines the velocity to affect to the specified gradient
  32085. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32086. * @returns the current particle system
  32087. */
  32088. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32089. /**
  32090. * Remove a specific velocity gradient
  32091. * @param gradient defines the gradient to remove
  32092. * @returns the current particle system
  32093. */
  32094. removeVelocityGradient(gradient: number): IParticleSystem;
  32095. /**
  32096. * Adds a new limit velocity gradient
  32097. * @param gradient defines the gradient to use (between 0 and 1)
  32098. * @param factor defines the limit velocity value to affect to the specified gradient
  32099. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32100. * @returns the current particle system
  32101. */
  32102. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32103. /**
  32104. * Remove a specific limit velocity gradient
  32105. * @param gradient defines the gradient to remove
  32106. * @returns the current particle system
  32107. */
  32108. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  32109. /**
  32110. * Adds a new drag gradient
  32111. * @param gradient defines the gradient to use (between 0 and 1)
  32112. * @param factor defines the drag value to affect to the specified gradient
  32113. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32114. * @returns the current particle system
  32115. */
  32116. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32117. /**
  32118. * Remove a specific drag gradient
  32119. * @param gradient defines the gradient to remove
  32120. * @returns the current particle system
  32121. */
  32122. removeDragGradient(gradient: number): IParticleSystem;
  32123. /**
  32124. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  32125. * @param gradient defines the gradient to use (between 0 and 1)
  32126. * @param factor defines the emit rate value to affect to the specified gradient
  32127. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32128. * @returns the current particle system
  32129. */
  32130. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32131. /**
  32132. * Remove a specific emit rate gradient
  32133. * @param gradient defines the gradient to remove
  32134. * @returns the current particle system
  32135. */
  32136. removeEmitRateGradient(gradient: number): IParticleSystem;
  32137. /**
  32138. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  32139. * @param gradient defines the gradient to use (between 0 and 1)
  32140. * @param factor defines the start size value to affect to the specified gradient
  32141. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  32142. * @returns the current particle system
  32143. */
  32144. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  32145. /**
  32146. * Remove a specific start size gradient
  32147. * @param gradient defines the gradient to remove
  32148. * @returns the current particle system
  32149. */
  32150. removeStartSizeGradient(gradient: number): IParticleSystem;
  32151. private _createRampGradientTexture;
  32152. /**
  32153. * Gets the current list of ramp gradients.
  32154. * You must use addRampGradient and removeRampGradient to udpate this list
  32155. * @returns the list of ramp gradients
  32156. */
  32157. getRampGradients(): Nullable<Array<Color3Gradient>>;
  32158. /**
  32159. * Adds a new ramp gradient used to remap particle colors
  32160. * @param gradient defines the gradient to use (between 0 and 1)
  32161. * @param color defines the color to affect to the specified gradient
  32162. * @returns the current particle system
  32163. */
  32164. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  32165. /**
  32166. * Remove a specific ramp gradient
  32167. * @param gradient defines the gradient to remove
  32168. * @returns the current particle system
  32169. */
  32170. removeRampGradient(gradient: number): ParticleSystem;
  32171. /**
  32172. * Adds a new color gradient
  32173. * @param gradient defines the gradient to use (between 0 and 1)
  32174. * @param color1 defines the color to affect to the specified gradient
  32175. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  32176. * @returns this particle system
  32177. */
  32178. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  32179. /**
  32180. * Remove a specific color gradient
  32181. * @param gradient defines the gradient to remove
  32182. * @returns this particle system
  32183. */
  32184. removeColorGradient(gradient: number): IParticleSystem;
  32185. private _fetchR;
  32186. protected _reset(): void;
  32187. private _resetEffect;
  32188. private _createVertexBuffers;
  32189. private _createIndexBuffer;
  32190. /**
  32191. * Gets the maximum number of particles active at the same time.
  32192. * @returns The max number of active particles.
  32193. */
  32194. getCapacity(): number;
  32195. /**
  32196. * Gets whether there are still active particles in the system.
  32197. * @returns True if it is alive, otherwise false.
  32198. */
  32199. isAlive(): boolean;
  32200. /**
  32201. * Gets if the system has been started. (Note: this will still be true after stop is called)
  32202. * @returns True if it has been started, otherwise false.
  32203. */
  32204. isStarted(): boolean;
  32205. private _prepareSubEmitterInternalArray;
  32206. /**
  32207. * Starts the particle system and begins to emit
  32208. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  32209. */
  32210. start(delay?: number): void;
  32211. /**
  32212. * Stops the particle system.
  32213. * @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.
  32214. */
  32215. stop(stopSubEmitters?: boolean): void;
  32216. /**
  32217. * Remove all active particles
  32218. */
  32219. reset(): void;
  32220. /**
  32221. * @hidden (for internal use only)
  32222. */
  32223. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  32224. /**
  32225. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  32226. * Its lifetime will start back at 0.
  32227. */
  32228. recycleParticle: (particle: Particle) => void;
  32229. private _stopSubEmitters;
  32230. private _createParticle;
  32231. private _removeFromRoot;
  32232. private _emitFromParticle;
  32233. private _update;
  32234. /** @hidden */
  32235. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  32236. /** @hidden */
  32237. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  32238. /** @hidden */
  32239. private _getEffect;
  32240. /**
  32241. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  32242. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  32243. */
  32244. animate(preWarmOnly?: boolean): void;
  32245. private _appendParticleVertices;
  32246. /**
  32247. * Rebuilds the particle system.
  32248. */
  32249. rebuild(): void;
  32250. /**
  32251. * Is this system ready to be used/rendered
  32252. * @return true if the system is ready
  32253. */
  32254. isReady(): boolean;
  32255. private _render;
  32256. /**
  32257. * Renders the particle system in its current state.
  32258. * @returns the current number of particles
  32259. */
  32260. render(): number;
  32261. /**
  32262. * Disposes the particle system and free the associated resources
  32263. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32264. */
  32265. dispose(disposeTexture?: boolean): void;
  32266. /**
  32267. * Clones the particle system.
  32268. * @param name The name of the cloned object
  32269. * @param newEmitter The new emitter to use
  32270. * @returns the cloned particle system
  32271. */
  32272. clone(name: string, newEmitter: any): ParticleSystem;
  32273. /**
  32274. * Serializes the particle system to a JSON object.
  32275. * @returns the JSON object
  32276. */
  32277. serialize(): any;
  32278. /** @hidden */
  32279. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  32280. /** @hidden */
  32281. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  32282. /**
  32283. * Parses a JSON object to create a particle system.
  32284. * @param parsedParticleSystem The JSON object to parse
  32285. * @param scene The scene to create the particle system in
  32286. * @param rootUrl The root url to use to load external dependencies like texture
  32287. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  32288. * @returns the Parsed particle system
  32289. */
  32290. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  32291. }
  32292. }
  32293. declare module BABYLON {
  32294. interface Engine {
  32295. /**
  32296. * Create an effect to use with particle systems.
  32297. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  32298. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  32299. * @param uniformsNames defines a list of attribute names
  32300. * @param samplers defines an array of string used to represent textures
  32301. * @param defines defines the string containing the defines to use to compile the shaders
  32302. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32303. * @param onCompiled defines a function to call when the effect creation is successful
  32304. * @param onError defines a function to call when the effect creation has failed
  32305. * @returns the new Effect
  32306. */
  32307. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  32308. }
  32309. interface Mesh {
  32310. /**
  32311. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  32312. * @returns an array of IParticleSystem
  32313. */
  32314. getEmittedParticleSystems(): IParticleSystem[];
  32315. /**
  32316. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  32317. * @returns an array of IParticleSystem
  32318. */
  32319. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  32320. }
  32321. }
  32322. declare module BABYLON {
  32323. /**
  32324. * Represents a set of particle systems working together to create a specific effect
  32325. */
  32326. class ParticleSystemSet implements IDisposable {
  32327. private _emitterCreationOptions;
  32328. private _emitterNode;
  32329. /**
  32330. * Gets the particle system list
  32331. */
  32332. systems: IParticleSystem[];
  32333. /**
  32334. * Gets the emitter node used with this set
  32335. */
  32336. readonly emitterNode: Nullable<TransformNode>;
  32337. /**
  32338. * Creates a new emitter mesh as a sphere
  32339. * @param options defines the options used to create the sphere
  32340. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  32341. * @param scene defines the hosting scene
  32342. */
  32343. setEmitterAsSphere(options: {
  32344. diameter: number;
  32345. segments: number;
  32346. color: Color3;
  32347. }, renderingGroupId: number, scene: Scene): void;
  32348. /**
  32349. * Starts all particle systems of the set
  32350. * @param emitter defines an optional mesh to use as emitter for the particle systems
  32351. */
  32352. start(emitter?: AbstractMesh): void;
  32353. /**
  32354. * Release all associated resources
  32355. */
  32356. dispose(): void;
  32357. /**
  32358. * Serialize the set into a JSON compatible object
  32359. * @returns a JSON compatible representation of the set
  32360. */
  32361. serialize(): any;
  32362. /**
  32363. * Parse a new ParticleSystemSet from a serialized source
  32364. * @param data defines a JSON compatible representation of the set
  32365. * @param scene defines the hosting scene
  32366. * @param gpu defines if we want GPU particles or CPU particles
  32367. * @returns a new ParticleSystemSet
  32368. */
  32369. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  32370. }
  32371. }
  32372. declare module BABYLON {
  32373. /**
  32374. * Represents one particle of a solid particle system.
  32375. */
  32376. class SolidParticle {
  32377. /**
  32378. * particle global index
  32379. */
  32380. idx: number;
  32381. /**
  32382. * The color of the particle
  32383. */
  32384. color: Nullable<Color4>;
  32385. /**
  32386. * The world space position of the particle.
  32387. */
  32388. position: Vector3;
  32389. /**
  32390. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32391. */
  32392. rotation: Vector3;
  32393. /**
  32394. * The world space rotation quaternion of the particle.
  32395. */
  32396. rotationQuaternion: Nullable<Quaternion>;
  32397. /**
  32398. * The scaling of the particle.
  32399. */
  32400. scaling: Vector3;
  32401. /**
  32402. * The uvs of the particle.
  32403. */
  32404. uvs: Vector4;
  32405. /**
  32406. * The current speed of the particle.
  32407. */
  32408. velocity: Vector3;
  32409. /**
  32410. * The pivot point in the particle local space.
  32411. */
  32412. pivot: Vector3;
  32413. /**
  32414. * Must the particle be translated from its pivot point in its local space ?
  32415. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32416. * Default : false
  32417. */
  32418. translateFromPivot: boolean;
  32419. /**
  32420. * Is the particle active or not ?
  32421. */
  32422. alive: boolean;
  32423. /**
  32424. * Is the particle visible or not ?
  32425. */
  32426. isVisible: boolean;
  32427. /**
  32428. * Index of this particle in the global "positions" array (Internal use)
  32429. * @hidden
  32430. */
  32431. _pos: number;
  32432. /**
  32433. * @hidden Index of this particle in the global "indices" array (Internal use)
  32434. */
  32435. _ind: number;
  32436. /**
  32437. * @hidden ModelShape of this particle (Internal use)
  32438. */
  32439. _model: ModelShape;
  32440. /**
  32441. * ModelShape id of this particle
  32442. */
  32443. shapeId: number;
  32444. /**
  32445. * Index of the particle in its shape id (Internal use)
  32446. */
  32447. idxInShape: number;
  32448. /**
  32449. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32450. */
  32451. _modelBoundingInfo: BoundingInfo;
  32452. /**
  32453. * @hidden Particle BoundingInfo object (Internal use)
  32454. */
  32455. _boundingInfo: BoundingInfo;
  32456. /**
  32457. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32458. */
  32459. _sps: SolidParticleSystem;
  32460. /**
  32461. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32462. */
  32463. _stillInvisible: boolean;
  32464. /**
  32465. * @hidden Last computed particle rotation matrix
  32466. */
  32467. _rotationMatrix: number[];
  32468. /**
  32469. * Parent particle Id, if any.
  32470. * Default null.
  32471. */
  32472. parentId: Nullable<number>;
  32473. /**
  32474. * @hidden Internal global position in the SPS.
  32475. */
  32476. _globalPosition: Vector3;
  32477. /**
  32478. * Creates a Solid Particle object.
  32479. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32480. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  32481. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32482. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32483. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32484. * @param shapeId (integer) is the model shape identifier in the SPS.
  32485. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32486. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32487. */
  32488. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  32489. /**
  32490. * Legacy support, changed scale to scaling
  32491. */
  32492. /**
  32493. * Legacy support, changed scale to scaling
  32494. */
  32495. scale: Vector3;
  32496. /**
  32497. * Legacy support, changed quaternion to rotationQuaternion
  32498. */
  32499. /**
  32500. * Legacy support, changed quaternion to rotationQuaternion
  32501. */
  32502. quaternion: Nullable<Quaternion>;
  32503. /**
  32504. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32505. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32506. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32507. * @returns true if it intersects
  32508. */
  32509. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32510. /**
  32511. * get the rotation matrix of the particle
  32512. * @hidden
  32513. */
  32514. getRotationMatrix(m: Matrix): void;
  32515. }
  32516. /**
  32517. * Represents the shape of the model used by one particle of a solid particle system.
  32518. * SPS internal tool, don't use it manually.
  32519. */
  32520. class ModelShape {
  32521. /**
  32522. * The shape id
  32523. * @hidden
  32524. */
  32525. shapeID: number;
  32526. /**
  32527. * flat array of model positions (internal use)
  32528. * @hidden
  32529. */
  32530. _shape: Vector3[];
  32531. /**
  32532. * flat array of model UVs (internal use)
  32533. * @hidden
  32534. */
  32535. _shapeUV: number[];
  32536. /**
  32537. * length of the shape in the model indices array (internal use)
  32538. * @hidden
  32539. */
  32540. _indicesLength: number;
  32541. /**
  32542. * Custom position function (internal use)
  32543. * @hidden
  32544. */
  32545. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32546. /**
  32547. * Custom vertex function (internal use)
  32548. * @hidden
  32549. */
  32550. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32551. /**
  32552. * 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.
  32553. * SPS internal tool, don't use it manually.
  32554. * @hidden
  32555. */
  32556. 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>);
  32557. }
  32558. /**
  32559. * Represents a Depth Sorted Particle in the solid particle system.
  32560. */
  32561. class DepthSortedParticle {
  32562. /**
  32563. * Index of the particle in the "indices" array
  32564. */
  32565. ind: number;
  32566. /**
  32567. * Length of the particle shape in the "indices" array
  32568. */
  32569. indicesLength: number;
  32570. /**
  32571. * Squared distance from the particle to the camera
  32572. */
  32573. sqDistance: number;
  32574. }
  32575. }
  32576. declare module BABYLON {
  32577. /**
  32578. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32579. *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.
  32580. * The SPS is also a particle system. It provides some methods to manage the particles.
  32581. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32582. *
  32583. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  32584. */
  32585. class SolidParticleSystem implements IDisposable {
  32586. /**
  32587. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32588. * Example : var p = SPS.particles[i];
  32589. */
  32590. particles: SolidParticle[];
  32591. /**
  32592. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32593. */
  32594. nbParticles: number;
  32595. /**
  32596. * If the particles must ever face the camera (default false). Useful for planar particles.
  32597. */
  32598. billboard: boolean;
  32599. /**
  32600. * Recompute normals when adding a shape
  32601. */
  32602. recomputeNormals: boolean;
  32603. /**
  32604. * This a counter ofr your own usage. It's not set by any SPS functions.
  32605. */
  32606. counter: number;
  32607. /**
  32608. * The SPS name. This name is also given to the underlying mesh.
  32609. */
  32610. name: string;
  32611. /**
  32612. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32613. */
  32614. mesh: Mesh;
  32615. /**
  32616. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32617. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  32618. */
  32619. vars: any;
  32620. /**
  32621. * This array is populated when the SPS is set as 'pickable'.
  32622. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32623. * Each element of this array is an object `{idx: int, faceId: int}`.
  32624. * `idx` is the picked particle index in the `SPS.particles` array
  32625. * `faceId` is the picked face index counted within this particle.
  32626. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  32627. */
  32628. pickedParticles: {
  32629. idx: number;
  32630. faceId: number;
  32631. }[];
  32632. /**
  32633. * This array is populated when `enableDepthSort` is set to true.
  32634. * Each element of this array is an instance of the class DepthSortedParticle.
  32635. */
  32636. depthSortedParticles: DepthSortedParticle[];
  32637. /**
  32638. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32639. * @hidden
  32640. */
  32641. _bSphereOnly: boolean;
  32642. /**
  32643. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32644. * @hidden
  32645. */
  32646. _bSphereRadiusFactor: number;
  32647. private _scene;
  32648. private _positions;
  32649. private _indices;
  32650. private _normals;
  32651. private _colors;
  32652. private _uvs;
  32653. private _indices32;
  32654. private _positions32;
  32655. private _normals32;
  32656. private _fixedNormal32;
  32657. private _colors32;
  32658. private _uvs32;
  32659. private _index;
  32660. private _updatable;
  32661. private _pickable;
  32662. private _isVisibilityBoxLocked;
  32663. private _alwaysVisible;
  32664. private _depthSort;
  32665. private _shapeCounter;
  32666. private _copy;
  32667. private _color;
  32668. private _computeParticleColor;
  32669. private _computeParticleTexture;
  32670. private _computeParticleRotation;
  32671. private _computeParticleVertex;
  32672. private _computeBoundingBox;
  32673. private _depthSortParticles;
  32674. private _camera;
  32675. private _mustUnrotateFixedNormals;
  32676. private _particlesIntersect;
  32677. private _needs32Bits;
  32678. /**
  32679. * Creates a SPS (Solid Particle System) object.
  32680. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32681. * @param scene (Scene) is the scene in which the SPS is added.
  32682. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32683. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32684. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32685. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32686. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32687. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32688. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32689. */
  32690. constructor(name: string, scene: Scene, options?: {
  32691. updatable?: boolean;
  32692. isPickable?: boolean;
  32693. enableDepthSort?: boolean;
  32694. particleIntersection?: boolean;
  32695. boundingSphereOnly?: boolean;
  32696. bSphereRadiusFactor?: number;
  32697. });
  32698. /**
  32699. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32700. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32701. * @returns the created mesh
  32702. */
  32703. buildMesh(): Mesh;
  32704. /**
  32705. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32706. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32707. * Thus the particles generated from `digest()` have their property `position` set yet.
  32708. * @param mesh ( Mesh ) is the mesh to be digested
  32709. * @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
  32710. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32711. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32712. * @returns the current SPS
  32713. */
  32714. digest(mesh: Mesh, options?: {
  32715. facetNb?: number;
  32716. number?: number;
  32717. delta?: number;
  32718. }): SolidParticleSystem;
  32719. private _unrotateFixedNormals;
  32720. private _resetCopy;
  32721. private _meshBuilder;
  32722. private _posToShape;
  32723. private _uvsToShapeUV;
  32724. private _addParticle;
  32725. /**
  32726. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32727. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  32728. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32729. * @param nb (positive integer) the number of particles to be created from this model
  32730. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32731. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32732. * @returns the number of shapes in the system
  32733. */
  32734. addShape(mesh: Mesh, nb: number, options?: {
  32735. positionFunction?: any;
  32736. vertexFunction?: any;
  32737. }): number;
  32738. private _rebuildParticle;
  32739. /**
  32740. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32741. * @returns the SPS.
  32742. */
  32743. rebuildMesh(): SolidParticleSystem;
  32744. /**
  32745. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32746. * This method calls `updateParticle()` for each particle of the SPS.
  32747. * For an animated SPS, it is usually called within the render loop.
  32748. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32749. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32750. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32751. * @returns the SPS.
  32752. */
  32753. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32754. /**
  32755. * Disposes the SPS.
  32756. */
  32757. dispose(): void;
  32758. /**
  32759. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32760. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32761. * @returns the SPS.
  32762. */
  32763. refreshVisibleSize(): SolidParticleSystem;
  32764. /**
  32765. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32766. * @param size the size (float) of the visibility box
  32767. * note : this doesn't lock the SPS mesh bounding box.
  32768. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32769. */
  32770. setVisibilityBox(size: number): void;
  32771. /**
  32772. * Gets whether the SPS as always visible or not
  32773. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32774. */
  32775. /**
  32776. * Sets the SPS as always visible or not
  32777. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32778. */
  32779. isAlwaysVisible: boolean;
  32780. /**
  32781. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32782. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32783. */
  32784. /**
  32785. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32786. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32787. */
  32788. isVisibilityBoxLocked: boolean;
  32789. /**
  32790. * Tells to `setParticles()` to compute the particle rotations or not.
  32791. * Default value : true. The SPS is faster when it's set to false.
  32792. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32793. */
  32794. /**
  32795. * Gets if `setParticles()` computes the particle rotations or not.
  32796. * Default value : true. The SPS is faster when it's set to false.
  32797. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32798. */
  32799. computeParticleRotation: boolean;
  32800. /**
  32801. * Tells to `setParticles()` to compute the particle colors or not.
  32802. * Default value : true. The SPS is faster when it's set to false.
  32803. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32804. */
  32805. /**
  32806. * Gets if `setParticles()` computes the particle colors or not.
  32807. * Default value : true. The SPS is faster when it's set to false.
  32808. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32809. */
  32810. computeParticleColor: boolean;
  32811. /**
  32812. * Gets if `setParticles()` computes the particle textures or not.
  32813. * Default value : true. The SPS is faster when it's set to false.
  32814. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32815. */
  32816. computeParticleTexture: boolean;
  32817. /**
  32818. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32819. * Default value : false. The SPS is faster when it's set to false.
  32820. * Note : the particle custom vertex positions aren't stored values.
  32821. */
  32822. /**
  32823. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32824. * Default value : false. The SPS is faster when it's set to false.
  32825. * Note : the particle custom vertex positions aren't stored values.
  32826. */
  32827. computeParticleVertex: boolean;
  32828. /**
  32829. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32830. */
  32831. /**
  32832. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32833. */
  32834. computeBoundingBox: boolean;
  32835. /**
  32836. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32837. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32838. * Default : `true`
  32839. */
  32840. /**
  32841. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32842. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32843. * Default : `true`
  32844. */
  32845. depthSortParticles: boolean;
  32846. /**
  32847. * This function does nothing. It may be overwritten to set all the particle first values.
  32848. * The SPS doesn't call this function, you may have to call it by your own.
  32849. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32850. */
  32851. initParticles(): void;
  32852. /**
  32853. * This function does nothing. It may be overwritten to recycle a particle.
  32854. * The SPS doesn't call this function, you may have to call it by your own.
  32855. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32856. * @param particle The particle to recycle
  32857. * @returns the recycled particle
  32858. */
  32859. recycleParticle(particle: SolidParticle): SolidParticle;
  32860. /**
  32861. * Updates a particle : this function should be overwritten by the user.
  32862. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32863. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32864. * @example : just set a particle position or velocity and recycle conditions
  32865. * @param particle The particle to update
  32866. * @returns the updated particle
  32867. */
  32868. updateParticle(particle: SolidParticle): SolidParticle;
  32869. /**
  32870. * Updates a vertex of a particle : it can be overwritten by the user.
  32871. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32872. * @param particle the current particle
  32873. * @param vertex the current index of the current particle
  32874. * @param pt the index of the current vertex in the particle shape
  32875. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  32876. * @example : just set a vertex particle position
  32877. * @returns the updated vertex
  32878. */
  32879. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  32880. /**
  32881. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32882. * This does nothing and may be overwritten by the user.
  32883. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32884. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32885. * @param update the boolean update value actually passed to setParticles()
  32886. */
  32887. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32888. /**
  32889. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32890. * This will be passed three parameters.
  32891. * This does nothing and may be overwritten by the user.
  32892. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32893. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32894. * @param update the boolean update value actually passed to setParticles()
  32895. */
  32896. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32897. }
  32898. }
  32899. declare module BABYLON {
  32900. /**
  32901. * Type of sub emitter
  32902. */
  32903. enum SubEmitterType {
  32904. /**
  32905. * Attached to the particle over it's lifetime
  32906. */
  32907. ATTACHED = 0,
  32908. /**
  32909. * Created when the particle dies
  32910. */
  32911. END = 1
  32912. }
  32913. /**
  32914. * Sub emitter class used to emit particles from an existing particle
  32915. */
  32916. class SubEmitter {
  32917. /**
  32918. * the particle system to be used by the sub emitter
  32919. */
  32920. particleSystem: ParticleSystem;
  32921. /**
  32922. * Type of the submitter (Default: END)
  32923. */
  32924. type: SubEmitterType;
  32925. /**
  32926. * 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)
  32927. * Note: This only is supported when using an emitter of type Mesh
  32928. */
  32929. inheritDirection: boolean;
  32930. /**
  32931. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  32932. */
  32933. inheritedVelocityAmount: number;
  32934. /**
  32935. * Creates a sub emitter
  32936. * @param particleSystem the particle system to be used by the sub emitter
  32937. */
  32938. constructor(
  32939. /**
  32940. * the particle system to be used by the sub emitter
  32941. */
  32942. particleSystem: ParticleSystem);
  32943. /**
  32944. * Clones the sub emitter
  32945. * @returns the cloned sub emitter
  32946. */
  32947. clone(): SubEmitter;
  32948. /**
  32949. * Serialize current object to a JSON object
  32950. * @returns the serialized object
  32951. */
  32952. serialize(): any;
  32953. /**
  32954. * Creates a new SubEmitter from a serialized JSON version
  32955. * @param serializationObject defines the JSON object to read from
  32956. * @param scene defines the hosting scene
  32957. * @param rootUrl defines the rootUrl for data loading
  32958. * @returns a new SubEmitter
  32959. */
  32960. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  32961. /** Release associated resources */
  32962. dispose(): void;
  32963. }
  32964. }
  32965. declare module BABYLON {
  32966. /**
  32967. * Interface used to describe a physics joint
  32968. */
  32969. interface PhysicsImpostorJoint {
  32970. /** Defines the main impostor to which the joint is linked */
  32971. mainImpostor: PhysicsImpostor;
  32972. /** Defines the impostor that is connected to the main impostor using this joint */
  32973. connectedImpostor: PhysicsImpostor;
  32974. /** Defines the joint itself */
  32975. joint: PhysicsJoint;
  32976. }
  32977. /** @hidden */
  32978. interface IPhysicsEnginePlugin {
  32979. world: any;
  32980. name: string;
  32981. setGravity(gravity: Vector3): void;
  32982. setTimeStep(timeStep: number): void;
  32983. getTimeStep(): number;
  32984. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32985. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32986. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32987. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32988. removePhysicsBody(impostor: PhysicsImpostor): void;
  32989. generateJoint(joint: PhysicsImpostorJoint): void;
  32990. removeJoint(joint: PhysicsImpostorJoint): void;
  32991. isSupported(): boolean;
  32992. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32993. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32994. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32995. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32996. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32997. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32998. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32999. getBodyMass(impostor: PhysicsImpostor): number;
  33000. getBodyFriction(impostor: PhysicsImpostor): number;
  33001. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  33002. getBodyRestitution(impostor: PhysicsImpostor): number;
  33003. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  33004. sleepBody(impostor: PhysicsImpostor): void;
  33005. wakeUpBody(impostor: PhysicsImpostor): void;
  33006. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  33007. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  33008. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33009. getRadius(impostor: PhysicsImpostor): number;
  33010. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  33011. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  33012. dispose(): void;
  33013. }
  33014. /**
  33015. * Interface used to define a physics engine
  33016. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33017. */
  33018. interface IPhysicsEngine {
  33019. /**
  33020. * Gets the gravity vector used by the simulation
  33021. */
  33022. gravity: Vector3;
  33023. /**
  33024. * Sets the gravity vector used by the simulation
  33025. * @param gravity defines the gravity vector to use
  33026. */
  33027. setGravity(gravity: Vector3): void;
  33028. /**
  33029. * Set the time step of the physics engine.
  33030. * Default is 1/60.
  33031. * To slow it down, enter 1/600 for example.
  33032. * To speed it up, 1/30
  33033. * @param newTimeStep the new timestep to apply to this world.
  33034. */
  33035. setTimeStep(newTimeStep: number): void;
  33036. /**
  33037. * Get the time step of the physics engine.
  33038. * @returns the current time step
  33039. */
  33040. getTimeStep(): number;
  33041. /**
  33042. * Release all resources
  33043. */
  33044. dispose(): void;
  33045. /**
  33046. * Gets the name of the current physics plugin
  33047. * @returns the name of the plugin
  33048. */
  33049. getPhysicsPluginName(): string;
  33050. /**
  33051. * Adding a new impostor for the impostor tracking.
  33052. * This will be done by the impostor itself.
  33053. * @param impostor the impostor to add
  33054. */
  33055. addImpostor(impostor: PhysicsImpostor): void;
  33056. /**
  33057. * Remove an impostor from the engine.
  33058. * This impostor and its mesh will not longer be updated by the physics engine.
  33059. * @param impostor the impostor to remove
  33060. */
  33061. removeImpostor(impostor: PhysicsImpostor): void;
  33062. /**
  33063. * Add a joint to the physics engine
  33064. * @param mainImpostor defines the main impostor to which the joint is added.
  33065. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33066. * @param joint defines the joint that will connect both impostors.
  33067. */
  33068. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33069. /**
  33070. * Removes a joint from the simulation
  33071. * @param mainImpostor defines the impostor used with the joint
  33072. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33073. * @param joint defines the joint to remove
  33074. */
  33075. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33076. /**
  33077. * Gets the current plugin used to run the simulation
  33078. * @returns current plugin
  33079. */
  33080. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33081. /**
  33082. * Gets the list of physic impostors
  33083. * @returns an array of PhysicsImpostor
  33084. */
  33085. getImpostors(): Array<PhysicsImpostor>;
  33086. /**
  33087. * Gets the impostor for a physics enabled object
  33088. * @param object defines the object impersonated by the impostor
  33089. * @returns the PhysicsImpostor or null if not found
  33090. */
  33091. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33092. /**
  33093. * Gets the impostor for a physics body object
  33094. * @param body defines physics body used by the impostor
  33095. * @returns the PhysicsImpostor or null if not found
  33096. */
  33097. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33098. /**
  33099. * Called by the scene. No need to call it.
  33100. * @param delta defines the timespam between frames
  33101. */
  33102. _step(delta: number): void;
  33103. }
  33104. }
  33105. declare module BABYLON {
  33106. /**
  33107. * Class used to control physics engine
  33108. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33109. */
  33110. class PhysicsEngine implements IPhysicsEngine {
  33111. private _physicsPlugin;
  33112. /**
  33113. * Global value used to control the smallest number supported by the simulation
  33114. */
  33115. static Epsilon: number;
  33116. private _impostors;
  33117. private _joints;
  33118. /**
  33119. * Gets the gravity vector used by the simulation
  33120. */
  33121. gravity: Vector3;
  33122. /**
  33123. * Creates a new Physics Engine
  33124. * @param gravity defines the gravity vector used by the simulation
  33125. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  33126. */
  33127. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  33128. /**
  33129. * Sets the gravity vector used by the simulation
  33130. * @param gravity defines the gravity vector to use
  33131. */
  33132. setGravity(gravity: Vector3): void;
  33133. /**
  33134. * Set the time step of the physics engine.
  33135. * Default is 1/60.
  33136. * To slow it down, enter 1/600 for example.
  33137. * To speed it up, 1/30
  33138. * @param newTimeStep defines the new timestep to apply to this world.
  33139. */
  33140. setTimeStep(newTimeStep?: number): void;
  33141. /**
  33142. * Get the time step of the physics engine.
  33143. * @returns the current time step
  33144. */
  33145. getTimeStep(): number;
  33146. /**
  33147. * Release all resources
  33148. */
  33149. dispose(): void;
  33150. /**
  33151. * Gets the name of the current physics plugin
  33152. * @returns the name of the plugin
  33153. */
  33154. getPhysicsPluginName(): string;
  33155. /**
  33156. * Adding a new impostor for the impostor tracking.
  33157. * This will be done by the impostor itself.
  33158. * @param impostor the impostor to add
  33159. */
  33160. addImpostor(impostor: PhysicsImpostor): void;
  33161. /**
  33162. * Remove an impostor from the engine.
  33163. * This impostor and its mesh will not longer be updated by the physics engine.
  33164. * @param impostor the impostor to remove
  33165. */
  33166. removeImpostor(impostor: PhysicsImpostor): void;
  33167. /**
  33168. * Add a joint to the physics engine
  33169. * @param mainImpostor defines the main impostor to which the joint is added.
  33170. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33171. * @param joint defines the joint that will connect both impostors.
  33172. */
  33173. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33174. /**
  33175. * Removes a joint from the simulation
  33176. * @param mainImpostor defines the impostor used with the joint
  33177. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33178. * @param joint defines the joint to remove
  33179. */
  33180. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33181. /**
  33182. * Called by the scene. No need to call it.
  33183. * @param delta defines the timespam between frames
  33184. */
  33185. _step(delta: number): void;
  33186. /**
  33187. * Gets the current plugin used to run the simulation
  33188. * @returns current plugin
  33189. */
  33190. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33191. /**
  33192. * Gets the list of physic impostors
  33193. * @returns an array of PhysicsImpostor
  33194. */
  33195. getImpostors(): Array<PhysicsImpostor>;
  33196. /**
  33197. * Gets the impostor for a physics enabled object
  33198. * @param object defines the object impersonated by the impostor
  33199. * @returns the PhysicsImpostor or null if not found
  33200. */
  33201. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33202. /**
  33203. * Gets the impostor for a physics body object
  33204. * @param body defines physics body used by the impostor
  33205. * @returns the PhysicsImpostor or null if not found
  33206. */
  33207. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33208. }
  33209. }
  33210. declare module BABYLON {
  33211. interface Scene {
  33212. /** @hidden (Backing field) */
  33213. _physicsEngine: Nullable<IPhysicsEngine>;
  33214. /**
  33215. * Gets the current physics engine
  33216. * @returns a IPhysicsEngine or null if none attached
  33217. */
  33218. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  33219. /**
  33220. * Enables physics to the current scene
  33221. * @param gravity defines the scene's gravity for the physics engine
  33222. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  33223. * @return a boolean indicating if the physics engine was initialized
  33224. */
  33225. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  33226. /**
  33227. * Disables and disposes the physics engine associated with the scene
  33228. */
  33229. disablePhysicsEngine(): void;
  33230. /**
  33231. * Gets a boolean indicating if there is an active physics engine
  33232. * @returns a boolean indicating if there is an active physics engine
  33233. */
  33234. isPhysicsEnabled(): boolean;
  33235. /**
  33236. * Deletes a physics compound impostor
  33237. * @param compound defines the compound to delete
  33238. */
  33239. deleteCompoundImpostor(compound: any): void;
  33240. /**
  33241. * An event triggered when physic simulation is about to be run
  33242. */
  33243. onBeforePhysicsObservable: Observable<Scene>;
  33244. /**
  33245. * An event triggered when physic simulation has been done
  33246. */
  33247. onAfterPhysicsObservable: Observable<Scene>;
  33248. }
  33249. interface AbstractMesh {
  33250. /** @hidden */
  33251. _physicsImpostor: Nullable<PhysicsImpostor>;
  33252. /**
  33253. * Gets or sets impostor used for physic simulation
  33254. * @see http://doc.babylonjs.com/features/physics_engine
  33255. */
  33256. physicsImpostor: Nullable<PhysicsImpostor>;
  33257. /**
  33258. * Gets the current physics impostor
  33259. * @see http://doc.babylonjs.com/features/physics_engine
  33260. * @returns a physics impostor or null
  33261. */
  33262. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  33263. /** Apply a physic impulse to the mesh
  33264. * @param force defines the force to apply
  33265. * @param contactPoint defines where to apply the force
  33266. * @returns the current mesh
  33267. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33268. */
  33269. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  33270. /**
  33271. * Creates a physic joint between two meshes
  33272. * @param otherMesh defines the other mesh to use
  33273. * @param pivot1 defines the pivot to use on this mesh
  33274. * @param pivot2 defines the pivot to use on the other mesh
  33275. * @param options defines additional options (can be plugin dependent)
  33276. * @returns the current mesh
  33277. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  33278. */
  33279. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  33280. /** @hidden */
  33281. _disposePhysicsObserver: Nullable<Observer<Node>>;
  33282. }
  33283. /**
  33284. * Defines the physics engine scene component responsible to manage a physics engine
  33285. */
  33286. class PhysicsEngineSceneComponent implements ISceneComponent {
  33287. /**
  33288. * The component name helpful to identify the component in the list of scene components.
  33289. */
  33290. readonly name: string;
  33291. /**
  33292. * The scene the component belongs to.
  33293. */
  33294. scene: Scene;
  33295. /**
  33296. * Creates a new instance of the component for the given scene
  33297. * @param scene Defines the scene to register the component in
  33298. */
  33299. constructor(scene: Scene);
  33300. /**
  33301. * Registers the component in a given scene
  33302. */
  33303. register(): void;
  33304. /**
  33305. * Rebuilds the elements related to this component in case of
  33306. * context lost for instance.
  33307. */
  33308. rebuild(): void;
  33309. /**
  33310. * Disposes the component and the associated ressources
  33311. */
  33312. dispose(): void;
  33313. }
  33314. }
  33315. declare module BABYLON {
  33316. /**
  33317. * A helper for physics simulations
  33318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33319. */
  33320. class PhysicsHelper {
  33321. private _scene;
  33322. private _physicsEngine;
  33323. /**
  33324. * Initializes the Physics helper
  33325. * @param scene Babylon.js scene
  33326. */
  33327. constructor(scene: Scene);
  33328. /**
  33329. * Applies a radial explosion impulse
  33330. * @param origin the origin of the explosion
  33331. * @param radius the explosion radius
  33332. * @param strength the explosion strength
  33333. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33334. * @returns A physics radial explosion event, or null
  33335. */
  33336. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33337. /**
  33338. * Applies a radial explosion force
  33339. * @param origin the origin of the explosion
  33340. * @param radius the explosion radius
  33341. * @param strength the explosion strength
  33342. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33343. * @returns A physics radial explosion event, or null
  33344. */
  33345. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33346. /**
  33347. * Creates a gravitational field
  33348. * @param origin the origin of the explosion
  33349. * @param radius the explosion radius
  33350. * @param strength the explosion strength
  33351. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33352. * @returns A physics gravitational field event, or null
  33353. */
  33354. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  33355. /**
  33356. * Creates a physics updraft event
  33357. * @param origin the origin of the updraft
  33358. * @param radius the radius of the updraft
  33359. * @param strength the strength of the updraft
  33360. * @param height the height of the updraft
  33361. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  33362. * @returns A physics updraft event, or null
  33363. */
  33364. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  33365. /**
  33366. * Creates a physics vortex event
  33367. * @param origin the of the vortex
  33368. * @param radius the radius of the vortex
  33369. * @param strength the strength of the vortex
  33370. * @param height the height of the vortex
  33371. * @returns a Physics vortex event, or null
  33372. * A physics vortex event or null
  33373. */
  33374. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  33375. }
  33376. /**
  33377. * Represents a physics radial explosion event
  33378. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33379. */
  33380. class PhysicsRadialExplosionEvent {
  33381. private _scene;
  33382. private _sphere;
  33383. private _sphereOptions;
  33384. private _rays;
  33385. private _dataFetched;
  33386. /**
  33387. * Initializes a radial explosioin event
  33388. * @param scene BabylonJS scene
  33389. */
  33390. constructor(scene: Scene);
  33391. /**
  33392. * Returns the data related to the radial explosion event (sphere & rays).
  33393. * @returns The radial explosion event data
  33394. */
  33395. getData(): PhysicsRadialExplosionEventData;
  33396. /**
  33397. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  33398. * @param impostor A physics imposter
  33399. * @param origin the origin of the explosion
  33400. * @param radius the explosion radius
  33401. * @param strength the explosion strength
  33402. * @param falloff possible options: Constant & Linear
  33403. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  33404. */
  33405. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  33406. /**
  33407. * Disposes the sphere.
  33408. * @param force Specifies if the sphere should be disposed by force
  33409. */
  33410. dispose(force?: boolean): void;
  33411. /*** Helpers ***/
  33412. private _prepareSphere;
  33413. private _intersectsWithSphere;
  33414. }
  33415. /**
  33416. * Represents a gravitational field event
  33417. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33418. */
  33419. class PhysicsGravitationalFieldEvent {
  33420. private _physicsHelper;
  33421. private _scene;
  33422. private _origin;
  33423. private _radius;
  33424. private _strength;
  33425. private _falloff;
  33426. private _tickCallback;
  33427. private _sphere;
  33428. private _dataFetched;
  33429. /**
  33430. * Initializes the physics gravitational field event
  33431. * @param physicsHelper A physics helper
  33432. * @param scene BabylonJS scene
  33433. * @param origin The origin position of the gravitational field event
  33434. * @param radius The radius of the gravitational field event
  33435. * @param strength The strength of the gravitational field event
  33436. * @param falloff The falloff for the gravitational field event
  33437. */
  33438. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  33439. /**
  33440. * Returns the data related to the gravitational field event (sphere).
  33441. * @returns A gravitational field event
  33442. */
  33443. getData(): PhysicsGravitationalFieldEventData;
  33444. /**
  33445. * Enables the gravitational field.
  33446. */
  33447. enable(): void;
  33448. /**
  33449. * Disables the gravitational field.
  33450. */
  33451. disable(): void;
  33452. /**
  33453. * Disposes the sphere.
  33454. * @param force The force to dispose from the gravitational field event
  33455. */
  33456. dispose(force?: boolean): void;
  33457. private _tick;
  33458. }
  33459. /**
  33460. * Represents a physics updraft event
  33461. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33462. */
  33463. class PhysicsUpdraftEvent {
  33464. private _scene;
  33465. private _origin;
  33466. private _radius;
  33467. private _strength;
  33468. private _height;
  33469. private _updraftMode;
  33470. private _physicsEngine;
  33471. private _originTop;
  33472. private _originDirection;
  33473. private _tickCallback;
  33474. private _cylinder;
  33475. private _cylinderPosition;
  33476. private _dataFetched;
  33477. /**
  33478. * Initializes the physics updraft event
  33479. * @param _scene BabylonJS scene
  33480. * @param _origin The origin position of the updraft
  33481. * @param _radius The radius of the updraft
  33482. * @param _strength The strength of the updraft
  33483. * @param _height The height of the updraft
  33484. * @param _updraftMode The mode of the updraft
  33485. */
  33486. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  33487. /**
  33488. * Returns the data related to the updraft event (cylinder).
  33489. * @returns A physics updraft event
  33490. */
  33491. getData(): PhysicsUpdraftEventData;
  33492. /**
  33493. * Enables the updraft.
  33494. */
  33495. enable(): void;
  33496. /**
  33497. * Disables the cortex.
  33498. */
  33499. disable(): void;
  33500. /**
  33501. * Disposes the sphere.
  33502. * @param force Specifies if the updraft should be disposed by force
  33503. */
  33504. dispose(force?: boolean): void;
  33505. private getImpostorForceAndContactPoint;
  33506. private _tick;
  33507. /*** Helpers ***/
  33508. private _prepareCylinder;
  33509. private _intersectsWithCylinder;
  33510. }
  33511. /**
  33512. * Represents a physics vortex event
  33513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33514. */
  33515. class PhysicsVortexEvent {
  33516. private _scene;
  33517. private _origin;
  33518. private _radius;
  33519. private _strength;
  33520. private _height;
  33521. private _physicsEngine;
  33522. private _originTop;
  33523. private _centripetalForceThreshold;
  33524. private _updraftMultiplier;
  33525. private _tickCallback;
  33526. private _cylinder;
  33527. private _cylinderPosition;
  33528. private _dataFetched;
  33529. /**
  33530. * Initializes the physics vortex event
  33531. * @param _scene The BabylonJS scene
  33532. * @param _origin The origin position of the vortex
  33533. * @param _radius The radius of the vortex
  33534. * @param _strength The strength of the vortex
  33535. * @param _height The height of the vortex
  33536. */
  33537. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  33538. /**
  33539. * Returns the data related to the vortex event (cylinder).
  33540. * @returns The physics vortex event data
  33541. */
  33542. getData(): PhysicsVortexEventData;
  33543. /**
  33544. * Enables the vortex.
  33545. */
  33546. enable(): void;
  33547. /**
  33548. * Disables the cortex.
  33549. */
  33550. disable(): void;
  33551. /**
  33552. * Disposes the sphere.
  33553. * @param force
  33554. */
  33555. dispose(force?: boolean): void;
  33556. private getImpostorForceAndContactPoint;
  33557. private _tick;
  33558. /*** Helpers ***/
  33559. private _prepareCylinder;
  33560. private _intersectsWithCylinder;
  33561. }
  33562. /**
  33563. * The strenght of the force in correspondence to the distance of the affected object
  33564. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33565. */
  33566. enum PhysicsRadialImpulseFalloff {
  33567. /** Defines that impulse is constant in strength across it's whole radius */
  33568. Constant = 0,
  33569. /** DEfines that impulse gets weaker if it's further from the origin */
  33570. Linear = 1
  33571. }
  33572. /**
  33573. * The strength of the force in correspondence to the distance of the affected object
  33574. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33575. */
  33576. enum PhysicsUpdraftMode {
  33577. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  33578. Center = 0,
  33579. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  33580. Perpendicular = 1
  33581. }
  33582. /**
  33583. * Interface for a physics force and contact point
  33584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33585. */
  33586. interface PhysicsForceAndContactPoint {
  33587. /**
  33588. * The force applied at the contact point
  33589. */
  33590. force: Vector3;
  33591. /**
  33592. * The contact point
  33593. */
  33594. contactPoint: Vector3;
  33595. }
  33596. /**
  33597. * Interface for radial explosion event data
  33598. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33599. */
  33600. interface PhysicsRadialExplosionEventData {
  33601. /**
  33602. * A sphere used for the radial explosion event
  33603. */
  33604. sphere: Mesh;
  33605. /**
  33606. * An array of rays for the radial explosion event
  33607. */
  33608. rays: Array<Ray>;
  33609. }
  33610. /**
  33611. * Interface for gravitational field event data
  33612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33613. */
  33614. interface PhysicsGravitationalFieldEventData {
  33615. /**
  33616. * A sphere mesh used for the gravitational field event
  33617. */
  33618. sphere: Mesh;
  33619. }
  33620. /**
  33621. * Interface for updraft event data
  33622. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33623. */
  33624. interface PhysicsUpdraftEventData {
  33625. /**
  33626. * A cylinder used for the updraft event
  33627. */
  33628. cylinder: Mesh;
  33629. }
  33630. /**
  33631. * Interface for vortex event data
  33632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33633. */
  33634. interface PhysicsVortexEventData {
  33635. /**
  33636. * A cylinder used for the vortex event
  33637. */
  33638. cylinder: Mesh;
  33639. }
  33640. }
  33641. declare module BABYLON {
  33642. /**
  33643. * The interface for the physics imposter parameters
  33644. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33645. */
  33646. interface PhysicsImpostorParameters {
  33647. /**
  33648. * The mass of the physics imposter
  33649. */
  33650. mass: number;
  33651. /**
  33652. * The friction of the physics imposter
  33653. */
  33654. friction?: number;
  33655. /**
  33656. * The coefficient of restitution of the physics imposter
  33657. */
  33658. restitution?: number;
  33659. /**
  33660. * The native options of the physics imposter
  33661. */
  33662. nativeOptions?: any;
  33663. /**
  33664. * Specifies if the parent should be ignored
  33665. */
  33666. ignoreParent?: boolean;
  33667. /**
  33668. * Specifies if bi-directional transformations should be disabled
  33669. */
  33670. disableBidirectionalTransformation?: boolean;
  33671. }
  33672. /**
  33673. * Interface for a physics-enabled object
  33674. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33675. */
  33676. interface IPhysicsEnabledObject {
  33677. /**
  33678. * The position of the physics-enabled object
  33679. */
  33680. position: Vector3;
  33681. /**
  33682. * The rotation of the physics-enabled object
  33683. */
  33684. rotationQuaternion: Nullable<Quaternion>;
  33685. /**
  33686. * The scale of the physics-enabled object
  33687. */
  33688. scaling: Vector3;
  33689. /**
  33690. * The rotation of the physics-enabled object
  33691. */
  33692. rotation?: Vector3;
  33693. /**
  33694. * The parent of the physics-enabled object
  33695. */
  33696. parent?: any;
  33697. /**
  33698. * The bounding info of the physics-enabled object
  33699. * @returns The bounding info of the physics-enabled object
  33700. */
  33701. getBoundingInfo(): BoundingInfo;
  33702. /**
  33703. * Computes the world matrix
  33704. * @param force Specifies if the world matrix should be computed by force
  33705. * @returns A world matrix
  33706. */
  33707. computeWorldMatrix(force: boolean): Matrix;
  33708. /**
  33709. * Gets the world matrix
  33710. * @returns A world matrix
  33711. */
  33712. getWorldMatrix?(): Matrix;
  33713. /**
  33714. * Gets the child meshes
  33715. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33716. * @returns An array of abstract meshes
  33717. */
  33718. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33719. /**
  33720. * Gets the vertex data
  33721. * @param kind The type of vertex data
  33722. * @returns A nullable array of numbers, or a float32 array
  33723. */
  33724. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33725. /**
  33726. * Gets the indices from the mesh
  33727. * @returns A nullable array of index arrays
  33728. */
  33729. getIndices?(): Nullable<IndicesArray>;
  33730. /**
  33731. * Gets the scene from the mesh
  33732. * @returns the indices array or null
  33733. */
  33734. getScene?(): Scene;
  33735. /**
  33736. * Gets the absolute position from the mesh
  33737. * @returns the absolute position
  33738. */
  33739. getAbsolutePosition(): Vector3;
  33740. /**
  33741. * Gets the absolute pivot point from the mesh
  33742. * @returns the absolute pivot point
  33743. */
  33744. getAbsolutePivotPoint(): Vector3;
  33745. /**
  33746. * Rotates the mesh
  33747. * @param axis The axis of rotation
  33748. * @param amount The amount of rotation
  33749. * @param space The space of the rotation
  33750. * @returns The rotation transform node
  33751. */
  33752. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33753. /**
  33754. * Translates the mesh
  33755. * @param axis The axis of translation
  33756. * @param distance The distance of translation
  33757. * @param space The space of the translation
  33758. * @returns The transform node
  33759. */
  33760. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33761. /**
  33762. * Sets the absolute position of the mesh
  33763. * @param absolutePosition The absolute position of the mesh
  33764. * @returns The transform node
  33765. */
  33766. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33767. /**
  33768. * Gets the class name of the mesh
  33769. * @returns The class name
  33770. */
  33771. getClassName(): string;
  33772. }
  33773. /**
  33774. * Represents a physics imposter
  33775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33776. */
  33777. class PhysicsImpostor {
  33778. /**
  33779. * The physics-enabled object used as the physics imposter
  33780. */
  33781. object: IPhysicsEnabledObject;
  33782. /**
  33783. * The type of the physics imposter
  33784. */
  33785. type: number;
  33786. private _options;
  33787. private _scene?;
  33788. /**
  33789. * The default object size of the imposter
  33790. */
  33791. static DEFAULT_OBJECT_SIZE: Vector3;
  33792. /**
  33793. * The identity quaternion of the imposter
  33794. */
  33795. static IDENTITY_QUATERNION: Quaternion;
  33796. /** @hidden */
  33797. _pluginData: any;
  33798. private _physicsEngine;
  33799. private _physicsBody;
  33800. private _bodyUpdateRequired;
  33801. private _onBeforePhysicsStepCallbacks;
  33802. private _onAfterPhysicsStepCallbacks;
  33803. /** @hidden */
  33804. _onPhysicsCollideCallbacks: Array<{
  33805. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  33806. otherImpostors: Array<PhysicsImpostor>;
  33807. }>;
  33808. private _deltaPosition;
  33809. private _deltaRotation;
  33810. private _deltaRotationConjugated;
  33811. private _parent;
  33812. private _isDisposed;
  33813. private static _tmpVecs;
  33814. private static _tmpQuat;
  33815. /**
  33816. * Specifies if the physics imposter is disposed
  33817. */
  33818. readonly isDisposed: boolean;
  33819. /**
  33820. * Gets the mass of the physics imposter
  33821. */
  33822. mass: number;
  33823. /**
  33824. * Gets the coefficient of friction
  33825. */
  33826. /**
  33827. * Sets the coefficient of friction
  33828. */
  33829. friction: number;
  33830. /**
  33831. * Gets the coefficient of restitution
  33832. */
  33833. /**
  33834. * Sets the coefficient of restitution
  33835. */
  33836. restitution: number;
  33837. /**
  33838. * The unique id of the physics imposter
  33839. * set by the physics engine when adding this impostor to the array
  33840. */
  33841. uniqueId: number;
  33842. private _joints;
  33843. /**
  33844. * Initializes the physics imposter
  33845. * @param object The physics-enabled object used as the physics imposter
  33846. * @param type The type of the physics imposter
  33847. * @param _options The options for the physics imposter
  33848. * @param _scene The Babylon scene
  33849. */
  33850. constructor(
  33851. /**
  33852. * The physics-enabled object used as the physics imposter
  33853. */
  33854. object: IPhysicsEnabledObject,
  33855. /**
  33856. * The type of the physics imposter
  33857. */
  33858. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33859. /**
  33860. * This function will completly initialize this impostor.
  33861. * It will create a new body - but only if this mesh has no parent.
  33862. * If it has, this impostor will not be used other than to define the impostor
  33863. * of the child mesh.
  33864. * @hidden
  33865. */
  33866. _init(): void;
  33867. private _getPhysicsParent;
  33868. /**
  33869. * Should a new body be generated.
  33870. * @returns boolean specifying if body initialization is required
  33871. */
  33872. isBodyInitRequired(): boolean;
  33873. /**
  33874. * Sets the updated scaling
  33875. * @param updated Specifies if the scaling is updated
  33876. */
  33877. setScalingUpdated(updated: boolean): void;
  33878. /**
  33879. * Force a regeneration of this or the parent's impostor's body.
  33880. * Use under cautious - This will remove all joints already implemented.
  33881. */
  33882. forceUpdate(): void;
  33883. /**
  33884. * Gets the body that holds this impostor. Either its own, or its parent.
  33885. */
  33886. /**
  33887. * Set the physics body. Used mainly by the physics engine/plugin
  33888. */
  33889. physicsBody: any;
  33890. /**
  33891. * Get the parent of the physics imposter
  33892. * @returns Physics imposter or null
  33893. */
  33894. /**
  33895. * Sets the parent of the physics imposter
  33896. */
  33897. parent: Nullable<PhysicsImpostor>;
  33898. /**
  33899. * Resets the update flags
  33900. */
  33901. resetUpdateFlags(): void;
  33902. /**
  33903. * Gets the object extend size
  33904. * @returns the object extend size
  33905. */
  33906. getObjectExtendSize(): Vector3;
  33907. /**
  33908. * Gets the object center
  33909. * @returns The object center
  33910. */
  33911. getObjectCenter(): Vector3;
  33912. /**
  33913. * Get a specific parametes from the options parameter
  33914. * @param paramName The object parameter name
  33915. * @returns The object parameter
  33916. */
  33917. getParam(paramName: string): any;
  33918. /**
  33919. * Sets a specific parameter in the options given to the physics plugin
  33920. * @param paramName The parameter name
  33921. * @param value The value of the parameter
  33922. */
  33923. setParam(paramName: string, value: number): void;
  33924. /**
  33925. * Specifically change the body's mass option. Won't recreate the physics body object
  33926. * @param mass The mass of the physics imposter
  33927. */
  33928. setMass(mass: number): void;
  33929. /**
  33930. * Gets the linear velocity
  33931. * @returns linear velocity or null
  33932. */
  33933. getLinearVelocity(): Nullable<Vector3>;
  33934. /**
  33935. * Sets the linear velocity
  33936. * @param velocity linear velocity or null
  33937. */
  33938. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33939. /**
  33940. * Gets the angular velocity
  33941. * @returns angular velocity or null
  33942. */
  33943. getAngularVelocity(): Nullable<Vector3>;
  33944. /**
  33945. * Sets the angular velocity
  33946. * @param velocity The velocity or null
  33947. */
  33948. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33949. /**
  33950. * Execute a function with the physics plugin native code
  33951. * Provide a function the will have two variables - the world object and the physics body object
  33952. * @param func The function to execute with the physics plugin native code
  33953. */
  33954. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33955. /**
  33956. * Register a function that will be executed before the physics world is stepping forward
  33957. * @param func The function to execute before the physics world is stepped forward
  33958. */
  33959. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33960. /**
  33961. * Unregister a function that will be executed before the physics world is stepping forward
  33962. * @param func The function to execute before the physics world is stepped forward
  33963. */
  33964. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33965. /**
  33966. * Register a function that will be executed after the physics step
  33967. * @param func The function to execute after physics step
  33968. */
  33969. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33970. /**
  33971. * Unregisters a function that will be executed after the physics step
  33972. * @param func The function to execute after physics step
  33973. */
  33974. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33975. /**
  33976. * register a function that will be executed when this impostor collides against a different body
  33977. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33978. * @param func Callback that is executed on collision
  33979. */
  33980. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33981. /**
  33982. * Unregisters the physics imposter on contact
  33983. * @param collideAgainst The physics object to collide against
  33984. * @param func Callback to execute on collision
  33985. */
  33986. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33987. private _tmpQuat;
  33988. private _tmpQuat2;
  33989. /**
  33990. * Get the parent rotation
  33991. * @returns The parent rotation
  33992. */
  33993. getParentsRotation(): Quaternion;
  33994. /**
  33995. * this function is executed by the physics engine.
  33996. */
  33997. beforeStep: () => void;
  33998. /**
  33999. * this function is executed by the physics engine
  34000. */
  34001. afterStep: () => void;
  34002. /**
  34003. * Legacy collision detection event support
  34004. */
  34005. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  34006. /**
  34007. * event and body object due to cannon's event-based architecture.
  34008. */
  34009. onCollide: (e: {
  34010. body: any;
  34011. }) => void;
  34012. /**
  34013. * Apply a force
  34014. * @param force The force to apply
  34015. * @param contactPoint The contact point for the force
  34016. * @returns The physics imposter
  34017. */
  34018. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  34019. /**
  34020. * Apply an impulse
  34021. * @param force The impulse force
  34022. * @param contactPoint The contact point for the impulse force
  34023. * @returns The physics imposter
  34024. */
  34025. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  34026. /**
  34027. * A help function to create a joint
  34028. * @param otherImpostor A physics imposter used to create a joint
  34029. * @param jointType The type of joint
  34030. * @param jointData The data for the joint
  34031. * @returns The physics imposter
  34032. */
  34033. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  34034. /**
  34035. * Add a joint to this impostor with a different impostor
  34036. * @param otherImpostor A physics imposter used to add a joint
  34037. * @param joint The joint to add
  34038. * @returns The physics imposter
  34039. */
  34040. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  34041. /**
  34042. * Will keep this body still, in a sleep mode.
  34043. * @returns the physics imposter
  34044. */
  34045. sleep(): PhysicsImpostor;
  34046. /**
  34047. * Wake the body up.
  34048. * @returns The physics imposter
  34049. */
  34050. wakeUp(): PhysicsImpostor;
  34051. /**
  34052. * Clones the physics imposter
  34053. * @param newObject The physics imposter clones to this physics-enabled object
  34054. * @returns A nullable physics imposter
  34055. */
  34056. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  34057. /**
  34058. * Disposes the physics imposter
  34059. */
  34060. dispose(): void;
  34061. /**
  34062. * Sets the delta position
  34063. * @param position The delta position amount
  34064. */
  34065. setDeltaPosition(position: Vector3): void;
  34066. /**
  34067. * Sets the delta rotation
  34068. * @param rotation The delta rotation amount
  34069. */
  34070. setDeltaRotation(rotation: Quaternion): void;
  34071. /**
  34072. * Gets the box size of the physics imposter and stores the result in the input parameter
  34073. * @param result Stores the box size
  34074. * @returns The physics imposter
  34075. */
  34076. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  34077. /**
  34078. * Gets the radius of the physics imposter
  34079. * @returns Radius of the physics imposter
  34080. */
  34081. getRadius(): number;
  34082. /**
  34083. * Sync a bone with this impostor
  34084. * @param bone The bone to sync to the impostor.
  34085. * @param boneMesh The mesh that the bone is influencing.
  34086. * @param jointPivot The pivot of the joint / bone in local space.
  34087. * @param distToJoint Optional distance from the impostor to the joint.
  34088. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34089. */
  34090. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  34091. /**
  34092. * Sync impostor to a bone
  34093. * @param bone The bone that the impostor will be synced to.
  34094. * @param boneMesh The mesh that the bone is influencing.
  34095. * @param jointPivot The pivot of the joint / bone in local space.
  34096. * @param distToJoint Optional distance from the impostor to the joint.
  34097. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  34098. * @param boneAxis Optional vector3 axis the bone is aligned with
  34099. */
  34100. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  34101. /**
  34102. * No-Imposter type
  34103. */
  34104. static NoImpostor: number;
  34105. /**
  34106. * Sphere-Imposter type
  34107. */
  34108. static SphereImpostor: number;
  34109. /**
  34110. * Box-Imposter type
  34111. */
  34112. static BoxImpostor: number;
  34113. /**
  34114. * Plane-Imposter type
  34115. */
  34116. static PlaneImpostor: number;
  34117. /**
  34118. * Mesh-imposter type
  34119. */
  34120. static MeshImpostor: number;
  34121. /**
  34122. * Cylinder-Imposter type
  34123. */
  34124. static CylinderImpostor: number;
  34125. /**
  34126. * Particle-Imposter type
  34127. */
  34128. static ParticleImpostor: number;
  34129. /**
  34130. * Heightmap-Imposter type
  34131. */
  34132. static HeightmapImpostor: number;
  34133. }
  34134. }
  34135. declare module BABYLON {
  34136. /**
  34137. * Interface for Physics-Joint data
  34138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34139. */
  34140. interface PhysicsJointData {
  34141. /**
  34142. * The main pivot of the joint
  34143. */
  34144. mainPivot?: Vector3;
  34145. /**
  34146. * The connected pivot of the joint
  34147. */
  34148. connectedPivot?: Vector3;
  34149. /**
  34150. * The main axis of the joint
  34151. */
  34152. mainAxis?: Vector3;
  34153. /**
  34154. * The connected axis of the joint
  34155. */
  34156. connectedAxis?: Vector3;
  34157. /**
  34158. * The collision of the joint
  34159. */
  34160. collision?: boolean;
  34161. /**
  34162. * Native Oimo/Cannon/Energy data
  34163. */
  34164. nativeParams?: any;
  34165. }
  34166. /**
  34167. * This is a holder class for the physics joint created by the physics plugin
  34168. * It holds a set of functions to control the underlying joint
  34169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34170. */
  34171. class PhysicsJoint {
  34172. /**
  34173. * The type of the physics joint
  34174. */
  34175. type: number;
  34176. /**
  34177. * The data for the physics joint
  34178. */
  34179. jointData: PhysicsJointData;
  34180. private _physicsJoint;
  34181. protected _physicsPlugin: IPhysicsEnginePlugin;
  34182. /**
  34183. * Initializes the physics joint
  34184. * @param type The type of the physics joint
  34185. * @param jointData The data for the physics joint
  34186. */
  34187. constructor(
  34188. /**
  34189. * The type of the physics joint
  34190. */
  34191. type: number,
  34192. /**
  34193. * The data for the physics joint
  34194. */
  34195. jointData: PhysicsJointData);
  34196. /**
  34197. * Gets the physics joint
  34198. */
  34199. /**
  34200. * Sets the physics joint
  34201. */
  34202. physicsJoint: any;
  34203. /**
  34204. * Sets the physics plugin
  34205. */
  34206. physicsPlugin: IPhysicsEnginePlugin;
  34207. /**
  34208. * Execute a function that is physics-plugin specific.
  34209. * @param {Function} func the function that will be executed.
  34210. * It accepts two parameters: the physics world and the physics joint
  34211. */
  34212. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  34213. /**
  34214. * Distance-Joint type
  34215. */
  34216. static DistanceJoint: number;
  34217. /**
  34218. * Hinge-Joint type
  34219. */
  34220. static HingeJoint: number;
  34221. /**
  34222. * Ball-and-Socket joint type
  34223. */
  34224. static BallAndSocketJoint: number;
  34225. /**
  34226. * Wheel-Joint type
  34227. */
  34228. static WheelJoint: number;
  34229. /**
  34230. * Slider-Joint type
  34231. */
  34232. static SliderJoint: number;
  34233. /**
  34234. * Prismatic-Joint type
  34235. */
  34236. static PrismaticJoint: number;
  34237. /**
  34238. * Universal-Joint type
  34239. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  34240. */
  34241. static UniversalJoint: number;
  34242. /**
  34243. * Hinge-Joint 2 type
  34244. */
  34245. static Hinge2Joint: number;
  34246. /**
  34247. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  34248. */
  34249. static PointToPointJoint: number;
  34250. /**
  34251. * Spring-Joint type
  34252. */
  34253. static SpringJoint: number;
  34254. /**
  34255. * Lock-Joint type
  34256. */
  34257. static LockJoint: number;
  34258. }
  34259. /**
  34260. * A class representing a physics distance joint
  34261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34262. */
  34263. class DistanceJoint extends PhysicsJoint {
  34264. /**
  34265. *
  34266. * @param jointData The data for the Distance-Joint
  34267. */
  34268. constructor(jointData: DistanceJointData);
  34269. /**
  34270. * Update the predefined distance.
  34271. * @param maxDistance The maximum preferred distance
  34272. * @param minDistance The minimum preferred distance
  34273. */
  34274. updateDistance(maxDistance: number, minDistance?: number): void;
  34275. }
  34276. /**
  34277. * Represents a Motor-Enabled Joint
  34278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34279. */
  34280. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  34281. /**
  34282. * Initializes the Motor-Enabled Joint
  34283. * @param type The type of the joint
  34284. * @param jointData The physica joint data for the joint
  34285. */
  34286. constructor(type: number, jointData: PhysicsJointData);
  34287. /**
  34288. * Set the motor values.
  34289. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34290. * @param force the force to apply
  34291. * @param maxForce max force for this motor.
  34292. */
  34293. setMotor(force?: number, maxForce?: number): void;
  34294. /**
  34295. * Set the motor's limits.
  34296. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34297. * @param upperLimit The upper limit of the motor
  34298. * @param lowerLimit The lower limit of the motor
  34299. */
  34300. setLimit(upperLimit: number, lowerLimit?: number): void;
  34301. }
  34302. /**
  34303. * This class represents a single physics Hinge-Joint
  34304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34305. */
  34306. class HingeJoint extends MotorEnabledJoint {
  34307. /**
  34308. * Initializes the Hinge-Joint
  34309. * @param jointData The joint data for the Hinge-Joint
  34310. */
  34311. constructor(jointData: PhysicsJointData);
  34312. /**
  34313. * Set the motor values.
  34314. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34315. * @param {number} force the force to apply
  34316. * @param {number} maxForce max force for this motor.
  34317. */
  34318. setMotor(force?: number, maxForce?: number): void;
  34319. /**
  34320. * Set the motor's limits.
  34321. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34322. * @param upperLimit The upper limit of the motor
  34323. * @param lowerLimit The lower limit of the motor
  34324. */
  34325. setLimit(upperLimit: number, lowerLimit?: number): void;
  34326. }
  34327. /**
  34328. * This class represents a dual hinge physics joint (same as wheel joint)
  34329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34330. */
  34331. class Hinge2Joint extends MotorEnabledJoint {
  34332. /**
  34333. * Initializes the Hinge2-Joint
  34334. * @param jointData The joint data for the Hinge2-Joint
  34335. */
  34336. constructor(jointData: PhysicsJointData);
  34337. /**
  34338. * Set the motor values.
  34339. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34340. * @param {number} force the force to apply
  34341. * @param {number} maxForce max force for this motor.
  34342. * @param {motorIndex} the motor's index, 0 or 1.
  34343. */
  34344. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34345. /**
  34346. * Set the motor limits.
  34347. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34348. * @param {number} upperLimit the upper limit
  34349. * @param {number} lowerLimit lower limit
  34350. * @param {motorIndex} the motor's index, 0 or 1.
  34351. */
  34352. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34353. }
  34354. /**
  34355. * Interface for a motor enabled joint
  34356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34357. */
  34358. interface IMotorEnabledJoint {
  34359. /**
  34360. * Physics joint
  34361. */
  34362. physicsJoint: any;
  34363. /**
  34364. * Sets the motor of the motor-enabled joint
  34365. * @param force The force of the motor
  34366. * @param maxForce The maximum force of the motor
  34367. * @param motorIndex The index of the motor
  34368. */
  34369. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34370. /**
  34371. * Sets the limit of the motor
  34372. * @param upperLimit The upper limit of the motor
  34373. * @param lowerLimit The lower limit of the motor
  34374. * @param motorIndex The index of the motor
  34375. */
  34376. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34377. }
  34378. /**
  34379. * Joint data for a Distance-Joint
  34380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34381. */
  34382. interface DistanceJointData extends PhysicsJointData {
  34383. /**
  34384. * Max distance the 2 joint objects can be apart
  34385. */
  34386. maxDistance: number;
  34387. }
  34388. /**
  34389. * Joint data from a spring joint
  34390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34391. */
  34392. interface SpringJointData extends PhysicsJointData {
  34393. /**
  34394. * Length of the spring
  34395. */
  34396. length: number;
  34397. /**
  34398. * Stiffness of the spring
  34399. */
  34400. stiffness: number;
  34401. /**
  34402. * Damping of the spring
  34403. */
  34404. damping: number;
  34405. /** this callback will be called when applying the force to the impostors. */
  34406. forceApplicationCallback: () => void;
  34407. }
  34408. }
  34409. declare module BABYLON {
  34410. interface AbstractScene {
  34411. /**
  34412. * The list of reflection probes added to the scene
  34413. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34414. */
  34415. reflectionProbes: Array<ReflectionProbe>;
  34416. /**
  34417. * Removes the given reflection probe from this scene.
  34418. * @param toRemove The reflection probe to remove
  34419. * @returns The index of the removed reflection probe
  34420. */
  34421. removeReflectionProbe(toRemove: ReflectionProbe): number;
  34422. /**
  34423. * Adds the given reflection probe to this scene.
  34424. * @param newReflectionProbe The reflection probe to add
  34425. */
  34426. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  34427. }
  34428. /**
  34429. * Class used to generate realtime reflection / refraction cube textures
  34430. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34431. */
  34432. class ReflectionProbe {
  34433. /** defines the name of the probe */
  34434. name: string;
  34435. private _scene;
  34436. private _renderTargetTexture;
  34437. private _projectionMatrix;
  34438. private _viewMatrix;
  34439. private _target;
  34440. private _add;
  34441. private _attachedMesh;
  34442. private _invertYAxis;
  34443. /** Gets or sets probe position (center of the cube map) */
  34444. position: Vector3;
  34445. /**
  34446. * Creates a new reflection probe
  34447. * @param name defines the name of the probe
  34448. * @param size defines the texture resolution (for each face)
  34449. * @param scene defines the hosting scene
  34450. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  34451. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  34452. */
  34453. constructor(
  34454. /** defines the name of the probe */
  34455. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  34456. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  34457. samples: number;
  34458. /** Gets or sets the refresh rate to use (on every frame by default) */
  34459. refreshRate: number;
  34460. /**
  34461. * Gets the hosting scene
  34462. * @returns a Scene
  34463. */
  34464. getScene(): Scene;
  34465. /** Gets the internal CubeTexture used to render to */
  34466. readonly cubeTexture: RenderTargetTexture;
  34467. /** Gets the list of meshes to render */
  34468. readonly renderList: Nullable<AbstractMesh[]>;
  34469. /**
  34470. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  34471. * @param mesh defines the mesh to attach to
  34472. */
  34473. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  34474. /**
  34475. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  34476. * @param renderingGroupId The rendering group id corresponding to its index
  34477. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34478. */
  34479. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  34480. /**
  34481. * Clean all associated resources
  34482. */
  34483. dispose(): void;
  34484. /**
  34485. * Converts the reflection probe information to a readable string for debug purpose.
  34486. * @param fullDetails Supports for multiple levels of logging within scene loading
  34487. * @returns the human readable reflection probe info
  34488. */
  34489. toString(fullDetails?: boolean): string;
  34490. /**
  34491. * Get the class name of the relfection probe.
  34492. * @returns "ReflectionProbe"
  34493. */
  34494. getClassName(): string;
  34495. /**
  34496. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  34497. * @returns The JSON representation of the texture
  34498. */
  34499. serialize(): any;
  34500. /**
  34501. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  34502. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  34503. * @param scene Define the scene the parsed reflection probe should be instantiated in
  34504. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  34505. * @returns The parsed reflection probe if successful
  34506. */
  34507. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  34508. }
  34509. }
  34510. declare module BABYLON {
  34511. /**
  34512. * Postprocess used to generate anaglyphic rendering
  34513. */
  34514. class AnaglyphPostProcess extends PostProcess {
  34515. private _passedProcess;
  34516. /**
  34517. * Creates a new AnaglyphPostProcess
  34518. * @param name defines postprocess name
  34519. * @param options defines creation options or target ratio scale
  34520. * @param rigCameras defines cameras using this postprocess
  34521. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  34522. * @param engine defines hosting engine
  34523. * @param reusable defines if the postprocess will be reused multiple times per frame
  34524. */
  34525. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  34526. }
  34527. }
  34528. declare module BABYLON {
  34529. /**
  34530. * Post process used to render in black and white
  34531. */
  34532. class BlackAndWhitePostProcess extends PostProcess {
  34533. /**
  34534. * Linear about to convert he result to black and white (default: 1)
  34535. */
  34536. degree: number;
  34537. /**
  34538. * Creates a black and white post process
  34539. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  34540. * @param name The name of the effect.
  34541. * @param options The required width/height ratio to downsize to before computing the render pass.
  34542. * @param camera The camera to apply the render pass to.
  34543. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34544. * @param engine The engine which the post process will be applied. (default: current engine)
  34545. * @param reusable If the post process can be reused on the same frame. (default: false)
  34546. */
  34547. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34548. }
  34549. }
  34550. declare module BABYLON {
  34551. /**
  34552. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  34553. */
  34554. class BloomEffect extends PostProcessRenderEffect {
  34555. private bloomScale;
  34556. /**
  34557. * @hidden Internal
  34558. */
  34559. _effects: Array<PostProcess>;
  34560. /**
  34561. * @hidden Internal
  34562. */
  34563. _downscale: ExtractHighlightsPostProcess;
  34564. private _blurX;
  34565. private _blurY;
  34566. private _merge;
  34567. /**
  34568. * The luminance threshold to find bright areas of the image to bloom.
  34569. */
  34570. threshold: number;
  34571. /**
  34572. * The strength of the bloom.
  34573. */
  34574. weight: number;
  34575. /**
  34576. * Specifies the size of the bloom blur kernel, relative to the final output size
  34577. */
  34578. kernel: number;
  34579. /**
  34580. * Creates a new instance of @see BloomEffect
  34581. * @param scene The scene the effect belongs to.
  34582. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  34583. * @param bloomKernel The size of the kernel to be used when applying the blur.
  34584. * @param bloomWeight The the strength of bloom.
  34585. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34586. * @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)
  34587. */
  34588. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  34589. /**
  34590. * Disposes each of the internal effects for a given camera.
  34591. * @param camera The camera to dispose the effect on.
  34592. */
  34593. disposeEffects(camera: Camera): void;
  34594. /**
  34595. * @hidden Internal
  34596. */
  34597. _updateEffects(): void;
  34598. /**
  34599. * Internal
  34600. * @returns if all the contained post processes are ready.
  34601. * @hidden
  34602. */
  34603. _isReady(): boolean;
  34604. }
  34605. }
  34606. declare module BABYLON {
  34607. /**
  34608. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34609. */
  34610. class BloomMergePostProcess extends PostProcess {
  34611. /** Weight of the bloom to be added to the original input. */
  34612. weight: number;
  34613. /**
  34614. * Creates a new instance of @see BloomMergePostProcess
  34615. * @param name The name of the effect.
  34616. * @param originalFromInput Post process which's input will be used for the merge.
  34617. * @param blurred Blurred highlights post process which's output will be used.
  34618. * @param weight Weight of the bloom to be added to the original input.
  34619. * @param options The required width/height ratio to downsize to before computing the render pass.
  34620. * @param camera The camera to apply the render pass to.
  34621. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34622. * @param engine The engine which the post process will be applied. (default: current engine)
  34623. * @param reusable If the post process can be reused on the same frame. (default: false)
  34624. * @param textureType Type of textures used when performing the post process. (default: 0)
  34625. * @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)
  34626. */
  34627. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  34628. /** Weight of the bloom to be added to the original input. */
  34629. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34630. }
  34631. }
  34632. declare module BABYLON {
  34633. /**
  34634. * The Blur Post Process which blurs an image based on a kernel and direction.
  34635. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  34636. */
  34637. class BlurPostProcess extends PostProcess {
  34638. /** The direction in which to blur the image. */
  34639. direction: Vector2;
  34640. private blockCompilation;
  34641. protected _kernel: number;
  34642. protected _idealKernel: number;
  34643. protected _packedFloat: boolean;
  34644. private _staticDefines;
  34645. /**
  34646. * Sets the length in pixels of the blur sample region
  34647. */
  34648. /**
  34649. * Gets the length in pixels of the blur sample region
  34650. */
  34651. kernel: number;
  34652. /**
  34653. * Sets wether or not the blur needs to unpack/repack floats
  34654. */
  34655. /**
  34656. * Gets wether or not the blur is unpacking/repacking floats
  34657. */
  34658. packedFloat: boolean;
  34659. /**
  34660. * Creates a new instance BlurPostProcess
  34661. * @param name The name of the effect.
  34662. * @param direction The direction in which to blur the image.
  34663. * @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.
  34664. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  34665. * @param camera The camera to apply the render pass to.
  34666. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34667. * @param engine The engine which the post process will be applied. (default: current engine)
  34668. * @param reusable If the post process can be reused on the same frame. (default: false)
  34669. * @param textureType Type of textures used when performing the post process. (default: 0)
  34670. * @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)
  34671. */
  34672. constructor(name: string,
  34673. /** The direction in which to blur the image. */
  34674. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  34675. /**
  34676. * Updates the effect with the current post process compile time values and recompiles the shader.
  34677. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  34678. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  34679. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  34680. * @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
  34681. * @param onCompiled Called when the shader has been compiled.
  34682. * @param onError Called if there is an error when compiling a shader.
  34683. */
  34684. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34685. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  34686. /**
  34687. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  34688. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  34689. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  34690. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  34691. * The gaps between physical kernels are compensated for in the weighting of the samples
  34692. * @param idealKernel Ideal blur kernel.
  34693. * @return Nearest best kernel.
  34694. */
  34695. protected _nearestBestKernel(idealKernel: number): number;
  34696. /**
  34697. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  34698. * @param x The point on the Gaussian distribution to sample.
  34699. * @return the value of the Gaussian function at x.
  34700. */
  34701. protected _gaussianWeight(x: number): number;
  34702. /**
  34703. * Generates a string that can be used as a floating point number in GLSL.
  34704. * @param x Value to print.
  34705. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  34706. * @return GLSL float string.
  34707. */
  34708. protected _glslFloat(x: number, decimalFigures?: number): string;
  34709. }
  34710. }
  34711. declare module BABYLON {
  34712. /**
  34713. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  34714. */
  34715. class ChromaticAberrationPostProcess extends PostProcess {
  34716. /**
  34717. * The amount of seperation of rgb channels (default: 30)
  34718. */
  34719. aberrationAmount: number;
  34720. /**
  34721. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  34722. */
  34723. radialIntensity: number;
  34724. /**
  34725. * 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))
  34726. */
  34727. direction: Vector2;
  34728. /**
  34729. * 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))
  34730. */
  34731. centerPosition: Vector2;
  34732. /**
  34733. * Creates a new instance ChromaticAberrationPostProcess
  34734. * @param name The name of the effect.
  34735. * @param screenWidth The width of the screen to apply the effect on.
  34736. * @param screenHeight The height of the screen to apply the effect on.
  34737. * @param options The required width/height ratio to downsize to before computing the render pass.
  34738. * @param camera The camera to apply the render pass to.
  34739. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34740. * @param engine The engine which the post process will be applied. (default: current engine)
  34741. * @param reusable If the post process can be reused on the same frame. (default: false)
  34742. * @param textureType Type of textures used when performing the post process. (default: 0)
  34743. * @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)
  34744. */
  34745. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34746. }
  34747. }
  34748. declare module BABYLON {
  34749. /**
  34750. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  34751. */
  34752. class CircleOfConfusionPostProcess extends PostProcess {
  34753. /**
  34754. * 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.
  34755. */
  34756. lensSize: number;
  34757. /**
  34758. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34759. */
  34760. fStop: number;
  34761. /**
  34762. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34763. */
  34764. focusDistance: number;
  34765. /**
  34766. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  34767. */
  34768. focalLength: number;
  34769. private _depthTexture;
  34770. /**
  34771. * Creates a new instance CircleOfConfusionPostProcess
  34772. * @param name The name of the effect.
  34773. * @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.
  34774. * @param options The required width/height ratio to downsize to before computing the render pass.
  34775. * @param camera The camera to apply the render pass to.
  34776. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34777. * @param engine The engine which the post process will be applied. (default: current engine)
  34778. * @param reusable If the post process can be reused on the same frame. (default: false)
  34779. * @param textureType Type of textures used when performing the post process. (default: 0)
  34780. * @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)
  34781. */
  34782. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  34783. /**
  34784. * 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.
  34785. */
  34786. depthTexture: RenderTargetTexture;
  34787. }
  34788. }
  34789. declare module BABYLON {
  34790. /**
  34791. *
  34792. * This post-process allows the modification of rendered colors by using
  34793. * a 'look-up table' (LUT). This effect is also called Color Grading.
  34794. *
  34795. * The object needs to be provided an url to a texture containing the color
  34796. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  34797. * Use an image editing software to tweak the LUT to match your needs.
  34798. *
  34799. * For an example of a color LUT, see here:
  34800. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  34801. * For explanations on color grading, see here:
  34802. * @see http://udn.epicgames.com/Three/ColorGrading.html
  34803. *
  34804. */
  34805. class ColorCorrectionPostProcess extends PostProcess {
  34806. private _colorTableTexture;
  34807. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  34808. }
  34809. }
  34810. declare module BABYLON {
  34811. /**
  34812. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  34813. * input texture to perform effects such as edge detection or sharpening
  34814. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  34815. */
  34816. class ConvolutionPostProcess extends PostProcess {
  34817. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34818. kernel: number[];
  34819. /**
  34820. * Creates a new instance ConvolutionPostProcess
  34821. * @param name The name of the effect.
  34822. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  34823. * @param options The required width/height ratio to downsize to before computing the render pass.
  34824. * @param camera The camera to apply the render pass to.
  34825. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34826. * @param engine The engine which the post process will be applied. (default: current engine)
  34827. * @param reusable If the post process can be reused on the same frame. (default: false)
  34828. * @param textureType Type of textures used when performing the post process. (default: 0)
  34829. */
  34830. constructor(name: string,
  34831. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  34832. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  34833. /**
  34834. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34835. */
  34836. static EdgeDetect0Kernel: number[];
  34837. /**
  34838. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34839. */
  34840. static EdgeDetect1Kernel: number[];
  34841. /**
  34842. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34843. */
  34844. static EdgeDetect2Kernel: number[];
  34845. /**
  34846. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34847. */
  34848. static SharpenKernel: number[];
  34849. /**
  34850. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34851. */
  34852. static EmbossKernel: number[];
  34853. /**
  34854. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  34855. */
  34856. static GaussianKernel: number[];
  34857. }
  34858. }
  34859. declare module BABYLON {
  34860. /**
  34861. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  34862. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  34863. * based on samples that have a large difference in distance than the center pixel.
  34864. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  34865. */
  34866. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  34867. direction: Vector2;
  34868. /**
  34869. * Creates a new instance CircleOfConfusionPostProcess
  34870. * @param name The name of the effect.
  34871. * @param scene The scene the effect belongs to.
  34872. * @param direction The direction the blur should be applied.
  34873. * @param kernel The size of the kernel used to blur.
  34874. * @param options The required width/height ratio to downsize to before computing the render pass.
  34875. * @param camera The camera to apply the render pass to.
  34876. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  34877. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  34878. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  34879. * @param engine The engine which the post process will be applied. (default: current engine)
  34880. * @param reusable If the post process can be reused on the same frame. (default: false)
  34881. * @param textureType Type of textures used when performing the post process. (default: 0)
  34882. * @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)
  34883. */
  34884. 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);
  34885. }
  34886. }
  34887. declare module BABYLON {
  34888. /**
  34889. * Specifies the level of max blur that should be applied when using the depth of field effect
  34890. */
  34891. enum DepthOfFieldEffectBlurLevel {
  34892. /**
  34893. * Subtle blur
  34894. */
  34895. Low = 0,
  34896. /**
  34897. * Medium blur
  34898. */
  34899. Medium = 1,
  34900. /**
  34901. * Large blur
  34902. */
  34903. High = 2
  34904. }
  34905. /**
  34906. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  34907. */
  34908. class DepthOfFieldEffect extends PostProcessRenderEffect {
  34909. private _circleOfConfusion;
  34910. /**
  34911. * @hidden Internal, blurs from high to low
  34912. */
  34913. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  34914. private _depthOfFieldBlurY;
  34915. private _dofMerge;
  34916. /**
  34917. * @hidden Internal post processes in depth of field effect
  34918. */
  34919. _effects: Array<PostProcess>;
  34920. /**
  34921. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  34922. */
  34923. focalLength: number;
  34924. /**
  34925. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  34926. */
  34927. fStop: number;
  34928. /**
  34929. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  34930. */
  34931. focusDistance: number;
  34932. /**
  34933. * 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.
  34934. */
  34935. lensSize: number;
  34936. /**
  34937. * Creates a new instance DepthOfFieldEffect
  34938. * @param scene The scene the effect belongs to.
  34939. * @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.
  34940. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  34941. * @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)
  34942. */
  34943. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  34944. /**
  34945. * 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.
  34946. */
  34947. depthTexture: RenderTargetTexture;
  34948. /**
  34949. * Disposes each of the internal effects for a given camera.
  34950. * @param camera The camera to dispose the effect on.
  34951. */
  34952. disposeEffects(camera: Camera): void;
  34953. /**
  34954. * @hidden Internal
  34955. */
  34956. _updateEffects(): void;
  34957. /**
  34958. * Internal
  34959. * @returns if all the contained post processes are ready.
  34960. * @hidden
  34961. */
  34962. _isReady(): boolean;
  34963. }
  34964. }
  34965. declare module BABYLON {
  34966. /**
  34967. * Options to be set when merging outputs from the default pipeline.
  34968. */
  34969. class DepthOfFieldMergePostProcessOptions {
  34970. /**
  34971. * The original image to merge on top of
  34972. */
  34973. originalFromInput: PostProcess;
  34974. /**
  34975. * Parameters to perform the merge of the depth of field effect
  34976. */
  34977. depthOfField?: {
  34978. circleOfConfusion: PostProcess;
  34979. blurSteps: Array<PostProcess>;
  34980. };
  34981. /**
  34982. * Parameters to perform the merge of bloom effect
  34983. */
  34984. bloom?: {
  34985. blurred: PostProcess;
  34986. weight: number;
  34987. };
  34988. }
  34989. /**
  34990. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  34991. */
  34992. class DepthOfFieldMergePostProcess extends PostProcess {
  34993. private blurSteps;
  34994. /**
  34995. * Creates a new instance of DepthOfFieldMergePostProcess
  34996. * @param name The name of the effect.
  34997. * @param originalFromInput Post process which's input will be used for the merge.
  34998. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  34999. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  35000. * @param options The required width/height ratio to downsize to before computing the render pass.
  35001. * @param camera The camera to apply the render pass to.
  35002. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35003. * @param engine The engine which the post process will be applied. (default: current engine)
  35004. * @param reusable If the post process can be reused on the same frame. (default: false)
  35005. * @param textureType Type of textures used when performing the post process. (default: 0)
  35006. * @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)
  35007. */
  35008. 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);
  35009. /**
  35010. * Updates the effect with the current post process compile time values and recompiles the shader.
  35011. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35012. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35013. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35014. * @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
  35015. * @param onCompiled Called when the shader has been compiled.
  35016. * @param onError Called if there is an error when compiling a shader.
  35017. */
  35018. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35019. }
  35020. }
  35021. declare module BABYLON {
  35022. /**
  35023. * DisplayPassPostProcess which produces an output the same as it's input
  35024. */
  35025. class DisplayPassPostProcess extends PostProcess {
  35026. /**
  35027. * Creates the DisplayPassPostProcess
  35028. * @param name The name of the effect.
  35029. * @param options The required width/height ratio to downsize to before computing the render pass.
  35030. * @param camera The camera to apply the render pass to.
  35031. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35032. * @param engine The engine which the post process will be applied. (default: current engine)
  35033. * @param reusable If the post process can be reused on the same frame. (default: false)
  35034. */
  35035. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35036. }
  35037. }
  35038. declare module BABYLON {
  35039. /**
  35040. * 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.
  35041. */
  35042. class ExtractHighlightsPostProcess extends PostProcess {
  35043. /**
  35044. * The luminance threshold, pixels below this value will be set to black.
  35045. */
  35046. threshold: number;
  35047. /** @hidden */
  35048. _exposure: number;
  35049. /**
  35050. * Post process which has the input texture to be used when performing highlight extraction
  35051. * @hidden
  35052. */
  35053. _inputPostProcess: Nullable<PostProcess>;
  35054. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35055. }
  35056. }
  35057. declare module BABYLON {
  35058. /**
  35059. * Applies a kernel filter to the image
  35060. */
  35061. class FilterPostProcess extends PostProcess {
  35062. /** The matrix to be applied to the image */
  35063. kernelMatrix: Matrix;
  35064. /**
  35065. *
  35066. * @param name The name of the effect.
  35067. * @param kernelMatrix The matrix to be applied to the image
  35068. * @param options The required width/height ratio to downsize to before computing the render pass.
  35069. * @param camera The camera to apply the render pass to.
  35070. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35071. * @param engine The engine which the post process will be applied. (default: current engine)
  35072. * @param reusable If the post process can be reused on the same frame. (default: false)
  35073. */
  35074. constructor(name: string,
  35075. /** The matrix to be applied to the image */
  35076. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35077. }
  35078. }
  35079. declare module BABYLON {
  35080. /**
  35081. * Fxaa post process
  35082. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  35083. */
  35084. class FxaaPostProcess extends PostProcess {
  35085. /** @hidden */
  35086. texelWidth: number;
  35087. /** @hidden */
  35088. texelHeight: number;
  35089. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35090. private _getDefines;
  35091. }
  35092. }
  35093. declare module BABYLON {
  35094. /**
  35095. * The GrainPostProcess adds noise to the image at mid luminance levels
  35096. */
  35097. class GrainPostProcess extends PostProcess {
  35098. /**
  35099. * The intensity of the grain added (default: 30)
  35100. */
  35101. intensity: number;
  35102. /**
  35103. * If the grain should be randomized on every frame
  35104. */
  35105. animated: boolean;
  35106. /**
  35107. * Creates a new instance of @see GrainPostProcess
  35108. * @param name The name of the effect.
  35109. * @param options The required width/height ratio to downsize to before computing the render pass.
  35110. * @param camera The camera to apply the render pass to.
  35111. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35112. * @param engine The engine which the post process will be applied. (default: current engine)
  35113. * @param reusable If the post process can be reused on the same frame. (default: false)
  35114. * @param textureType Type of textures used when performing the post process. (default: 0)
  35115. * @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)
  35116. */
  35117. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35118. }
  35119. }
  35120. declare module BABYLON {
  35121. /**
  35122. * Extracts highlights from the image
  35123. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35124. */
  35125. class HighlightsPostProcess extends PostProcess {
  35126. /**
  35127. * Extracts highlights from the image
  35128. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35129. * @param name The name of the effect.
  35130. * @param options The required width/height ratio to downsize to before computing the render pass.
  35131. * @param camera The camera to apply the render pass to.
  35132. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35133. * @param engine The engine which the post process will be applied. (default: current engine)
  35134. * @param reusable If the post process can be reused on the same frame. (default: false)
  35135. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  35136. */
  35137. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35138. }
  35139. }
  35140. declare module BABYLON {
  35141. /**
  35142. * ImageProcessingPostProcess
  35143. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  35144. */
  35145. class ImageProcessingPostProcess extends PostProcess {
  35146. /**
  35147. * Default configuration related to image processing available in the PBR Material.
  35148. */
  35149. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35150. /**
  35151. * Gets the image processing configuration used either in this material.
  35152. */
  35153. /**
  35154. * Sets the Default image processing configuration used either in the this material.
  35155. *
  35156. * If sets to null, the scene one is in use.
  35157. */
  35158. imageProcessingConfiguration: ImageProcessingConfiguration;
  35159. /**
  35160. * Keep track of the image processing observer to allow dispose and replace.
  35161. */
  35162. private _imageProcessingObserver;
  35163. /**
  35164. * Attaches a new image processing configuration to the PBR Material.
  35165. * @param configuration
  35166. */
  35167. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  35168. /**
  35169. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  35170. */
  35171. /**
  35172. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  35173. */
  35174. colorCurves: Nullable<ColorCurves>;
  35175. /**
  35176. * Gets wether the color curves effect is enabled.
  35177. */
  35178. /**
  35179. * Sets wether the color curves effect is enabled.
  35180. */
  35181. colorCurvesEnabled: boolean;
  35182. /**
  35183. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  35184. */
  35185. /**
  35186. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  35187. */
  35188. colorGradingTexture: Nullable<BaseTexture>;
  35189. /**
  35190. * Gets wether the color grading effect is enabled.
  35191. */
  35192. /**
  35193. * Gets wether the color grading effect is enabled.
  35194. */
  35195. colorGradingEnabled: boolean;
  35196. /**
  35197. * Gets exposure used in the effect.
  35198. */
  35199. /**
  35200. * Sets exposure used in the effect.
  35201. */
  35202. exposure: number;
  35203. /**
  35204. * Gets wether tonemapping is enabled or not.
  35205. */
  35206. /**
  35207. * Sets wether tonemapping is enabled or not
  35208. */
  35209. toneMappingEnabled: boolean;
  35210. /**
  35211. * Gets contrast used in the effect.
  35212. */
  35213. /**
  35214. * Sets contrast used in the effect.
  35215. */
  35216. contrast: number;
  35217. /**
  35218. * Gets Vignette stretch size.
  35219. */
  35220. /**
  35221. * Sets Vignette stretch size.
  35222. */
  35223. vignetteStretch: number;
  35224. /**
  35225. * Gets Vignette centre X Offset.
  35226. */
  35227. /**
  35228. * Sets Vignette centre X Offset.
  35229. */
  35230. vignetteCentreX: number;
  35231. /**
  35232. * Gets Vignette centre Y Offset.
  35233. */
  35234. /**
  35235. * Sets Vignette centre Y Offset.
  35236. */
  35237. vignetteCentreY: number;
  35238. /**
  35239. * Gets Vignette weight or intensity of the vignette effect.
  35240. */
  35241. /**
  35242. * Sets Vignette weight or intensity of the vignette effect.
  35243. */
  35244. vignetteWeight: number;
  35245. /**
  35246. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  35247. * if vignetteEnabled is set to true.
  35248. */
  35249. /**
  35250. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  35251. * if vignetteEnabled is set to true.
  35252. */
  35253. vignetteColor: Color4;
  35254. /**
  35255. * Gets Camera field of view used by the Vignette effect.
  35256. */
  35257. /**
  35258. * Sets Camera field of view used by the Vignette effect.
  35259. */
  35260. vignetteCameraFov: number;
  35261. /**
  35262. * Gets the vignette blend mode allowing different kind of effect.
  35263. */
  35264. /**
  35265. * Sets the vignette blend mode allowing different kind of effect.
  35266. */
  35267. vignetteBlendMode: number;
  35268. /**
  35269. * Gets wether the vignette effect is enabled.
  35270. */
  35271. /**
  35272. * Sets wether the vignette effect is enabled.
  35273. */
  35274. vignetteEnabled: boolean;
  35275. private _fromLinearSpace;
  35276. /**
  35277. * Gets wether the input of the processing is in Gamma or Linear Space.
  35278. */
  35279. /**
  35280. * Sets wether the input of the processing is in Gamma or Linear Space.
  35281. */
  35282. fromLinearSpace: boolean;
  35283. /**
  35284. * Defines cache preventing GC.
  35285. */
  35286. private _defines;
  35287. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  35288. /**
  35289. * "ImageProcessingPostProcess"
  35290. * @returns "ImageProcessingPostProcess"
  35291. */
  35292. getClassName(): string;
  35293. protected _updateParameters(): void;
  35294. dispose(camera?: Camera): void;
  35295. }
  35296. }
  35297. declare module BABYLON {
  35298. /**
  35299. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  35300. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  35301. * As an example, all you have to do is to create the post-process:
  35302. * var mb = new BABYLON.MotionBlurPostProcess(
  35303. * 'mb', // The name of the effect.
  35304. * scene, // The scene containing the objects to blur according to their velocity.
  35305. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  35306. * camera // The camera to apply the render pass to.
  35307. * );
  35308. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  35309. */
  35310. class MotionBlurPostProcess extends PostProcess {
  35311. /**
  35312. * Defines how much the image is blurred by the movement. Default value is equal to 1
  35313. */
  35314. motionStrength: number;
  35315. /**
  35316. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  35317. */
  35318. /**
  35319. * Sets the number of iterations to be used for motion blur quality
  35320. */
  35321. motionBlurSamples: number;
  35322. private _motionBlurSamples;
  35323. private _geometryBufferRenderer;
  35324. /**
  35325. * Creates a new instance MotionBlurPostProcess
  35326. * @param name The name of the effect.
  35327. * @param scene The scene containing the objects to blur according to their velocity.
  35328. * @param options The required width/height ratio to downsize to before computing the render pass.
  35329. * @param camera The camera to apply the render pass to.
  35330. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35331. * @param engine The engine which the post process will be applied. (default: current engine)
  35332. * @param reusable If the post process can be reused on the same frame. (default: false)
  35333. * @param textureType Type of textures used when performing the post process. (default: 0)
  35334. * @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)
  35335. */
  35336. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35337. /**
  35338. * Disposes the post process.
  35339. * @param camera The camera to dispose the post process on.
  35340. */
  35341. dispose(camera?: Camera): void;
  35342. }
  35343. }
  35344. declare module BABYLON {
  35345. /**
  35346. * PassPostProcess which produces an output the same as it's input
  35347. */
  35348. class PassPostProcess extends PostProcess {
  35349. /**
  35350. * Creates the PassPostProcess
  35351. * @param name The name of the effect.
  35352. * @param options The required width/height ratio to downsize to before computing the render pass.
  35353. * @param camera The camera to apply the render pass to.
  35354. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35355. * @param engine The engine which the post process will be applied. (default: current engine)
  35356. * @param reusable If the post process can be reused on the same frame. (default: false)
  35357. * @param textureType The type of texture to be used when performing the post processing.
  35358. * @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)
  35359. */
  35360. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35361. }
  35362. /**
  35363. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  35364. */
  35365. class PassCubePostProcess extends PostProcess {
  35366. private _face;
  35367. /**
  35368. * Gets or sets the cube face to display.
  35369. * * 0 is +X
  35370. * * 1 is -X
  35371. * * 2 is +Y
  35372. * * 3 is -Y
  35373. * * 4 is +Z
  35374. * * 5 is -Z
  35375. */
  35376. face: number;
  35377. /**
  35378. * Creates the PassCubePostProcess
  35379. * @param name The name of the effect.
  35380. * @param options The required width/height ratio to downsize to before computing the render pass.
  35381. * @param camera The camera to apply the render pass to.
  35382. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35383. * @param engine The engine which the post process will be applied. (default: current engine)
  35384. * @param reusable If the post process can be reused on the same frame. (default: false)
  35385. * @param textureType The type of texture to be used when performing the post processing.
  35386. * @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)
  35387. */
  35388. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35389. }
  35390. }
  35391. declare module BABYLON {
  35392. /**
  35393. * Size options for a post process
  35394. */
  35395. type PostProcessOptions = {
  35396. width: number;
  35397. height: number;
  35398. };
  35399. /**
  35400. * PostProcess can be used to apply a shader to a texture after it has been rendered
  35401. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35402. */
  35403. class PostProcess {
  35404. /** Name of the PostProcess. */
  35405. name: string;
  35406. /**
  35407. * Width of the texture to apply the post process on
  35408. */
  35409. width: number;
  35410. /**
  35411. * Height of the texture to apply the post process on
  35412. */
  35413. height: number;
  35414. /**
  35415. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  35416. * @hidden
  35417. */
  35418. _outputTexture: Nullable<InternalTexture>;
  35419. /**
  35420. * Sampling mode used by the shader
  35421. * See https://doc.babylonjs.com/classes/3.1/texture
  35422. */
  35423. renderTargetSamplingMode: number;
  35424. /**
  35425. * Clear color to use when screen clearing
  35426. */
  35427. clearColor: Color4;
  35428. /**
  35429. * If the buffer needs to be cleared before applying the post process. (default: true)
  35430. * Should be set to false if shader will overwrite all previous pixels.
  35431. */
  35432. autoClear: boolean;
  35433. /**
  35434. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  35435. */
  35436. alphaMode: number;
  35437. /**
  35438. * Sets the setAlphaBlendConstants of the babylon engine
  35439. */
  35440. alphaConstants: Color4;
  35441. /**
  35442. * Animations to be used for the post processing
  35443. */
  35444. animations: Animation[];
  35445. /**
  35446. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  35447. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  35448. */
  35449. enablePixelPerfectMode: boolean;
  35450. /**
  35451. * Force the postprocess to be applied without taking in account viewport
  35452. */
  35453. forceFullscreenViewport: boolean;
  35454. /**
  35455. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  35456. *
  35457. * | Value | Type | Description |
  35458. * | ----- | ----------------------------------- | ----------- |
  35459. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  35460. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  35461. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  35462. *
  35463. */
  35464. scaleMode: number;
  35465. /**
  35466. * Force textures to be a power of two (default: false)
  35467. */
  35468. alwaysForcePOT: boolean;
  35469. private _samples;
  35470. /**
  35471. * Number of sample textures (default: 1)
  35472. */
  35473. samples: number;
  35474. /**
  35475. * Modify the scale of the post process to be the same as the viewport (default: false)
  35476. */
  35477. adaptScaleToCurrentViewport: boolean;
  35478. private _camera;
  35479. private _scene;
  35480. private _engine;
  35481. private _options;
  35482. private _reusable;
  35483. private _textureType;
  35484. /**
  35485. * Smart array of input and output textures for the post process.
  35486. * @hidden
  35487. */
  35488. _textures: SmartArray<InternalTexture>;
  35489. /**
  35490. * The index in _textures that corresponds to the output texture.
  35491. * @hidden
  35492. */
  35493. _currentRenderTextureInd: number;
  35494. private _effect;
  35495. private _samplers;
  35496. private _fragmentUrl;
  35497. private _vertexUrl;
  35498. private _parameters;
  35499. private _scaleRatio;
  35500. protected _indexParameters: any;
  35501. private _shareOutputWithPostProcess;
  35502. private _texelSize;
  35503. private _forcedOutputTexture;
  35504. /**
  35505. * An event triggered when the postprocess is activated.
  35506. */
  35507. onActivateObservable: Observable<Camera>;
  35508. private _onActivateObserver;
  35509. /**
  35510. * A function that is added to the onActivateObservable
  35511. */
  35512. onActivate: Nullable<(camera: Camera) => void>;
  35513. /**
  35514. * An event triggered when the postprocess changes its size.
  35515. */
  35516. onSizeChangedObservable: Observable<PostProcess>;
  35517. private _onSizeChangedObserver;
  35518. /**
  35519. * A function that is added to the onSizeChangedObservable
  35520. */
  35521. onSizeChanged: (postProcess: PostProcess) => void;
  35522. /**
  35523. * An event triggered when the postprocess applies its effect.
  35524. */
  35525. onApplyObservable: Observable<Effect>;
  35526. private _onApplyObserver;
  35527. /**
  35528. * A function that is added to the onApplyObservable
  35529. */
  35530. onApply: (effect: Effect) => void;
  35531. /**
  35532. * An event triggered before rendering the postprocess
  35533. */
  35534. onBeforeRenderObservable: Observable<Effect>;
  35535. private _onBeforeRenderObserver;
  35536. /**
  35537. * A function that is added to the onBeforeRenderObservable
  35538. */
  35539. onBeforeRender: (effect: Effect) => void;
  35540. /**
  35541. * An event triggered after rendering the postprocess
  35542. */
  35543. onAfterRenderObservable: Observable<Effect>;
  35544. private _onAfterRenderObserver;
  35545. /**
  35546. * A function that is added to the onAfterRenderObservable
  35547. */
  35548. onAfterRender: (efect: Effect) => void;
  35549. /**
  35550. * 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
  35551. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  35552. */
  35553. inputTexture: InternalTexture;
  35554. /**
  35555. * Gets the camera which post process is applied to.
  35556. * @returns The camera the post process is applied to.
  35557. */
  35558. getCamera(): Camera;
  35559. /**
  35560. * Gets the texel size of the postprocess.
  35561. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  35562. */
  35563. readonly texelSize: Vector2;
  35564. /**
  35565. * Creates a new instance PostProcess
  35566. * @param name The name of the PostProcess.
  35567. * @param fragmentUrl The url of the fragment shader to be used.
  35568. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  35569. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  35570. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  35571. * @param camera The camera to apply the render pass to.
  35572. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35573. * @param engine The engine which the post process will be applied. (default: current engine)
  35574. * @param reusable If the post process can be reused on the same frame. (default: false)
  35575. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  35576. * @param textureType Type of textures used when performing the post process. (default: 0)
  35577. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  35578. * @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
  35579. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  35580. */
  35581. constructor(
  35582. /** Name of the PostProcess. */
  35583. 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);
  35584. /**
  35585. * Gets the engine which this post process belongs to.
  35586. * @returns The engine the post process was enabled with.
  35587. */
  35588. getEngine(): Engine;
  35589. /**
  35590. * The effect that is created when initializing the post process.
  35591. * @returns The created effect corrisponding the the postprocess.
  35592. */
  35593. getEffect(): Effect;
  35594. /**
  35595. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  35596. * @param postProcess The post process to share the output with.
  35597. * @returns This post process.
  35598. */
  35599. shareOutputWith(postProcess: PostProcess): PostProcess;
  35600. /**
  35601. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  35602. * This should be called if the post process that shares output with this post process is disabled/disposed.
  35603. */
  35604. useOwnOutput(): void;
  35605. /**
  35606. * Updates the effect with the current post process compile time values and recompiles the shader.
  35607. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35608. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35609. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35610. * @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
  35611. * @param onCompiled Called when the shader has been compiled.
  35612. * @param onError Called if there is an error when compiling a shader.
  35613. */
  35614. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35615. /**
  35616. * The post process is reusable if it can be used multiple times within one frame.
  35617. * @returns If the post process is reusable
  35618. */
  35619. isReusable(): boolean;
  35620. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  35621. markTextureDirty(): void;
  35622. /**
  35623. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  35624. * 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.
  35625. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  35626. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  35627. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  35628. * @returns The target texture that was bound to be written to.
  35629. */
  35630. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  35631. /**
  35632. * If the post process is supported.
  35633. */
  35634. readonly isSupported: boolean;
  35635. /**
  35636. * The aspect ratio of the output texture.
  35637. */
  35638. readonly aspectRatio: number;
  35639. /**
  35640. * Get a value indicating if the post-process is ready to be used
  35641. * @returns true if the post-process is ready (shader is compiled)
  35642. */
  35643. isReady(): boolean;
  35644. /**
  35645. * Binds all textures and uniforms to the shader, this will be run on every pass.
  35646. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  35647. */
  35648. apply(): Nullable<Effect>;
  35649. private _disposeTextures;
  35650. /**
  35651. * Disposes the post process.
  35652. * @param camera The camera to dispose the post process on.
  35653. */
  35654. dispose(camera?: Camera): void;
  35655. }
  35656. }
  35657. declare module BABYLON {
  35658. /**
  35659. * PostProcessManager is used to manage one or more post processes or post process pipelines
  35660. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35661. */
  35662. class PostProcessManager {
  35663. private _scene;
  35664. private _indexBuffer;
  35665. private _vertexBuffers;
  35666. /**
  35667. * Creates a new instance PostProcess
  35668. * @param scene The scene that the post process is associated with.
  35669. */
  35670. constructor(scene: Scene);
  35671. private _prepareBuffers;
  35672. private _buildIndexBuffer;
  35673. /**
  35674. * Rebuilds the vertex buffers of the manager.
  35675. * @hidden
  35676. */
  35677. _rebuild(): void;
  35678. /**
  35679. * Prepares a frame to be run through a post process.
  35680. * @param sourceTexture The input texture to the post procesess. (default: null)
  35681. * @param postProcesses An array of post processes to be run. (default: null)
  35682. * @returns True if the post processes were able to be run.
  35683. * @hidden
  35684. */
  35685. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  35686. /**
  35687. * Manually render a set of post processes to a texture.
  35688. * @param postProcesses An array of post processes to be run.
  35689. * @param targetTexture The target texture to render to.
  35690. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  35691. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  35692. * @param lodLevel defines which lod of the texture to render to
  35693. */
  35694. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  35695. /**
  35696. * Finalize the result of the output of the postprocesses.
  35697. * @param doNotPresent If true the result will not be displayed to the screen.
  35698. * @param targetTexture The target texture to render to.
  35699. * @param faceIndex The index of the face to bind the target texture to.
  35700. * @param postProcesses The array of post processes to render.
  35701. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  35702. * @hidden
  35703. */
  35704. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  35705. /**
  35706. * Disposes of the post process manager.
  35707. */
  35708. dispose(): void;
  35709. }
  35710. }
  35711. declare module BABYLON {
  35712. /**
  35713. * Post process which applies a refractin texture
  35714. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35715. */
  35716. class RefractionPostProcess extends PostProcess {
  35717. /** the base color of the refraction (used to taint the rendering) */
  35718. color: Color3;
  35719. /** simulated refraction depth */
  35720. depth: number;
  35721. /** the coefficient of the base color (0 to remove base color tainting) */
  35722. colorLevel: number;
  35723. private _refTexture;
  35724. private _ownRefractionTexture;
  35725. /**
  35726. * Gets or sets the refraction texture
  35727. * Please note that you are responsible for disposing the texture if you set it manually
  35728. */
  35729. refractionTexture: Texture;
  35730. /**
  35731. * Initializes the RefractionPostProcess
  35732. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  35733. * @param name The name of the effect.
  35734. * @param refractionTextureUrl Url of the refraction texture to use
  35735. * @param color the base color of the refraction (used to taint the rendering)
  35736. * @param depth simulated refraction depth
  35737. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  35738. * @param camera The camera to apply the render pass to.
  35739. * @param options The required width/height ratio to downsize to before computing the render pass.
  35740. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35741. * @param engine The engine which the post process will be applied. (default: current engine)
  35742. * @param reusable If the post process can be reused on the same frame. (default: false)
  35743. */
  35744. constructor(name: string, refractionTextureUrl: string,
  35745. /** the base color of the refraction (used to taint the rendering) */
  35746. color: Color3,
  35747. /** simulated refraction depth */
  35748. depth: number,
  35749. /** the coefficient of the base color (0 to remove base color tainting) */
  35750. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35751. /**
  35752. * Disposes of the post process
  35753. * @param camera Camera to dispose post process on
  35754. */
  35755. dispose(camera: Camera): void;
  35756. }
  35757. }
  35758. declare module BABYLON {
  35759. /**
  35760. * The SharpenPostProcess applies a sharpen kernel to every pixel
  35761. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  35762. */
  35763. class SharpenPostProcess extends PostProcess {
  35764. /**
  35765. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  35766. */
  35767. colorAmount: number;
  35768. /**
  35769. * How much sharpness should be applied (default: 0.3)
  35770. */
  35771. edgeAmount: number;
  35772. /**
  35773. * Creates a new instance ConvolutionPostProcess
  35774. * @param name The name of the effect.
  35775. * @param options The required width/height ratio to downsize to before computing the render pass.
  35776. * @param camera The camera to apply the render pass to.
  35777. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35778. * @param engine The engine which the post process will be applied. (default: current engine)
  35779. * @param reusable If the post process can be reused on the same frame. (default: false)
  35780. * @param textureType Type of textures used when performing the post process. (default: 0)
  35781. * @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)
  35782. */
  35783. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35784. }
  35785. }
  35786. declare module BABYLON {
  35787. /**
  35788. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  35789. */
  35790. class StereoscopicInterlacePostProcess extends PostProcess {
  35791. private _stepSize;
  35792. private _passedProcess;
  35793. /**
  35794. * Initializes a StereoscopicInterlacePostProcess
  35795. * @param name The name of the effect.
  35796. * @param rigCameras The rig cameras to be appled to the post process
  35797. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  35798. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35799. * @param engine The engine which the post process will be applied. (default: current engine)
  35800. * @param reusable If the post process can be reused on the same frame. (default: false)
  35801. */
  35802. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35803. }
  35804. }
  35805. declare module BABYLON {
  35806. /** Defines operator used for tonemapping */
  35807. enum TonemappingOperator {
  35808. /** Hable */
  35809. Hable = 0,
  35810. /** Reinhard */
  35811. Reinhard = 1,
  35812. /** HejiDawson */
  35813. HejiDawson = 2,
  35814. /** Photographic */
  35815. Photographic = 3
  35816. }
  35817. /**
  35818. * Defines a post process to apply tone mapping
  35819. */
  35820. class TonemapPostProcess extends PostProcess {
  35821. private _operator;
  35822. /** Defines the required exposure adjustement */
  35823. exposureAdjustment: number;
  35824. /**
  35825. * Creates a new TonemapPostProcess
  35826. * @param name defines the name of the postprocess
  35827. * @param _operator defines the operator to use
  35828. * @param exposureAdjustment defines the required exposure adjustement
  35829. * @param camera defines the camera to use (can be null)
  35830. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  35831. * @param engine defines the hosting engine (can be ignore if camera is set)
  35832. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  35833. */
  35834. constructor(name: string, _operator: TonemappingOperator,
  35835. /** Defines the required exposure adjustement */
  35836. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  35837. }
  35838. }
  35839. declare module BABYLON {
  35840. /**
  35841. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  35842. */
  35843. class VolumetricLightScatteringPostProcess extends PostProcess {
  35844. private _volumetricLightScatteringPass;
  35845. private _volumetricLightScatteringRTT;
  35846. private _viewPort;
  35847. private _screenCoordinates;
  35848. private _cachedDefines;
  35849. /**
  35850. * If not undefined, the mesh position is computed from the attached node position
  35851. */
  35852. attachedNode: {
  35853. position: Vector3;
  35854. };
  35855. /**
  35856. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  35857. */
  35858. customMeshPosition: Vector3;
  35859. /**
  35860. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  35861. */
  35862. useCustomMeshPosition: boolean;
  35863. /**
  35864. * If the post-process should inverse the light scattering direction
  35865. */
  35866. invert: boolean;
  35867. /**
  35868. * The internal mesh used by the post-process
  35869. */
  35870. mesh: Mesh;
  35871. /**
  35872. * @hidden
  35873. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  35874. */
  35875. useDiffuseColor: boolean;
  35876. /**
  35877. * Array containing the excluded meshes not rendered in the internal pass
  35878. */
  35879. excludedMeshes: AbstractMesh[];
  35880. /**
  35881. * Controls the overall intensity of the post-process
  35882. */
  35883. exposure: number;
  35884. /**
  35885. * Dissipates each sample's contribution in range [0, 1]
  35886. */
  35887. decay: number;
  35888. /**
  35889. * Controls the overall intensity of each sample
  35890. */
  35891. weight: number;
  35892. /**
  35893. * Controls the density of each sample
  35894. */
  35895. density: number;
  35896. /**
  35897. * @constructor
  35898. * @param name The post-process name
  35899. * @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)
  35900. * @param camera The camera that the post-process will be attached to
  35901. * @param mesh The mesh used to create the light scattering
  35902. * @param samples The post-process quality, default 100
  35903. * @param samplingModeThe post-process filtering mode
  35904. * @param engine The babylon engine
  35905. * @param reusable If the post-process is reusable
  35906. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  35907. */
  35908. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  35909. /**
  35910. * Returns the string "VolumetricLightScatteringPostProcess"
  35911. * @returns "VolumetricLightScatteringPostProcess"
  35912. */
  35913. getClassName(): string;
  35914. private _isReady;
  35915. /**
  35916. * Sets the new light position for light scattering effect
  35917. * @param position The new custom light position
  35918. */
  35919. setCustomMeshPosition(position: Vector3): void;
  35920. /**
  35921. * Returns the light position for light scattering effect
  35922. * @return Vector3 The custom light position
  35923. */
  35924. getCustomMeshPosition(): Vector3;
  35925. /**
  35926. * Disposes the internal assets and detaches the post-process from the camera
  35927. */
  35928. dispose(camera: Camera): void;
  35929. /**
  35930. * Returns the render target texture used by the post-process
  35931. * @return the render target texture used by the post-process
  35932. */
  35933. getPass(): RenderTargetTexture;
  35934. private _meshExcluded;
  35935. private _createPass;
  35936. private _updateMeshScreenCoordinates;
  35937. /**
  35938. * Creates a default mesh for the Volumeric Light Scattering post-process
  35939. * @param name The mesh name
  35940. * @param scene The scene where to create the mesh
  35941. * @return the default mesh
  35942. */
  35943. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  35944. }
  35945. }
  35946. declare module BABYLON {
  35947. /**
  35948. * VRDistortionCorrectionPostProcess used for mobile VR
  35949. */
  35950. class VRDistortionCorrectionPostProcess extends PostProcess {
  35951. private _isRightEye;
  35952. private _distortionFactors;
  35953. private _postProcessScaleFactor;
  35954. private _lensCenterOffset;
  35955. private _scaleIn;
  35956. private _scaleFactor;
  35957. private _lensCenter;
  35958. /**
  35959. * Initializes the VRDistortionCorrectionPostProcess
  35960. * @param name The name of the effect.
  35961. * @param camera The camera to apply the render pass to.
  35962. * @param isRightEye If this is for the right eye distortion
  35963. * @param vrMetrics All the required metrics for the VR camera
  35964. */
  35965. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  35966. }
  35967. }
  35968. declare module BABYLON {
  35969. interface Scene {
  35970. /** @hidden (Backing field) */
  35971. _boundingBoxRenderer: BoundingBoxRenderer;
  35972. /** @hidden (Backing field) */
  35973. _forceShowBoundingBoxes: boolean;
  35974. /**
  35975. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  35976. */
  35977. forceShowBoundingBoxes: boolean;
  35978. /**
  35979. * Gets the bounding box renderer associated with the scene
  35980. * @returns a BoundingBoxRenderer
  35981. */
  35982. getBoundingBoxRenderer(): BoundingBoxRenderer;
  35983. }
  35984. interface AbstractMesh {
  35985. /** @hidden (Backing field) */
  35986. _showBoundingBox: boolean;
  35987. /**
  35988. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  35989. */
  35990. showBoundingBox: boolean;
  35991. }
  35992. /**
  35993. * Component responsible of rendering the bounding box of the meshes in a scene.
  35994. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  35995. */
  35996. class BoundingBoxRenderer implements ISceneComponent {
  35997. /**
  35998. * The component name helpfull to identify the component in the list of scene components.
  35999. */
  36000. readonly name: string;
  36001. /**
  36002. * The scene the component belongs to.
  36003. */
  36004. scene: Scene;
  36005. /**
  36006. * Color of the bounding box lines placed in front of an object
  36007. */
  36008. frontColor: Color3;
  36009. /**
  36010. * Color of the bounding box lines placed behind an object
  36011. */
  36012. backColor: Color3;
  36013. /**
  36014. * Defines if the renderer should show the back lines or not
  36015. */
  36016. showBackLines: boolean;
  36017. /**
  36018. * @hidden
  36019. */
  36020. renderList: SmartArray<BoundingBox>;
  36021. private _colorShader;
  36022. private _vertexBuffers;
  36023. private _indexBuffer;
  36024. /**
  36025. * Instantiates a new bounding box renderer in a scene.
  36026. * @param scene the scene the renderer renders in
  36027. */
  36028. constructor(scene: Scene);
  36029. /**
  36030. * Registers the component in a given scene
  36031. */
  36032. register(): void;
  36033. private _evaluateSubMesh;
  36034. private _activeMesh;
  36035. private _prepareRessources;
  36036. private _createIndexBuffer;
  36037. /**
  36038. * Rebuilds the elements related to this component in case of
  36039. * context lost for instance.
  36040. */
  36041. rebuild(): void;
  36042. /**
  36043. * @hidden
  36044. */
  36045. reset(): void;
  36046. /**
  36047. * Render the bounding boxes of a specific rendering group
  36048. * @param renderingGroupId defines the rendering group to render
  36049. */
  36050. render(renderingGroupId: number): void;
  36051. /**
  36052. * In case of occlusion queries, we can render the occlusion bounding box through this method
  36053. * @param mesh Define the mesh to render the occlusion bounding box for
  36054. */
  36055. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  36056. /**
  36057. * Dispose and release the resources attached to this renderer.
  36058. */
  36059. dispose(): void;
  36060. }
  36061. }
  36062. declare module BABYLON {
  36063. /**
  36064. * This represents a depth renderer in Babylon.
  36065. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  36066. */
  36067. class DepthRenderer {
  36068. private _scene;
  36069. private _depthMap;
  36070. private _effect;
  36071. private _cachedDefines;
  36072. private _camera;
  36073. /**
  36074. * Specifiess that the depth renderer will only be used within
  36075. * the camera it is created for.
  36076. * This can help forcing its rendering during the camera processing.
  36077. */
  36078. useOnlyInActiveCamera: boolean;
  36079. /**
  36080. * Instantiates a depth renderer
  36081. * @param scene The scene the renderer belongs to
  36082. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  36083. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  36084. */
  36085. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  36086. /**
  36087. * Creates the depth rendering effect and checks if the effect is ready.
  36088. * @param subMesh The submesh to be used to render the depth map of
  36089. * @param useInstances If multiple world instances should be used
  36090. * @returns if the depth renderer is ready to render the depth map
  36091. */
  36092. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36093. /**
  36094. * Gets the texture which the depth map will be written to.
  36095. * @returns The depth map texture
  36096. */
  36097. getDepthMap(): RenderTargetTexture;
  36098. /**
  36099. * Disposes of the depth renderer.
  36100. */
  36101. dispose(): void;
  36102. }
  36103. }
  36104. declare module BABYLON {
  36105. interface Scene {
  36106. /** @hidden (Backing field) */
  36107. _depthRenderer: {
  36108. [id: string]: DepthRenderer;
  36109. };
  36110. /**
  36111. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  36112. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  36113. * @returns the created depth renderer
  36114. */
  36115. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  36116. /**
  36117. * Disables a depth renderer for a given camera
  36118. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  36119. */
  36120. disableDepthRenderer(camera?: Nullable<Camera>): void;
  36121. }
  36122. /**
  36123. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  36124. * in several rendering techniques.
  36125. */
  36126. class DepthRendererSceneComponent implements ISceneComponent {
  36127. /**
  36128. * The component name helpfull to identify the component in the list of scene components.
  36129. */
  36130. readonly name: string;
  36131. /**
  36132. * The scene the component belongs to.
  36133. */
  36134. scene: Scene;
  36135. /**
  36136. * Creates a new instance of the component for the given scene
  36137. * @param scene Defines the scene to register the component in
  36138. */
  36139. constructor(scene: Scene);
  36140. /**
  36141. * Registers the component in a given scene
  36142. */
  36143. register(): void;
  36144. /**
  36145. * Rebuilds the elements related to this component in case of
  36146. * context lost for instance.
  36147. */
  36148. rebuild(): void;
  36149. /**
  36150. * Disposes the component and the associated ressources
  36151. */
  36152. dispose(): void;
  36153. private _gatherRenderTargets;
  36154. private _gatherActiveCameraRenderTargets;
  36155. }
  36156. }
  36157. declare module BABYLON {
  36158. interface AbstractMesh {
  36159. /**
  36160. * Disables the mesh edge rendering mode
  36161. * @returns the currentAbstractMesh
  36162. */
  36163. disableEdgesRendering(): AbstractMesh;
  36164. /**
  36165. * Enables the edge rendering mode on the mesh.
  36166. * This mode makes the mesh edges visible
  36167. * @param epsilon defines the maximal distance between two angles to detect a face
  36168. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36169. * @returns the currentAbstractMesh
  36170. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36171. */
  36172. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  36173. /**
  36174. * Gets the edgesRenderer associated with the mesh
  36175. */
  36176. edgesRenderer: Nullable<EdgesRenderer>;
  36177. }
  36178. interface LinesMesh {
  36179. /**
  36180. * Enables the edge rendering mode on the mesh.
  36181. * This mode makes the mesh edges visible
  36182. * @param epsilon defines the maximal distance between two angles to detect a face
  36183. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36184. * @returns the currentAbstractMesh
  36185. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36186. */
  36187. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  36188. }
  36189. interface InstancedLinesMesh {
  36190. /**
  36191. * Enables the edge rendering mode on the mesh.
  36192. * This mode makes the mesh edges visible
  36193. * @param epsilon defines the maximal distance between two angles to detect a face
  36194. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36195. * @returns the current InstancedLinesMesh
  36196. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36197. */
  36198. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  36199. }
  36200. /**
  36201. * Defines the minimum contract an Edges renderer should follow.
  36202. */
  36203. interface IEdgesRenderer extends IDisposable {
  36204. /**
  36205. * Gets or sets a boolean indicating if the edgesRenderer is active
  36206. */
  36207. isEnabled: boolean;
  36208. /**
  36209. * Renders the edges of the attached mesh,
  36210. */
  36211. render(): void;
  36212. /**
  36213. * Checks wether or not the edges renderer is ready to render.
  36214. * @return true if ready, otherwise false.
  36215. */
  36216. isReady(): boolean;
  36217. }
  36218. /**
  36219. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  36220. */
  36221. class EdgesRenderer implements IEdgesRenderer {
  36222. /**
  36223. * Define the size of the edges with an orthographic camera
  36224. */
  36225. edgesWidthScalerForOrthographic: number;
  36226. /**
  36227. * Define the size of the edges with a perspective camera
  36228. */
  36229. edgesWidthScalerForPerspective: number;
  36230. protected _source: AbstractMesh;
  36231. protected _linesPositions: number[];
  36232. protected _linesNormals: number[];
  36233. protected _linesIndices: number[];
  36234. protected _epsilon: number;
  36235. protected _indicesCount: number;
  36236. protected _lineShader: ShaderMaterial;
  36237. protected _ib: WebGLBuffer;
  36238. protected _buffers: {
  36239. [key: string]: Nullable<VertexBuffer>;
  36240. };
  36241. protected _checkVerticesInsteadOfIndices: boolean;
  36242. private _meshRebuildObserver;
  36243. private _meshDisposeObserver;
  36244. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  36245. isEnabled: boolean;
  36246. /**
  36247. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  36248. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  36249. * @param source Mesh used to create edges
  36250. * @param epsilon sum of angles in adjacency to check for edge
  36251. * @param checkVerticesInsteadOfIndices
  36252. * @param generateEdgesLines - should generate Lines or only prepare resources.
  36253. */
  36254. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  36255. protected _prepareRessources(): void;
  36256. /** @hidden */
  36257. _rebuild(): void;
  36258. /**
  36259. * Releases the required resources for the edges renderer
  36260. */
  36261. dispose(): void;
  36262. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  36263. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  36264. /**
  36265. * Checks if the pair of p0 and p1 is en edge
  36266. * @param faceIndex
  36267. * @param edge
  36268. * @param faceNormals
  36269. * @param p0
  36270. * @param p1
  36271. * @private
  36272. */
  36273. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  36274. /**
  36275. * push line into the position, normal and index buffer
  36276. * @protected
  36277. */
  36278. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  36279. /**
  36280. * Generates lines edges from adjacencjes
  36281. * @private
  36282. */
  36283. _generateEdgesLines(): void;
  36284. /**
  36285. * Checks wether or not the edges renderer is ready to render.
  36286. * @return true if ready, otherwise false.
  36287. */
  36288. isReady(): boolean;
  36289. /**
  36290. * Renders the edges of the attached mesh,
  36291. */
  36292. render(): void;
  36293. }
  36294. }
  36295. declare module BABYLON {
  36296. /**
  36297. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  36298. */
  36299. class GeometryBufferRenderer {
  36300. /**
  36301. * Constant used to retrieve the position texture index in the G-Buffer textures array
  36302. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  36303. */
  36304. static readonly POSITION_TEXTURE_TYPE: number;
  36305. /**
  36306. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  36307. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  36308. */
  36309. static readonly VELOCITY_TEXTURE_TYPE: number;
  36310. /**
  36311. * Dictionary used to store the previous transformation matrices of each rendered mesh
  36312. * in order to compute objects velocities when enableVelocity is set to "true"
  36313. * @hidden
  36314. */
  36315. _previousTransformationMatrices: {
  36316. [index: number]: Matrix;
  36317. };
  36318. private _scene;
  36319. private _multiRenderTarget;
  36320. private _ratio;
  36321. private _enablePosition;
  36322. private _enableVelocity;
  36323. private _positionIndex;
  36324. private _velocityIndex;
  36325. protected _effect: Effect;
  36326. protected _cachedDefines: string;
  36327. /**
  36328. * Set the render list (meshes to be rendered) used in the G buffer.
  36329. */
  36330. renderList: Mesh[];
  36331. /**
  36332. * Gets wether or not G buffer are supported by the running hardware.
  36333. * This requires draw buffer supports
  36334. */
  36335. readonly isSupported: boolean;
  36336. /**
  36337. * Returns the index of the given texture type in the G-Buffer textures array
  36338. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  36339. * @returns the index of the given texture type in the G-Buffer textures array
  36340. */
  36341. getTextureIndex(textureType: number): number;
  36342. /**
  36343. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  36344. */
  36345. /**
  36346. * Sets whether or not objects positions are enabled for the G buffer.
  36347. */
  36348. enablePosition: boolean;
  36349. /**
  36350. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  36351. */
  36352. /**
  36353. * Sets wether or not objects velocities are enabled for the G buffer.
  36354. */
  36355. enableVelocity: boolean;
  36356. /**
  36357. * Gets the scene associated with the buffer.
  36358. */
  36359. readonly scene: Scene;
  36360. /**
  36361. * Gets the ratio used by the buffer during its creation.
  36362. * How big is the buffer related to the main canvas.
  36363. */
  36364. readonly ratio: number;
  36365. /**
  36366. * Creates a new G Buffer for the scene
  36367. * @param scene The scene the buffer belongs to
  36368. * @param ratio How big is the buffer related to the main canvas.
  36369. */
  36370. constructor(scene: Scene, ratio?: number);
  36371. /**
  36372. * Checks wether everything is ready to render a submesh to the G buffer.
  36373. * @param subMesh the submesh to check readiness for
  36374. * @param useInstances is the mesh drawn using instance or not
  36375. * @returns true if ready otherwise false
  36376. */
  36377. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36378. /**
  36379. * Gets the current underlying G Buffer.
  36380. * @returns the buffer
  36381. */
  36382. getGBuffer(): MultiRenderTarget;
  36383. /**
  36384. * Gets the number of samples used to render the buffer (anti aliasing).
  36385. */
  36386. /**
  36387. * Sets the number of samples used to render the buffer (anti aliasing).
  36388. */
  36389. samples: number;
  36390. /**
  36391. * Disposes the renderer and frees up associated resources.
  36392. */
  36393. dispose(): void;
  36394. protected _createRenderTargets(): void;
  36395. }
  36396. }
  36397. declare module BABYLON {
  36398. interface Scene {
  36399. /** @hidden (Backing field) */
  36400. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  36401. /**
  36402. * Gets or Sets the current geometry buffer associated to the scene.
  36403. */
  36404. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  36405. /**
  36406. * Enables a GeometryBufferRender and associates it with the scene
  36407. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  36408. * @returns the GeometryBufferRenderer
  36409. */
  36410. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  36411. /**
  36412. * Disables the GeometryBufferRender associated with the scene
  36413. */
  36414. disableGeometryBufferRenderer(): void;
  36415. }
  36416. /**
  36417. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  36418. * in several rendering techniques.
  36419. */
  36420. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  36421. /**
  36422. * The component name helpful to identify the component in the list of scene components.
  36423. */
  36424. readonly name: string;
  36425. /**
  36426. * The scene the component belongs to.
  36427. */
  36428. scene: Scene;
  36429. /**
  36430. * Creates a new instance of the component for the given scene
  36431. * @param scene Defines the scene to register the component in
  36432. */
  36433. constructor(scene: Scene);
  36434. /**
  36435. * Registers the component in a given scene
  36436. */
  36437. register(): void;
  36438. /**
  36439. * Rebuilds the elements related to this component in case of
  36440. * context lost for instance.
  36441. */
  36442. rebuild(): void;
  36443. /**
  36444. * Disposes the component and the associated ressources
  36445. */
  36446. dispose(): void;
  36447. private _gatherRenderTargets;
  36448. }
  36449. }
  36450. declare module BABYLON {
  36451. /**
  36452. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  36453. */
  36454. class LineEdgesRenderer extends EdgesRenderer {
  36455. /**
  36456. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  36457. * @param source LineMesh used to generate edges
  36458. * @param epsilon not important (specified angle for edge detection)
  36459. * @param checkVerticesInsteadOfIndices not important for LineMesh
  36460. */
  36461. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  36462. /**
  36463. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  36464. */
  36465. _generateEdgesLines(): void;
  36466. }
  36467. }
  36468. declare module BABYLON {
  36469. interface Scene {
  36470. /** @hidden */
  36471. _outlineRenderer: OutlineRenderer;
  36472. /**
  36473. * Gets the outline renderer associated with the scene
  36474. * @returns a OutlineRenderer
  36475. */
  36476. getOutlineRenderer(): OutlineRenderer;
  36477. }
  36478. interface AbstractMesh {
  36479. /** @hidden (Backing field) */
  36480. _renderOutline: boolean;
  36481. /**
  36482. * Gets or sets a boolean indicating if the outline must be rendered as well
  36483. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  36484. */
  36485. renderOutline: boolean;
  36486. /** @hidden (Backing field) */
  36487. _renderOverlay: boolean;
  36488. /**
  36489. * Gets or sets a boolean indicating if the overlay must be rendered as well
  36490. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  36491. */
  36492. renderOverlay: boolean;
  36493. }
  36494. /**
  36495. * This class is responsible to draw bothe outline/overlay of meshes.
  36496. * It should not be used directly but through the available method on mesh.
  36497. */
  36498. class OutlineRenderer implements ISceneComponent {
  36499. /**
  36500. * The name of the component. Each component must have a unique name.
  36501. */
  36502. name: string;
  36503. /**
  36504. * The scene the component belongs to.
  36505. */
  36506. scene: Scene;
  36507. /**
  36508. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  36509. */
  36510. zOffset: number;
  36511. private _engine;
  36512. private _effect;
  36513. private _cachedDefines;
  36514. private _savedDepthWrite;
  36515. /**
  36516. * Instantiates a new outline renderer. (There could be only one per scene).
  36517. * @param scene Defines the scene it belongs to
  36518. */
  36519. constructor(scene: Scene);
  36520. /**
  36521. * Register the component to one instance of a scene.
  36522. */
  36523. register(): void;
  36524. /**
  36525. * Rebuilds the elements related to this component in case of
  36526. * context lost for instance.
  36527. */
  36528. rebuild(): void;
  36529. /**
  36530. * Disposes the component and the associated ressources.
  36531. */
  36532. dispose(): void;
  36533. /**
  36534. * Renders the outline in the canvas.
  36535. * @param subMesh Defines the sumesh to render
  36536. * @param batch Defines the batch of meshes in case of instances
  36537. * @param useOverlay Defines if the rendering is for the overlay or the outline
  36538. */
  36539. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  36540. /**
  36541. * Returns whether or not the outline renderer is ready for a given submesh.
  36542. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  36543. * @param subMesh Defines the submesh to check readyness for
  36544. * @param useInstances Defines wheter wee are trying to render instances or not
  36545. * @returns true if ready otherwise false
  36546. */
  36547. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  36548. private _beforeRenderingMesh;
  36549. private _afterRenderingMesh;
  36550. }
  36551. }
  36552. declare module BABYLON {
  36553. /**
  36554. * This represents the object necessary to create a rendering group.
  36555. * This is exclusively used and created by the rendering manager.
  36556. * To modify the behavior, you use the available helpers in your scene or meshes.
  36557. * @hidden
  36558. */
  36559. class RenderingGroup {
  36560. index: number;
  36561. private _scene;
  36562. private _opaqueSubMeshes;
  36563. private _transparentSubMeshes;
  36564. private _alphaTestSubMeshes;
  36565. private _depthOnlySubMeshes;
  36566. private _particleSystems;
  36567. private _spriteManagers;
  36568. private _opaqueSortCompareFn;
  36569. private _alphaTestSortCompareFn;
  36570. private _transparentSortCompareFn;
  36571. private _renderOpaque;
  36572. private _renderAlphaTest;
  36573. private _renderTransparent;
  36574. private _edgesRenderers;
  36575. onBeforeTransparentRendering: () => void;
  36576. /**
  36577. * Set the opaque sort comparison function.
  36578. * If null the sub meshes will be render in the order they were created
  36579. */
  36580. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36581. /**
  36582. * Set the alpha test sort comparison function.
  36583. * If null the sub meshes will be render in the order they were created
  36584. */
  36585. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36586. /**
  36587. * Set the transparent sort comparison function.
  36588. * If null the sub meshes will be render in the order they were created
  36589. */
  36590. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  36591. /**
  36592. * Creates a new rendering group.
  36593. * @param index The rendering group index
  36594. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  36595. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  36596. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  36597. */
  36598. 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>);
  36599. /**
  36600. * Render all the sub meshes contained in the group.
  36601. * @param customRenderFunction Used to override the default render behaviour of the group.
  36602. * @returns true if rendered some submeshes.
  36603. */
  36604. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  36605. /**
  36606. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  36607. * @param subMeshes The submeshes to render
  36608. */
  36609. private renderOpaqueSorted;
  36610. /**
  36611. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  36612. * @param subMeshes The submeshes to render
  36613. */
  36614. private renderAlphaTestSorted;
  36615. /**
  36616. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  36617. * @param subMeshes The submeshes to render
  36618. */
  36619. private renderTransparentSorted;
  36620. /**
  36621. * Renders the submeshes in a specified order.
  36622. * @param subMeshes The submeshes to sort before render
  36623. * @param sortCompareFn The comparison function use to sort
  36624. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  36625. * @param transparent Specifies to activate blending if true
  36626. */
  36627. private static renderSorted;
  36628. /**
  36629. * Renders the submeshes in the order they were dispatched (no sort applied).
  36630. * @param subMeshes The submeshes to render
  36631. */
  36632. private static renderUnsorted;
  36633. /**
  36634. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36635. * are rendered back to front if in the same alpha index.
  36636. *
  36637. * @param a The first submesh
  36638. * @param b The second submesh
  36639. * @returns The result of the comparison
  36640. */
  36641. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  36642. /**
  36643. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36644. * are rendered back to front.
  36645. *
  36646. * @param a The first submesh
  36647. * @param b The second submesh
  36648. * @returns The result of the comparison
  36649. */
  36650. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  36651. /**
  36652. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  36653. * are rendered front to back (prevent overdraw).
  36654. *
  36655. * @param a The first submesh
  36656. * @param b The second submesh
  36657. * @returns The result of the comparison
  36658. */
  36659. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  36660. /**
  36661. * Resets the different lists of submeshes to prepare a new frame.
  36662. */
  36663. prepare(): void;
  36664. dispose(): void;
  36665. /**
  36666. * Inserts the submesh in its correct queue depending on its material.
  36667. * @param subMesh The submesh to dispatch
  36668. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36669. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36670. */
  36671. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36672. dispatchSprites(spriteManager: ISpriteManager): void;
  36673. dispatchParticles(particleSystem: IParticleSystem): void;
  36674. private _renderParticles;
  36675. private _renderSprites;
  36676. }
  36677. }
  36678. declare module BABYLON {
  36679. /**
  36680. * Interface describing the different options available in the rendering manager
  36681. * regarding Auto Clear between groups.
  36682. */
  36683. interface IRenderingManagerAutoClearSetup {
  36684. /**
  36685. * Defines whether or not autoclear is enable.
  36686. */
  36687. autoClear: boolean;
  36688. /**
  36689. * Defines whether or not to autoclear the depth buffer.
  36690. */
  36691. depth: boolean;
  36692. /**
  36693. * Defines whether or not to autoclear the stencil buffer.
  36694. */
  36695. stencil: boolean;
  36696. }
  36697. /**
  36698. * This is the manager responsible of all the rendering for meshes sprites and particles.
  36699. * It is enable to manage the different groups as well as the different necessary sort functions.
  36700. * This should not be used directly aside of the few static configurations
  36701. */
  36702. class RenderingManager {
  36703. /**
  36704. * The max id used for rendering groups (not included)
  36705. */
  36706. static MAX_RENDERINGGROUPS: number;
  36707. /**
  36708. * The min id used for rendering groups (included)
  36709. */
  36710. static MIN_RENDERINGGROUPS: number;
  36711. /**
  36712. * Used to globally prevent autoclearing scenes.
  36713. */
  36714. static AUTOCLEAR: boolean;
  36715. /**
  36716. * @hidden
  36717. */
  36718. _useSceneAutoClearSetup: boolean;
  36719. private _scene;
  36720. private _renderingGroups;
  36721. private _depthStencilBufferAlreadyCleaned;
  36722. private _autoClearDepthStencil;
  36723. private _customOpaqueSortCompareFn;
  36724. private _customAlphaTestSortCompareFn;
  36725. private _customTransparentSortCompareFn;
  36726. private _renderingGroupInfo;
  36727. /**
  36728. * Instantiates a new rendering group for a particular scene
  36729. * @param scene Defines the scene the groups belongs to
  36730. */
  36731. constructor(scene: Scene);
  36732. private _clearDepthStencilBuffer;
  36733. /**
  36734. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  36735. * @hidden
  36736. */
  36737. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  36738. /**
  36739. * Resets the different information of the group to prepare a new frame
  36740. * @hidden
  36741. */
  36742. reset(): void;
  36743. /**
  36744. * Dispose and release the group and its associated resources.
  36745. * @hidden
  36746. */
  36747. dispose(): void;
  36748. /**
  36749. * Clear the info related to rendering groups preventing retention points during dispose.
  36750. */
  36751. freeRenderingGroups(): void;
  36752. private _prepareRenderingGroup;
  36753. /**
  36754. * Add a sprite manager to the rendering manager in order to render it this frame.
  36755. * @param spriteManager Define the sprite manager to render
  36756. */
  36757. dispatchSprites(spriteManager: ISpriteManager): void;
  36758. /**
  36759. * Add a particle system to the rendering manager in order to render it this frame.
  36760. * @param particleSystem Define the particle system to render
  36761. */
  36762. dispatchParticles(particleSystem: IParticleSystem): void;
  36763. /**
  36764. * Add a submesh to the manager in order to render it this frame
  36765. * @param subMesh The submesh to dispatch
  36766. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  36767. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  36768. */
  36769. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  36770. /**
  36771. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36772. * This allowed control for front to back rendering or reversly depending of the special needs.
  36773. *
  36774. * @param renderingGroupId The rendering group id corresponding to its index
  36775. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36776. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36777. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36778. */
  36779. 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;
  36780. /**
  36781. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36782. *
  36783. * @param renderingGroupId The rendering group id corresponding to its index
  36784. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36785. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36786. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36787. */
  36788. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36789. /**
  36790. * Gets the current auto clear configuration for one rendering group of the rendering
  36791. * manager.
  36792. * @param index the rendering group index to get the information for
  36793. * @returns The auto clear setup for the requested rendering group
  36794. */
  36795. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36796. }
  36797. }
  36798. declare module BABYLON {
  36799. /**
  36800. * Renders a layer on top of an existing scene
  36801. */
  36802. class UtilityLayerRenderer implements IDisposable {
  36803. /** the original scene that will be rendered on top of */
  36804. originalScene: Scene;
  36805. private _pointerCaptures;
  36806. private _lastPointerEvents;
  36807. private static _DefaultUtilityLayer;
  36808. private static _DefaultKeepDepthUtilityLayer;
  36809. /**
  36810. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  36811. */
  36812. pickUtilitySceneFirst: boolean;
  36813. /**
  36814. * 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)
  36815. */
  36816. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  36817. /**
  36818. * 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)
  36819. */
  36820. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  36821. /**
  36822. * The scene that is rendered on top of the original scene
  36823. */
  36824. utilityLayerScene: Scene;
  36825. /**
  36826. * If the utility layer should automatically be rendered on top of existing scene
  36827. */
  36828. shouldRender: boolean;
  36829. /**
  36830. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  36831. */
  36832. onlyCheckPointerDownEvents: boolean;
  36833. /**
  36834. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  36835. */
  36836. processAllEvents: boolean;
  36837. /**
  36838. * Observable raised when the pointer move from the utility layer scene to the main scene
  36839. */
  36840. onPointerOutObservable: Observable<number>;
  36841. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  36842. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  36843. private _afterRenderObserver;
  36844. private _sceneDisposeObserver;
  36845. private _originalPointerObserver;
  36846. /**
  36847. * Instantiates a UtilityLayerRenderer
  36848. * @param originalScene the original scene that will be rendered on top of
  36849. * @param handleEvents boolean indicating if the utility layer should handle events
  36850. */
  36851. constructor(
  36852. /** the original scene that will be rendered on top of */
  36853. originalScene: Scene, handleEvents?: boolean);
  36854. private _notifyObservers;
  36855. /**
  36856. * Renders the utility layers scene on top of the original scene
  36857. */
  36858. render(): void;
  36859. /**
  36860. * Disposes of the renderer
  36861. */
  36862. dispose(): void;
  36863. private _updateCamera;
  36864. }
  36865. }
  36866. declare module BABYLON {
  36867. /**
  36868. * Class used to represent a sprite
  36869. * @see http://doc.babylonjs.com/babylon101/sprites
  36870. */
  36871. class Sprite {
  36872. /** defines the name */
  36873. name: string;
  36874. /** Gets or sets the current world position */
  36875. position: Vector3;
  36876. /** Gets or sets the main color */
  36877. color: Color4;
  36878. /** Gets or sets the width */
  36879. width: number;
  36880. /** Gets or sets the height */
  36881. height: number;
  36882. /** Gets or sets rotation angle */
  36883. angle: number;
  36884. /** Gets or sets the cell index in the sprite sheet */
  36885. cellIndex: number;
  36886. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  36887. invertU: number;
  36888. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  36889. invertV: number;
  36890. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  36891. disposeWhenFinishedAnimating: boolean;
  36892. /** Gets the list of attached animations */
  36893. animations: Animation[];
  36894. /** Gets or sets a boolean indicating if the sprite can be picked */
  36895. isPickable: boolean;
  36896. /**
  36897. * Gets or sets the associated action manager
  36898. */
  36899. actionManager: Nullable<ActionManager>;
  36900. private _animationStarted;
  36901. private _loopAnimation;
  36902. private _fromIndex;
  36903. private _toIndex;
  36904. private _delay;
  36905. private _direction;
  36906. private _manager;
  36907. private _time;
  36908. private _onAnimationEnd;
  36909. /**
  36910. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  36911. */
  36912. isVisible: boolean;
  36913. /**
  36914. * Gets or sets the sprite size
  36915. */
  36916. size: number;
  36917. /**
  36918. * Creates a new Sprite
  36919. * @param name defines the name
  36920. * @param manager defines the manager
  36921. */
  36922. constructor(
  36923. /** defines the name */
  36924. name: string, manager: ISpriteManager);
  36925. /**
  36926. * Starts an animation
  36927. * @param from defines the initial key
  36928. * @param to defines the end key
  36929. * @param loop defines if the animation must loop
  36930. * @param delay defines the start delay (in ms)
  36931. * @param onAnimationEnd defines a callback to call when animation ends
  36932. */
  36933. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  36934. /** Stops current animation (if any) */
  36935. stopAnimation(): void;
  36936. /** @hidden */
  36937. _animate(deltaTime: number): void;
  36938. /** Release associated resources */
  36939. dispose(): void;
  36940. }
  36941. }
  36942. declare module BABYLON {
  36943. /**
  36944. * Defines the minimum interface to fullfil in order to be a sprite manager.
  36945. */
  36946. interface ISpriteManager extends IDisposable {
  36947. /**
  36948. * Restricts the camera to viewing objects with the same layerMask.
  36949. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  36950. */
  36951. layerMask: number;
  36952. /**
  36953. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36954. */
  36955. isPickable: boolean;
  36956. /**
  36957. * Specifies the rendering group id for this mesh (0 by default)
  36958. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36959. */
  36960. renderingGroupId: number;
  36961. /**
  36962. * Defines the list of sprites managed by the manager.
  36963. */
  36964. sprites: Array<Sprite>;
  36965. /**
  36966. * Tests the intersection of a sprite with a specific ray.
  36967. * @param ray The ray we are sending to test the collision
  36968. * @param camera The camera space we are sending rays in
  36969. * @param predicate A predicate allowing excluding sprites from the list of object to test
  36970. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  36971. * @returns picking info or null.
  36972. */
  36973. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36974. /**
  36975. * Renders the list of sprites on screen.
  36976. */
  36977. render(): void;
  36978. }
  36979. /**
  36980. * Class used to manage multiple sprites on the same spritesheet
  36981. * @see http://doc.babylonjs.com/babylon101/sprites
  36982. */
  36983. class SpriteManager implements ISpriteManager {
  36984. /** defines the manager's name */
  36985. name: string;
  36986. /** Gets the list of sprites */
  36987. sprites: Sprite[];
  36988. /** Gets or sets the rendering group id (0 by default) */
  36989. renderingGroupId: number;
  36990. /** Gets or sets camera layer mask */
  36991. layerMask: number;
  36992. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  36993. fogEnabled: boolean;
  36994. /** Gets or sets a boolean indicating if the sprites are pickable */
  36995. isPickable: boolean;
  36996. /** Defines the default width of a cell in the spritesheet */
  36997. cellWidth: number;
  36998. /** Defines the default height of a cell in the spritesheet */
  36999. cellHeight: number;
  37000. /**
  37001. * An event triggered when the manager is disposed.
  37002. */
  37003. onDisposeObservable: Observable<SpriteManager>;
  37004. private _onDisposeObserver;
  37005. /**
  37006. * Callback called when the manager is disposed
  37007. */
  37008. onDispose: () => void;
  37009. private _capacity;
  37010. private _spriteTexture;
  37011. private _epsilon;
  37012. private _scene;
  37013. private _vertexData;
  37014. private _buffer;
  37015. private _vertexBuffers;
  37016. private _indexBuffer;
  37017. private _effectBase;
  37018. private _effectFog;
  37019. /**
  37020. * Gets or sets the spritesheet texture
  37021. */
  37022. texture: Texture;
  37023. /**
  37024. * Creates a new sprite manager
  37025. * @param name defines the manager's name
  37026. * @param imgUrl defines the sprite sheet url
  37027. * @param capacity defines the maximum allowed number of sprites
  37028. * @param cellSize defines the size of a sprite cell
  37029. * @param scene defines the hosting scene
  37030. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  37031. * @param samplingMode defines the smapling mode to use with spritesheet
  37032. */
  37033. constructor(
  37034. /** defines the manager's name */
  37035. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  37036. private _appendSpriteVertex;
  37037. /**
  37038. * Intersects the sprites with a ray
  37039. * @param ray defines the ray to intersect with
  37040. * @param camera defines the current active camera
  37041. * @param predicate defines a predicate used to select candidate sprites
  37042. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  37043. * @returns null if no hit or a PickingInfo
  37044. */
  37045. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  37046. /**
  37047. * Render all child sprites
  37048. */
  37049. render(): void;
  37050. /**
  37051. * Release associated resources
  37052. */
  37053. dispose(): void;
  37054. }
  37055. }
  37056. declare module BABYLON {
  37057. interface Scene {
  37058. /** @hidden */
  37059. _pointerOverSprite: Nullable<Sprite>;
  37060. /** @hidden */
  37061. _pickedDownSprite: Nullable<Sprite>;
  37062. /** @hidden */
  37063. _tempSpritePickingRay: Nullable<Ray>;
  37064. /**
  37065. * All of the sprite managers added to this scene
  37066. * @see http://doc.babylonjs.com/babylon101/sprites
  37067. */
  37068. spriteManagers: Array<ISpriteManager>;
  37069. /**
  37070. * An event triggered when sprites rendering is about to start
  37071. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  37072. */
  37073. onBeforeSpritesRenderingObservable: Observable<Scene>;
  37074. /**
  37075. * An event triggered when sprites rendering is done
  37076. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  37077. */
  37078. onAfterSpritesRenderingObservable: Observable<Scene>;
  37079. /** @hidden */
  37080. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37081. /** Launch a ray to try to pick a sprite in the scene
  37082. * @param x position on screen
  37083. * @param y position on screen
  37084. * @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
  37085. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37086. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37087. * @returns a PickingInfo
  37088. */
  37089. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37090. /** Use the given ray to pick a sprite in the scene
  37091. * @param ray The ray (in world space) to use to pick meshes
  37092. * @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
  37093. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37094. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  37095. * @returns a PickingInfo
  37096. */
  37097. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  37098. /**
  37099. * Force the sprite under the pointer
  37100. * @param sprite defines the sprite to use
  37101. */
  37102. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  37103. /**
  37104. * Gets the sprite under the pointer
  37105. * @returns a Sprite or null if no sprite is under the pointer
  37106. */
  37107. getPointerOverSprite(): Nullable<Sprite>;
  37108. }
  37109. /**
  37110. * Defines the sprite scene component responsible to manage sprites
  37111. * in a given scene.
  37112. */
  37113. class SpriteSceneComponent implements ISceneComponent {
  37114. /**
  37115. * The component name helpfull to identify the component in the list of scene components.
  37116. */
  37117. readonly name: string;
  37118. /**
  37119. * The scene the component belongs to.
  37120. */
  37121. scene: Scene;
  37122. /** @hidden */
  37123. private _spritePredicate;
  37124. /**
  37125. * Creates a new instance of the component for the given scene
  37126. * @param scene Defines the scene to register the component in
  37127. */
  37128. constructor(scene: Scene);
  37129. /**
  37130. * Registers the component in a given scene
  37131. */
  37132. register(): void;
  37133. /**
  37134. * Rebuilds the elements related to this component in case of
  37135. * context lost for instance.
  37136. */
  37137. rebuild(): void;
  37138. /**
  37139. * Disposes the component and the associated ressources.
  37140. */
  37141. dispose(): void;
  37142. private _pickSpriteButKeepRay;
  37143. private _pointerMove;
  37144. private _pointerDown;
  37145. private _pointerUp;
  37146. }
  37147. }
  37148. declare module BABYLON {
  37149. /**
  37150. * @hidden
  37151. **/
  37152. class _AlphaState {
  37153. private _isAlphaBlendDirty;
  37154. private _isBlendFunctionParametersDirty;
  37155. private _isBlendEquationParametersDirty;
  37156. private _isBlendConstantsDirty;
  37157. private _alphaBlend;
  37158. private _blendFunctionParameters;
  37159. private _blendEquationParameters;
  37160. private _blendConstants;
  37161. /**
  37162. * Initializes the state.
  37163. */
  37164. constructor();
  37165. readonly isDirty: boolean;
  37166. alphaBlend: boolean;
  37167. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  37168. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  37169. setAlphaEquationParameters(rgb: number, alpha: number): void;
  37170. reset(): void;
  37171. apply(gl: WebGLRenderingContext): void;
  37172. }
  37173. }
  37174. declare module BABYLON {
  37175. /**
  37176. * @hidden
  37177. **/
  37178. class _DepthCullingState {
  37179. private _isDepthTestDirty;
  37180. private _isDepthMaskDirty;
  37181. private _isDepthFuncDirty;
  37182. private _isCullFaceDirty;
  37183. private _isCullDirty;
  37184. private _isZOffsetDirty;
  37185. private _isFrontFaceDirty;
  37186. private _depthTest;
  37187. private _depthMask;
  37188. private _depthFunc;
  37189. private _cull;
  37190. private _cullFace;
  37191. private _zOffset;
  37192. private _frontFace;
  37193. /**
  37194. * Initializes the state.
  37195. */
  37196. constructor();
  37197. readonly isDirty: boolean;
  37198. zOffset: number;
  37199. cullFace: Nullable<number>;
  37200. cull: Nullable<boolean>;
  37201. depthFunc: Nullable<number>;
  37202. depthMask: boolean;
  37203. depthTest: boolean;
  37204. frontFace: Nullable<number>;
  37205. reset(): void;
  37206. apply(gl: WebGLRenderingContext): void;
  37207. }
  37208. }
  37209. declare module BABYLON {
  37210. /**
  37211. * @hidden
  37212. **/
  37213. class _StencilState {
  37214. private _isStencilTestDirty;
  37215. private _isStencilMaskDirty;
  37216. private _isStencilFuncDirty;
  37217. private _isStencilOpDirty;
  37218. private _stencilTest;
  37219. private _stencilMask;
  37220. private _stencilFunc;
  37221. private _stencilFuncRef;
  37222. private _stencilFuncMask;
  37223. private _stencilOpStencilFail;
  37224. private _stencilOpDepthFail;
  37225. private _stencilOpStencilDepthPass;
  37226. readonly isDirty: boolean;
  37227. stencilFunc: number;
  37228. stencilFuncRef: number;
  37229. stencilFuncMask: number;
  37230. stencilOpStencilFail: number;
  37231. stencilOpDepthFail: number;
  37232. stencilOpStencilDepthPass: number;
  37233. stencilMask: number;
  37234. stencilTest: boolean;
  37235. constructor();
  37236. reset(): void;
  37237. apply(gl: WebGLRenderingContext): void;
  37238. }
  37239. }
  37240. declare module BABYLON {
  37241. /**
  37242. * Class used to evalaute queries containing `and` and `or` operators
  37243. */
  37244. class AndOrNotEvaluator {
  37245. /**
  37246. * Evaluate a query
  37247. * @param query defines the query to evaluate
  37248. * @param evaluateCallback defines the callback used to filter result
  37249. * @returns true if the query matches
  37250. */
  37251. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  37252. private static _HandleParenthesisContent;
  37253. private static _SimplifyNegation;
  37254. }
  37255. }
  37256. declare module BABYLON {
  37257. /**
  37258. * Defines the list of states available for a task inside a AssetsManager
  37259. */
  37260. enum AssetTaskState {
  37261. /**
  37262. * Initialization
  37263. */
  37264. INIT = 0,
  37265. /**
  37266. * Running
  37267. */
  37268. RUNNING = 1,
  37269. /**
  37270. * Done
  37271. */
  37272. DONE = 2,
  37273. /**
  37274. * Error
  37275. */
  37276. ERROR = 3
  37277. }
  37278. /**
  37279. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  37280. */
  37281. abstract class AbstractAssetTask {
  37282. /**
  37283. * Task name
  37284. */ name: string;
  37285. /**
  37286. * Callback called when the task is successful
  37287. */
  37288. onSuccess: (task: any) => void;
  37289. /**
  37290. * Callback called when the task is not successful
  37291. */
  37292. onError: (task: any, message?: string, exception?: any) => void;
  37293. /**
  37294. * Creates a new AssetsManager
  37295. * @param name defines the name of the task
  37296. */
  37297. constructor(
  37298. /**
  37299. * Task name
  37300. */ name: string);
  37301. private _isCompleted;
  37302. private _taskState;
  37303. private _errorObject;
  37304. /**
  37305. * Get if the task is completed
  37306. */
  37307. readonly isCompleted: boolean;
  37308. /**
  37309. * Gets the current state of the task
  37310. */
  37311. readonly taskState: AssetTaskState;
  37312. /**
  37313. * Gets the current error object (if task is in error)
  37314. */
  37315. readonly errorObject: {
  37316. message?: string;
  37317. exception?: any;
  37318. };
  37319. /**
  37320. * Internal only
  37321. * @hidden
  37322. */
  37323. _setErrorObject(message?: string, exception?: any): void;
  37324. /**
  37325. * Execute the current task
  37326. * @param scene defines the scene where you want your assets to be loaded
  37327. * @param onSuccess is a callback called when the task is successfully executed
  37328. * @param onError is a callback called if an error occurs
  37329. */
  37330. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37331. /**
  37332. * Execute the current task
  37333. * @param scene defines the scene where you want your assets to be loaded
  37334. * @param onSuccess is a callback called when the task is successfully executed
  37335. * @param onError is a callback called if an error occurs
  37336. */
  37337. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37338. /**
  37339. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  37340. * This can be used with failed tasks that have the reason for failure fixed.
  37341. */
  37342. reset(): void;
  37343. private onErrorCallback;
  37344. private onDoneCallback;
  37345. }
  37346. /**
  37347. * Define the interface used by progress events raised during assets loading
  37348. */
  37349. interface IAssetsProgressEvent {
  37350. /**
  37351. * Defines the number of remaining tasks to process
  37352. */
  37353. remainingCount: number;
  37354. /**
  37355. * Defines the total number of tasks
  37356. */
  37357. totalCount: number;
  37358. /**
  37359. * Defines the task that was just processed
  37360. */
  37361. task: AbstractAssetTask;
  37362. }
  37363. /**
  37364. * Class used to share progress information about assets loading
  37365. */
  37366. class AssetsProgressEvent implements IAssetsProgressEvent {
  37367. /**
  37368. * Defines the number of remaining tasks to process
  37369. */
  37370. remainingCount: number;
  37371. /**
  37372. * Defines the total number of tasks
  37373. */
  37374. totalCount: number;
  37375. /**
  37376. * Defines the task that was just processed
  37377. */
  37378. task: AbstractAssetTask;
  37379. /**
  37380. * Creates a AssetsProgressEvent
  37381. * @param remainingCount defines the number of remaining tasks to process
  37382. * @param totalCount defines the total number of tasks
  37383. * @param task defines the task that was just processed
  37384. */
  37385. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  37386. }
  37387. /**
  37388. * Define a task used by AssetsManager to load meshes
  37389. */
  37390. class MeshAssetTask extends AbstractAssetTask {
  37391. /**
  37392. * Defines the name of the task
  37393. */
  37394. name: string;
  37395. /**
  37396. * Defines the list of mesh's names you want to load
  37397. */
  37398. meshesNames: any;
  37399. /**
  37400. * Defines the root url to use as a base to load your meshes and associated resources
  37401. */
  37402. rootUrl: string;
  37403. /**
  37404. * Defines the filename of the scene to load from
  37405. */
  37406. sceneFilename: string;
  37407. /**
  37408. * Gets the list of loaded meshes
  37409. */
  37410. loadedMeshes: Array<AbstractMesh>;
  37411. /**
  37412. * Gets the list of loaded particle systems
  37413. */
  37414. loadedParticleSystems: Array<IParticleSystem>;
  37415. /**
  37416. * Gets the list of loaded skeletons
  37417. */
  37418. loadedSkeletons: Array<Skeleton>;
  37419. /**
  37420. * Callback called when the task is successful
  37421. */
  37422. onSuccess: (task: MeshAssetTask) => void;
  37423. /**
  37424. * Callback called when the task is successful
  37425. */
  37426. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  37427. /**
  37428. * Creates a new MeshAssetTask
  37429. * @param name defines the name of the task
  37430. * @param meshesNames defines the list of mesh's names you want to load
  37431. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  37432. * @param sceneFilename defines the filename of the scene to load from
  37433. */
  37434. constructor(
  37435. /**
  37436. * Defines the name of the task
  37437. */
  37438. name: string,
  37439. /**
  37440. * Defines the list of mesh's names you want to load
  37441. */
  37442. meshesNames: any,
  37443. /**
  37444. * Defines the root url to use as a base to load your meshes and associated resources
  37445. */
  37446. rootUrl: string,
  37447. /**
  37448. * Defines the filename of the scene to load from
  37449. */
  37450. sceneFilename: string);
  37451. /**
  37452. * Execute the current task
  37453. * @param scene defines the scene where you want your assets to be loaded
  37454. * @param onSuccess is a callback called when the task is successfully executed
  37455. * @param onError is a callback called if an error occurs
  37456. */
  37457. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37458. }
  37459. /**
  37460. * Define a task used by AssetsManager to load text content
  37461. */
  37462. class TextFileAssetTask extends AbstractAssetTask {
  37463. /**
  37464. * Defines the name of the task
  37465. */
  37466. name: string;
  37467. /**
  37468. * Defines the location of the file to load
  37469. */
  37470. url: string;
  37471. /**
  37472. * Gets the loaded text string
  37473. */
  37474. text: string;
  37475. /**
  37476. * Callback called when the task is successful
  37477. */
  37478. onSuccess: (task: TextFileAssetTask) => void;
  37479. /**
  37480. * Callback called when the task is successful
  37481. */
  37482. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  37483. /**
  37484. * Creates a new TextFileAssetTask object
  37485. * @param name defines the name of the task
  37486. * @param url defines the location of the file to load
  37487. */
  37488. constructor(
  37489. /**
  37490. * Defines the name of the task
  37491. */
  37492. name: string,
  37493. /**
  37494. * Defines the location of the file to load
  37495. */
  37496. url: string);
  37497. /**
  37498. * Execute the current task
  37499. * @param scene defines the scene where you want your assets to be loaded
  37500. * @param onSuccess is a callback called when the task is successfully executed
  37501. * @param onError is a callback called if an error occurs
  37502. */
  37503. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37504. }
  37505. /**
  37506. * Define a task used by AssetsManager to load binary data
  37507. */
  37508. class BinaryFileAssetTask extends AbstractAssetTask {
  37509. /**
  37510. * Defines the name of the task
  37511. */
  37512. name: string;
  37513. /**
  37514. * Defines the location of the file to load
  37515. */
  37516. url: string;
  37517. /**
  37518. * Gets the lodaded data (as an array buffer)
  37519. */
  37520. data: ArrayBuffer;
  37521. /**
  37522. * Callback called when the task is successful
  37523. */
  37524. onSuccess: (task: BinaryFileAssetTask) => void;
  37525. /**
  37526. * Callback called when the task is successful
  37527. */
  37528. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  37529. /**
  37530. * Creates a new BinaryFileAssetTask object
  37531. * @param name defines the name of the new task
  37532. * @param url defines the location of the file to load
  37533. */
  37534. constructor(
  37535. /**
  37536. * Defines the name of the task
  37537. */
  37538. name: string,
  37539. /**
  37540. * Defines the location of the file to load
  37541. */
  37542. url: string);
  37543. /**
  37544. * Execute the current task
  37545. * @param scene defines the scene where you want your assets to be loaded
  37546. * @param onSuccess is a callback called when the task is successfully executed
  37547. * @param onError is a callback called if an error occurs
  37548. */
  37549. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37550. }
  37551. /**
  37552. * Define a task used by AssetsManager to load images
  37553. */
  37554. class ImageAssetTask extends AbstractAssetTask {
  37555. /**
  37556. * Defines the name of the task
  37557. */
  37558. name: string;
  37559. /**
  37560. * Defines the location of the image to load
  37561. */
  37562. url: string;
  37563. /**
  37564. * Gets the loaded images
  37565. */
  37566. image: HTMLImageElement;
  37567. /**
  37568. * Callback called when the task is successful
  37569. */
  37570. onSuccess: (task: ImageAssetTask) => void;
  37571. /**
  37572. * Callback called when the task is successful
  37573. */
  37574. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  37575. /**
  37576. * Creates a new ImageAssetTask
  37577. * @param name defines the name of the task
  37578. * @param url defines the location of the image to load
  37579. */
  37580. constructor(
  37581. /**
  37582. * Defines the name of the task
  37583. */
  37584. name: string,
  37585. /**
  37586. * Defines the location of the image to load
  37587. */
  37588. url: string);
  37589. /**
  37590. * Execute the current task
  37591. * @param scene defines the scene where you want your assets to be loaded
  37592. * @param onSuccess is a callback called when the task is successfully executed
  37593. * @param onError is a callback called if an error occurs
  37594. */
  37595. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37596. }
  37597. /**
  37598. * Defines the interface used by texture loading tasks
  37599. */
  37600. interface ITextureAssetTask<TEX extends BaseTexture> {
  37601. /**
  37602. * Gets the loaded texture
  37603. */
  37604. texture: TEX;
  37605. }
  37606. /**
  37607. * Define a task used by AssetsManager to load 2D textures
  37608. */
  37609. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  37610. /**
  37611. * Defines the name of the task
  37612. */
  37613. name: string;
  37614. /**
  37615. * Defines the location of the file to load
  37616. */
  37617. url: string;
  37618. /**
  37619. * Defines if mipmap should not be generated (default is false)
  37620. */
  37621. noMipmap?: boolean | undefined;
  37622. /**
  37623. * Defines if texture must be inverted on Y axis (default is false)
  37624. */
  37625. invertY?: boolean | undefined;
  37626. /**
  37627. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37628. */
  37629. samplingMode: number;
  37630. /**
  37631. * Gets the loaded texture
  37632. */
  37633. texture: Texture;
  37634. /**
  37635. * Callback called when the task is successful
  37636. */
  37637. onSuccess: (task: TextureAssetTask) => void;
  37638. /**
  37639. * Callback called when the task is successful
  37640. */
  37641. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  37642. /**
  37643. * Creates a new TextureAssetTask object
  37644. * @param name defines the name of the task
  37645. * @param url defines the location of the file to load
  37646. * @param noMipmap defines if mipmap should not be generated (default is false)
  37647. * @param invertY defines if texture must be inverted on Y axis (default is false)
  37648. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37649. */
  37650. constructor(
  37651. /**
  37652. * Defines the name of the task
  37653. */
  37654. name: string,
  37655. /**
  37656. * Defines the location of the file to load
  37657. */
  37658. url: string,
  37659. /**
  37660. * Defines if mipmap should not be generated (default is false)
  37661. */
  37662. noMipmap?: boolean | undefined,
  37663. /**
  37664. * Defines if texture must be inverted on Y axis (default is false)
  37665. */
  37666. invertY?: boolean | undefined,
  37667. /**
  37668. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37669. */
  37670. samplingMode?: number);
  37671. /**
  37672. * Execute the current task
  37673. * @param scene defines the scene where you want your assets to be loaded
  37674. * @param onSuccess is a callback called when the task is successfully executed
  37675. * @param onError is a callback called if an error occurs
  37676. */
  37677. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37678. }
  37679. /**
  37680. * Define a task used by AssetsManager to load cube textures
  37681. */
  37682. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  37683. /**
  37684. * Defines the name of the task
  37685. */
  37686. name: string;
  37687. /**
  37688. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37689. */
  37690. url: string;
  37691. /**
  37692. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37693. */
  37694. extensions?: string[] | undefined;
  37695. /**
  37696. * Defines if mipmaps should not be generated (default is false)
  37697. */
  37698. noMipmap?: boolean | undefined;
  37699. /**
  37700. * Defines the explicit list of files (undefined by default)
  37701. */
  37702. files?: string[] | undefined;
  37703. /**
  37704. * Gets the loaded texture
  37705. */
  37706. texture: CubeTexture;
  37707. /**
  37708. * Callback called when the task is successful
  37709. */
  37710. onSuccess: (task: CubeTextureAssetTask) => void;
  37711. /**
  37712. * Callback called when the task is successful
  37713. */
  37714. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  37715. /**
  37716. * Creates a new CubeTextureAssetTask
  37717. * @param name defines the name of the task
  37718. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37719. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37720. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37721. * @param files defines the explicit list of files (undefined by default)
  37722. */
  37723. constructor(
  37724. /**
  37725. * Defines the name of the task
  37726. */
  37727. name: string,
  37728. /**
  37729. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37730. */
  37731. url: string,
  37732. /**
  37733. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37734. */
  37735. extensions?: string[] | undefined,
  37736. /**
  37737. * Defines if mipmaps should not be generated (default is false)
  37738. */
  37739. noMipmap?: boolean | undefined,
  37740. /**
  37741. * Defines the explicit list of files (undefined by default)
  37742. */
  37743. files?: string[] | undefined);
  37744. /**
  37745. * Execute the current task
  37746. * @param scene defines the scene where you want your assets to be loaded
  37747. * @param onSuccess is a callback called when the task is successfully executed
  37748. * @param onError is a callback called if an error occurs
  37749. */
  37750. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37751. }
  37752. /**
  37753. * Define a task used by AssetsManager to load HDR cube textures
  37754. */
  37755. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  37756. /**
  37757. * Defines the name of the task
  37758. */
  37759. name: string;
  37760. /**
  37761. * Defines the location of the file to load
  37762. */
  37763. url: string;
  37764. /**
  37765. * Defines the desired size (the more it increases the longer the generation will be)
  37766. */
  37767. size: number;
  37768. /**
  37769. * Defines if mipmaps should not be generated (default is false)
  37770. */
  37771. noMipmap: boolean;
  37772. /**
  37773. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37774. */
  37775. generateHarmonics: boolean;
  37776. /**
  37777. * 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)
  37778. */
  37779. gammaSpace: boolean;
  37780. /**
  37781. * Internal Use Only
  37782. */
  37783. reserved: boolean;
  37784. /**
  37785. * Gets the loaded texture
  37786. */
  37787. texture: HDRCubeTexture;
  37788. /**
  37789. * Callback called when the task is successful
  37790. */
  37791. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  37792. /**
  37793. * Callback called when the task is successful
  37794. */
  37795. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  37796. /**
  37797. * Creates a new HDRCubeTextureAssetTask object
  37798. * @param name defines the name of the task
  37799. * @param url defines the location of the file to load
  37800. * @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.
  37801. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37802. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37803. * @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)
  37804. * @param reserved Internal use only
  37805. */
  37806. constructor(
  37807. /**
  37808. * Defines the name of the task
  37809. */
  37810. name: string,
  37811. /**
  37812. * Defines the location of the file to load
  37813. */
  37814. url: string,
  37815. /**
  37816. * Defines the desired size (the more it increases the longer the generation will be)
  37817. */
  37818. size: number,
  37819. /**
  37820. * Defines if mipmaps should not be generated (default is false)
  37821. */
  37822. noMipmap?: boolean,
  37823. /**
  37824. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37825. */
  37826. generateHarmonics?: boolean,
  37827. /**
  37828. * 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)
  37829. */
  37830. gammaSpace?: boolean,
  37831. /**
  37832. * Internal Use Only
  37833. */
  37834. reserved?: boolean);
  37835. /**
  37836. * Execute the current task
  37837. * @param scene defines the scene where you want your assets to be loaded
  37838. * @param onSuccess is a callback called when the task is successfully executed
  37839. * @param onError is a callback called if an error occurs
  37840. */
  37841. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37842. }
  37843. /**
  37844. * This class can be used to easily import assets into a scene
  37845. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  37846. */
  37847. class AssetsManager {
  37848. private _scene;
  37849. private _isLoading;
  37850. protected _tasks: AbstractAssetTask[];
  37851. protected _waitingTasksCount: number;
  37852. protected _totalTasksCount: number;
  37853. /**
  37854. * Callback called when all tasks are processed
  37855. */
  37856. onFinish: (tasks: AbstractAssetTask[]) => void;
  37857. /**
  37858. * Callback called when a task is successful
  37859. */
  37860. onTaskSuccess: (task: AbstractAssetTask) => void;
  37861. /**
  37862. * Callback called when a task had an error
  37863. */
  37864. onTaskError: (task: AbstractAssetTask) => void;
  37865. /**
  37866. * Callback called when a task is done (whatever the result is)
  37867. */
  37868. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  37869. /**
  37870. * Observable called when all tasks are processed
  37871. */
  37872. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  37873. /**
  37874. * Observable called when a task had an error
  37875. */
  37876. onTaskErrorObservable: Observable<AbstractAssetTask>;
  37877. /**
  37878. * Observable called when a task is successful
  37879. */
  37880. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  37881. /**
  37882. * Observable called when a task is done (whatever the result is)
  37883. */
  37884. onProgressObservable: Observable<IAssetsProgressEvent>;
  37885. /**
  37886. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  37887. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37888. */
  37889. useDefaultLoadingScreen: boolean;
  37890. /**
  37891. * Creates a new AssetsManager
  37892. * @param scene defines the scene to work on
  37893. */
  37894. constructor(scene: Scene);
  37895. /**
  37896. * Add a MeshAssetTask to the list of active tasks
  37897. * @param taskName defines the name of the new task
  37898. * @param meshesNames defines the name of meshes to load
  37899. * @param rootUrl defines the root url to use to locate files
  37900. * @param sceneFilename defines the filename of the scene file
  37901. * @returns a new MeshAssetTask object
  37902. */
  37903. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  37904. /**
  37905. * Add a TextFileAssetTask to the list of active tasks
  37906. * @param taskName defines the name of the new task
  37907. * @param url defines the url of the file to load
  37908. * @returns a new TextFileAssetTask object
  37909. */
  37910. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  37911. /**
  37912. * Add a BinaryFileAssetTask to the list of active tasks
  37913. * @param taskName defines the name of the new task
  37914. * @param url defines the url of the file to load
  37915. * @returns a new BinaryFileAssetTask object
  37916. */
  37917. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  37918. /**
  37919. * Add a ImageAssetTask to the list of active tasks
  37920. * @param taskName defines the name of the new task
  37921. * @param url defines the url of the file to load
  37922. * @returns a new ImageAssetTask object
  37923. */
  37924. addImageTask(taskName: string, url: string): ImageAssetTask;
  37925. /**
  37926. * Add a TextureAssetTask to the list of active tasks
  37927. * @param taskName defines the name of the new task
  37928. * @param url defines the url of the file to load
  37929. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37930. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  37931. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37932. * @returns a new TextureAssetTask object
  37933. */
  37934. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  37935. /**
  37936. * Add a CubeTextureAssetTask to the list of active tasks
  37937. * @param taskName defines the name of the new task
  37938. * @param url defines the url of the file to load
  37939. * @param extensions defines the extension to use to load the cube map (can be null)
  37940. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37941. * @param files defines the list of files to load (can be null)
  37942. * @returns a new CubeTextureAssetTask object
  37943. */
  37944. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  37945. /**
  37946. *
  37947. * Add a HDRCubeTextureAssetTask to the list of active tasks
  37948. * @param taskName defines the name of the new task
  37949. * @param url defines the url of the file to load
  37950. * @param size defines the size you want for the cubemap (can be null)
  37951. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37952. * @param generateHarmonics defines if you want to automatically generate (true by default)
  37953. * @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)
  37954. * @param reserved Internal use only
  37955. * @returns a new HDRCubeTextureAssetTask object
  37956. */
  37957. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  37958. /**
  37959. * Remove a task from the assets manager.
  37960. * @param task the task to remove
  37961. */
  37962. removeTask(task: AbstractAssetTask): void;
  37963. private _decreaseWaitingTasksCount;
  37964. private _runTask;
  37965. /**
  37966. * Reset the AssetsManager and remove all tasks
  37967. * @return the current instance of the AssetsManager
  37968. */
  37969. reset(): AssetsManager;
  37970. /**
  37971. * Start the loading process
  37972. * @return the current instance of the AssetsManager
  37973. */
  37974. load(): AssetsManager;
  37975. }
  37976. }
  37977. declare module BABYLON {
  37978. /**
  37979. * Direct draw surface info
  37980. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  37981. */
  37982. interface DDSInfo {
  37983. /**
  37984. * Width of the texture
  37985. */
  37986. width: number;
  37987. /**
  37988. * Width of the texture
  37989. */
  37990. height: number;
  37991. /**
  37992. * Number of Mipmaps for the texture
  37993. * @see https://en.wikipedia.org/wiki/Mipmap
  37994. */
  37995. mipmapCount: number;
  37996. /**
  37997. * If the textures format is a known fourCC format
  37998. * @see https://www.fourcc.org/
  37999. */
  38000. isFourCC: boolean;
  38001. /**
  38002. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  38003. */
  38004. isRGB: boolean;
  38005. /**
  38006. * If the texture is a lumincance format
  38007. */
  38008. isLuminance: boolean;
  38009. /**
  38010. * If this is a cube texture
  38011. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  38012. */
  38013. isCube: boolean;
  38014. /**
  38015. * If the texture is a compressed format eg. FOURCC_DXT1
  38016. */
  38017. isCompressed: boolean;
  38018. /**
  38019. * The dxgiFormat of the texture
  38020. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  38021. */
  38022. dxgiFormat: number;
  38023. /**
  38024. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  38025. */
  38026. textureType: number;
  38027. /**
  38028. * Sphericle polynomial created for the dds texture
  38029. */
  38030. sphericalPolynomial?: SphericalPolynomial;
  38031. }
  38032. /**
  38033. * Class used to provide DDS decompression tools
  38034. */
  38035. class DDSTools {
  38036. /**
  38037. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  38038. */
  38039. static StoreLODInAlphaChannel: boolean;
  38040. /**
  38041. * Gets DDS information from an array buffer
  38042. * @param arrayBuffer defines the array buffer to read data from
  38043. * @returns the DDS information
  38044. */
  38045. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  38046. private static _FloatView;
  38047. private static _Int32View;
  38048. private static _ToHalfFloat;
  38049. private static _FromHalfFloat;
  38050. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  38051. private static _GetHalfFloatRGBAArrayBuffer;
  38052. private static _GetFloatRGBAArrayBuffer;
  38053. private static _GetFloatAsUIntRGBAArrayBuffer;
  38054. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  38055. private static _GetRGBAArrayBuffer;
  38056. private static _ExtractLongWordOrder;
  38057. private static _GetRGBArrayBuffer;
  38058. private static _GetLuminanceArrayBuffer;
  38059. /**
  38060. * Uploads DDS Levels to a Babylon Texture
  38061. * @hidden
  38062. */
  38063. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  38064. }
  38065. }
  38066. declare module BABYLON {
  38067. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38068. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38069. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38070. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38071. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38072. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38073. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38074. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38075. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38076. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38077. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38078. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38079. /**
  38080. * Decorator used to define property that can be serialized as reference to a camera
  38081. * @param sourceName defines the name of the property to decorate
  38082. */
  38083. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38084. /**
  38085. * Class used to help serialization objects
  38086. */
  38087. class SerializationHelper {
  38088. /**
  38089. * Static function used to serialized a specific entity
  38090. * @param entity defines the entity to serialize
  38091. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38092. * @returns a JSON compatible object representing the serialization of the entity
  38093. */
  38094. static Serialize<T>(entity: T, serializationObject?: any): any;
  38095. /**
  38096. * Creates a new entity from a serialization data object
  38097. * @param creationFunction defines a function used to instanciated the new entity
  38098. * @param source defines the source serialization data
  38099. * @param scene defines the hosting scene
  38100. * @param rootUrl defines the root url for resources
  38101. * @returns a new entity
  38102. */
  38103. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38104. /**
  38105. * Clones an object
  38106. * @param creationFunction defines the function used to instanciate the new object
  38107. * @param source defines the source object
  38108. * @returns the cloned object
  38109. */
  38110. static Clone<T>(creationFunction: () => T, source: T): T;
  38111. /**
  38112. * Instanciates a new object based on a source one (some data will be shared between both object)
  38113. * @param creationFunction defines the function used to instanciate the new object
  38114. * @param source defines the source object
  38115. * @returns the new object
  38116. */
  38117. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38118. }
  38119. }
  38120. declare module BABYLON {
  38121. /**
  38122. * Wrapper class for promise with external resolve and reject.
  38123. */
  38124. class Deferred<T> {
  38125. /**
  38126. * The promise associated with this deferred object.
  38127. */
  38128. readonly promise: Promise<T>;
  38129. private _resolve;
  38130. private _reject;
  38131. /**
  38132. * The resolve method of the promise associated with this deferred object.
  38133. */
  38134. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  38135. /**
  38136. * The reject method of the promise associated with this deferred object.
  38137. */
  38138. readonly reject: (reason?: any) => void;
  38139. /**
  38140. * Constructor for this deferred object.
  38141. */
  38142. constructor();
  38143. }
  38144. }
  38145. declare module BABYLON {
  38146. /**
  38147. * Raw texture data and descriptor sufficient for WebGL texture upload
  38148. */
  38149. interface EnvironmentTextureInfo {
  38150. /**
  38151. * Version of the environment map
  38152. */
  38153. version: number;
  38154. /**
  38155. * Width of image
  38156. */
  38157. width: number;
  38158. /**
  38159. * Irradiance information stored in the file.
  38160. */
  38161. irradiance: any;
  38162. /**
  38163. * Specular information stored in the file.
  38164. */
  38165. specular: any;
  38166. }
  38167. /**
  38168. * Sets of helpers addressing the serialization and deserialization of environment texture
  38169. * stored in a BabylonJS env file.
  38170. * Those files are usually stored as .env files.
  38171. */
  38172. class EnvironmentTextureTools {
  38173. /**
  38174. * Magic number identifying the env file.
  38175. */
  38176. private static _MagicBytes;
  38177. /**
  38178. * Gets the environment info from an env file.
  38179. * @param data The array buffer containing the .env bytes.
  38180. * @returns the environment file info (the json header) if successfully parsed.
  38181. */
  38182. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  38183. /**
  38184. * Creates an environment texture from a loaded cube texture.
  38185. * @param texture defines the cube texture to convert in env file
  38186. * @return a promise containing the environment data if succesfull.
  38187. */
  38188. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  38189. /**
  38190. * Creates a JSON representation of the spherical data.
  38191. * @param texture defines the texture containing the polynomials
  38192. * @return the JSON representation of the spherical info
  38193. */
  38194. private static _CreateEnvTextureIrradiance;
  38195. /**
  38196. * Uploads the texture info contained in the env file to the GPU.
  38197. * @param texture defines the internal texture to upload to
  38198. * @param arrayBuffer defines the buffer cotaining the data to load
  38199. * @param info defines the texture info retrieved through the GetEnvInfo method
  38200. * @returns a promise
  38201. */
  38202. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  38203. /**
  38204. * Uploads the levels of image data to the GPU.
  38205. * @param texture defines the internal texture to upload to
  38206. * @param imageData defines the array buffer views of image data [mipmap][face]
  38207. * @returns a promise
  38208. */
  38209. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  38210. /**
  38211. * Uploads spherical polynomials information to the texture.
  38212. * @param texture defines the texture we are trying to upload the information to
  38213. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  38214. */
  38215. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  38216. }
  38217. }
  38218. declare module BABYLON {
  38219. /**
  38220. * Class used to help managing file picking and drag'n'drop
  38221. */
  38222. class FilesInput {
  38223. /**
  38224. * List of files ready to be loaded
  38225. */
  38226. static FilesToLoad: {
  38227. [key: string]: File;
  38228. };
  38229. /**
  38230. * Callback called when a file is processed
  38231. */
  38232. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  38233. private _engine;
  38234. private _currentScene;
  38235. private _sceneLoadedCallback;
  38236. private _progressCallback;
  38237. private _additionalRenderLoopLogicCallback;
  38238. private _textureLoadingCallback;
  38239. private _startingProcessingFilesCallback;
  38240. private _onReloadCallback;
  38241. private _errorCallback;
  38242. private _elementToMonitor;
  38243. private _sceneFileToLoad;
  38244. private _filesToLoad;
  38245. /**
  38246. * Creates a new FilesInput
  38247. * @param engine defines the rendering engine
  38248. * @param scene defines the hosting scene
  38249. * @param sceneLoadedCallback callback called when scene is loaded
  38250. * @param progressCallback callback called to track progress
  38251. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  38252. * @param textureLoadingCallback callback called when a texture is loading
  38253. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  38254. * @param onReloadCallback callback called when a reload is requested
  38255. * @param errorCallback callback call if an error occurs
  38256. */
  38257. 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);
  38258. private _dragEnterHandler;
  38259. private _dragOverHandler;
  38260. private _dropHandler;
  38261. /**
  38262. * Calls this function to listen to drag'n'drop events on a specific DOM element
  38263. * @param elementToMonitor defines the DOM element to track
  38264. */
  38265. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  38266. /**
  38267. * Release all associated resources
  38268. */
  38269. dispose(): void;
  38270. private renderFunction;
  38271. private drag;
  38272. private drop;
  38273. private _traverseFolder;
  38274. private _processFiles;
  38275. /**
  38276. * Load files from a drop event
  38277. * @param event defines the drop event to use as source
  38278. */
  38279. loadFiles(event: any): void;
  38280. private _processReload;
  38281. /**
  38282. * Reload the current scene from the loaded files
  38283. */
  38284. reload(): void;
  38285. }
  38286. }
  38287. declare module BABYLON {
  38288. /**
  38289. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  38290. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  38291. */
  38292. class KhronosTextureContainer {
  38293. /** contents of the KTX container file */
  38294. arrayBuffer: any;
  38295. private static HEADER_LEN;
  38296. private static COMPRESSED_2D;
  38297. private static COMPRESSED_3D;
  38298. private static TEX_2D;
  38299. private static TEX_3D;
  38300. /**
  38301. * Gets the openGL type
  38302. */
  38303. glType: number;
  38304. /**
  38305. * Gets the openGL type size
  38306. */
  38307. glTypeSize: number;
  38308. /**
  38309. * Gets the openGL format
  38310. */
  38311. glFormat: number;
  38312. /**
  38313. * Gets the openGL internal format
  38314. */
  38315. glInternalFormat: number;
  38316. /**
  38317. * Gets the base internal format
  38318. */
  38319. glBaseInternalFormat: number;
  38320. /**
  38321. * Gets image width in pixel
  38322. */
  38323. pixelWidth: number;
  38324. /**
  38325. * Gets image height in pixel
  38326. */
  38327. pixelHeight: number;
  38328. /**
  38329. * Gets image depth in pixels
  38330. */
  38331. pixelDepth: number;
  38332. /**
  38333. * Gets the number of array elements
  38334. */
  38335. numberOfArrayElements: number;
  38336. /**
  38337. * Gets the number of faces
  38338. */
  38339. numberOfFaces: number;
  38340. /**
  38341. * Gets the number of mipmap levels
  38342. */
  38343. numberOfMipmapLevels: number;
  38344. /**
  38345. * Gets the bytes of key value data
  38346. */
  38347. bytesOfKeyValueData: number;
  38348. /**
  38349. * Gets the load type
  38350. */
  38351. loadType: number;
  38352. /**
  38353. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  38354. */
  38355. isInvalid: boolean;
  38356. /**
  38357. * Creates a new KhronosTextureContainer
  38358. * @param arrayBuffer contents of the KTX container file
  38359. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  38360. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  38361. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  38362. */
  38363. constructor(
  38364. /** contents of the KTX container file */
  38365. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  38366. /**
  38367. * Revert the endianness of a value.
  38368. * Not as fast hardware based, but will probably never need to use
  38369. * @param val defines the value to convert
  38370. * @returns the new value
  38371. */
  38372. switchEndianness(val: number): number;
  38373. /**
  38374. * Uploads KTX content to a Babylon Texture.
  38375. * It is assumed that the texture has already been created & is currently bound
  38376. * @hidden
  38377. */
  38378. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  38379. private _upload2DCompressedLevels;
  38380. }
  38381. }
  38382. declare module BABYLON {
  38383. /**
  38384. * A class serves as a medium between the observable and its observers
  38385. */
  38386. class EventState {
  38387. /**
  38388. * Create a new EventState
  38389. * @param mask defines the mask associated with this state
  38390. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38391. * @param target defines the original target of the state
  38392. * @param currentTarget defines the current target of the state
  38393. */
  38394. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  38395. /**
  38396. * Initialize the current event state
  38397. * @param mask defines the mask associated with this state
  38398. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38399. * @param target defines the original target of the state
  38400. * @param currentTarget defines the current target of the state
  38401. * @returns the current event state
  38402. */
  38403. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  38404. /**
  38405. * An Observer can set this property to true to prevent subsequent observers of being notified
  38406. */
  38407. skipNextObservers: boolean;
  38408. /**
  38409. * Get the mask value that were used to trigger the event corresponding to this EventState object
  38410. */
  38411. mask: number;
  38412. /**
  38413. * The object that originally notified the event
  38414. */
  38415. target?: any;
  38416. /**
  38417. * The current object in the bubbling phase
  38418. */
  38419. currentTarget?: any;
  38420. /**
  38421. * This will be populated with the return value of the last function that was executed.
  38422. * If it is the first function in the callback chain it will be the event data.
  38423. */
  38424. lastReturnValue?: any;
  38425. }
  38426. /**
  38427. * Represent an Observer registered to a given Observable object.
  38428. */
  38429. class Observer<T> {
  38430. /**
  38431. * Defines the callback to call when the observer is notified
  38432. */
  38433. callback: (eventData: T, eventState: EventState) => void;
  38434. /**
  38435. * Defines the mask of the observer (used to filter notifications)
  38436. */
  38437. mask: number;
  38438. /**
  38439. * Defines the current scope used to restore the JS context
  38440. */
  38441. scope: any;
  38442. /** @hidden */
  38443. _willBeUnregistered: boolean;
  38444. /**
  38445. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  38446. */
  38447. unregisterOnNextCall: boolean;
  38448. /**
  38449. * Creates a new observer
  38450. * @param callback defines the callback to call when the observer is notified
  38451. * @param mask defines the mask of the observer (used to filter notifications)
  38452. * @param scope defines the current scope used to restore the JS context
  38453. */
  38454. constructor(
  38455. /**
  38456. * Defines the callback to call when the observer is notified
  38457. */
  38458. callback: (eventData: T, eventState: EventState) => void,
  38459. /**
  38460. * Defines the mask of the observer (used to filter notifications)
  38461. */
  38462. mask: number,
  38463. /**
  38464. * Defines the current scope used to restore the JS context
  38465. */
  38466. scope?: any);
  38467. }
  38468. /**
  38469. * Represent a list of observers registered to multiple Observables object.
  38470. */
  38471. class MultiObserver<T> {
  38472. private _observers;
  38473. private _observables;
  38474. /**
  38475. * Release associated resources
  38476. */
  38477. dispose(): void;
  38478. /**
  38479. * Raise a callback when one of the observable will notify
  38480. * @param observables defines a list of observables to watch
  38481. * @param callback defines the callback to call on notification
  38482. * @param mask defines the mask used to filter notifications
  38483. * @param scope defines the current scope used to restore the JS context
  38484. * @returns the new MultiObserver
  38485. */
  38486. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  38487. }
  38488. /**
  38489. * The Observable class is a simple implementation of the Observable pattern.
  38490. *
  38491. * 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.
  38492. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  38493. * 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).
  38494. * 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.
  38495. */
  38496. class Observable<T> {
  38497. private _observers;
  38498. private _eventState;
  38499. private _onObserverAdded;
  38500. /**
  38501. * Creates a new observable
  38502. * @param onObserverAdded defines a callback to call when a new observer is added
  38503. */
  38504. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  38505. /**
  38506. * Create a new Observer with the specified callback
  38507. * @param callback the callback that will be executed for that Observer
  38508. * @param mask the mask used to filter observers
  38509. * @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.
  38510. * @param scope optional scope for the callback to be called from
  38511. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  38512. * @returns the new observer created for the callback
  38513. */
  38514. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  38515. /**
  38516. * Create a new Observer with the specified callback and unregisters after the next notification
  38517. * @param callback the callback that will be executed for that Observer
  38518. * @returns the new observer created for the callback
  38519. */
  38520. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  38521. /**
  38522. * Remove an Observer from the Observable object
  38523. * @param observer the instance of the Observer to remove
  38524. * @returns false if it doesn't belong to this Observable
  38525. */
  38526. remove(observer: Nullable<Observer<T>>): boolean;
  38527. /**
  38528. * Remove a callback from the Observable object
  38529. * @param callback the callback to remove
  38530. * @param scope optional scope. If used only the callbacks with this scope will be removed
  38531. * @returns false if it doesn't belong to this Observable
  38532. */
  38533. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  38534. private _deferUnregister;
  38535. private _remove;
  38536. /**
  38537. * Notify all Observers by calling their respective callback with the given data
  38538. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  38539. * @param eventData defines the data to send to all observers
  38540. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  38541. * @param target defines the original target of the state
  38542. * @param currentTarget defines the current target of the state
  38543. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  38544. */
  38545. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  38546. /**
  38547. * Calling this will execute each callback, expecting it to be a promise or return a value.
  38548. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  38549. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  38550. * and it is crucial that all callbacks will be executed.
  38551. * The order of the callbacks is kept, callbacks are not executed parallel.
  38552. *
  38553. * @param eventData The data to be sent to each callback
  38554. * @param mask is used to filter observers defaults to -1
  38555. * @param target defines the callback target (see EventState)
  38556. * @param currentTarget defines he current object in the bubbling phase
  38557. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  38558. */
  38559. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  38560. /**
  38561. * Notify a specific observer
  38562. * @param observer defines the observer to notify
  38563. * @param eventData defines the data to be sent to each callback
  38564. * @param mask is used to filter observers defaults to -1
  38565. */
  38566. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  38567. /**
  38568. * Gets a boolean indicating if the observable has at least one observer
  38569. * @returns true is the Observable has at least one Observer registered
  38570. */
  38571. hasObservers(): boolean;
  38572. /**
  38573. * Clear the list of observers
  38574. */
  38575. clear(): void;
  38576. /**
  38577. * Clone the current observable
  38578. * @returns a new observable
  38579. */
  38580. clone(): Observable<T>;
  38581. /**
  38582. * Does this observable handles observer registered with a given mask
  38583. * @param mask defines the mask to be tested
  38584. * @return whether or not one observer registered with the given mask is handeled
  38585. **/
  38586. hasSpecificMask(mask?: number): boolean;
  38587. }
  38588. }
  38589. declare module BABYLON {
  38590. /**
  38591. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38592. */
  38593. class PerformanceMonitor {
  38594. private _enabled;
  38595. private _rollingFrameTime;
  38596. private _lastFrameTimeMs;
  38597. /**
  38598. * constructor
  38599. * @param frameSampleSize The number of samples required to saturate the sliding window
  38600. */
  38601. constructor(frameSampleSize?: number);
  38602. /**
  38603. * Samples current frame
  38604. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38605. */
  38606. sampleFrame(timeMs?: number): void;
  38607. /**
  38608. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38609. */
  38610. readonly averageFrameTime: number;
  38611. /**
  38612. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38613. */
  38614. readonly averageFrameTimeVariance: number;
  38615. /**
  38616. * Returns the frame time of the most recent frame
  38617. */
  38618. readonly instantaneousFrameTime: number;
  38619. /**
  38620. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38621. */
  38622. readonly averageFPS: number;
  38623. /**
  38624. * Returns the average framerate in frames per second using the most recent frame time
  38625. */
  38626. readonly instantaneousFPS: number;
  38627. /**
  38628. * Returns true if enough samples have been taken to completely fill the sliding window
  38629. */
  38630. readonly isSaturated: boolean;
  38631. /**
  38632. * Enables contributions to the sliding window sample set
  38633. */
  38634. enable(): void;
  38635. /**
  38636. * Disables contributions to the sliding window sample set
  38637. * Samples will not be interpolated over the disabled period
  38638. */
  38639. disable(): void;
  38640. /**
  38641. * Returns true if sampling is enabled
  38642. */
  38643. readonly isEnabled: boolean;
  38644. /**
  38645. * Resets performance monitor
  38646. */
  38647. reset(): void;
  38648. }
  38649. /**
  38650. * RollingAverage
  38651. *
  38652. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38653. */
  38654. class RollingAverage {
  38655. /**
  38656. * Current average
  38657. */
  38658. average: number;
  38659. /**
  38660. * Current variance
  38661. */
  38662. variance: number;
  38663. protected _samples: Array<number>;
  38664. protected _sampleCount: number;
  38665. protected _pos: number;
  38666. protected _m2: number;
  38667. /**
  38668. * constructor
  38669. * @param length The number of samples required to saturate the sliding window
  38670. */
  38671. constructor(length: number);
  38672. /**
  38673. * Adds a sample to the sample set
  38674. * @param v The sample value
  38675. */
  38676. add(v: number): void;
  38677. /**
  38678. * Returns previously added values or null if outside of history or outside the sliding window domain
  38679. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38680. * @return Value previously recorded with add() or null if outside of range
  38681. */
  38682. history(i: number): number;
  38683. /**
  38684. * Returns true if enough samples have been taken to completely fill the sliding window
  38685. * @return true if sample-set saturated
  38686. */
  38687. isSaturated(): boolean;
  38688. /**
  38689. * Resets the rolling average (equivalent to 0 samples taken so far)
  38690. */
  38691. reset(): void;
  38692. /**
  38693. * Wraps a value around the sample range boundaries
  38694. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38695. * @return Wrapped position in sample range
  38696. */
  38697. protected _wrapPosition(i: number): number;
  38698. }
  38699. }
  38700. declare module BABYLON {
  38701. /**
  38702. * Helper class that provides a small promise polyfill
  38703. */
  38704. class PromisePolyfill {
  38705. /**
  38706. * Static function used to check if the polyfill is required
  38707. * If this is the case then the function will inject the polyfill to window.Promise
  38708. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38709. */
  38710. static Apply(force?: boolean): void;
  38711. }
  38712. }
  38713. declare module BABYLON {
  38714. /**
  38715. * Defines the root class used to create scene optimization to use with SceneOptimizer
  38716. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38717. */
  38718. class SceneOptimization {
  38719. /**
  38720. * Defines the priority of this optimization (0 by default which means first in the list)
  38721. */
  38722. priority: number;
  38723. /**
  38724. * Gets a string describing the action executed by the current optimization
  38725. * @returns description string
  38726. */
  38727. getDescription(): string;
  38728. /**
  38729. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38730. * @param scene defines the current scene where to apply this optimization
  38731. * @param optimizer defines the current optimizer
  38732. * @returns true if everything that can be done was applied
  38733. */
  38734. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38735. /**
  38736. * Creates the SceneOptimization object
  38737. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38738. * @param desc defines the description associated with the optimization
  38739. */
  38740. constructor(
  38741. /**
  38742. * Defines the priority of this optimization (0 by default which means first in the list)
  38743. */
  38744. priority?: number);
  38745. }
  38746. /**
  38747. * Defines an optimization used to reduce the size of render target textures
  38748. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38749. */
  38750. class TextureOptimization extends SceneOptimization {
  38751. /**
  38752. * Defines the priority of this optimization (0 by default which means first in the list)
  38753. */
  38754. priority: number;
  38755. /**
  38756. * 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
  38757. */
  38758. maximumSize: number;
  38759. /**
  38760. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38761. */
  38762. step: number;
  38763. /**
  38764. * Gets a string describing the action executed by the current optimization
  38765. * @returns description string
  38766. */
  38767. getDescription(): string;
  38768. /**
  38769. * Creates the TextureOptimization object
  38770. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38771. * @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
  38772. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38773. */
  38774. constructor(
  38775. /**
  38776. * Defines the priority of this optimization (0 by default which means first in the list)
  38777. */
  38778. priority?: number,
  38779. /**
  38780. * 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
  38781. */
  38782. maximumSize?: number,
  38783. /**
  38784. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38785. */
  38786. step?: number);
  38787. /**
  38788. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38789. * @param scene defines the current scene where to apply this optimization
  38790. * @param optimizer defines the current optimizer
  38791. * @returns true if everything that can be done was applied
  38792. */
  38793. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38794. }
  38795. /**
  38796. * Defines an optimization used to increase or decrease the rendering resolution
  38797. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38798. */
  38799. class HardwareScalingOptimization extends SceneOptimization {
  38800. /**
  38801. * Defines the priority of this optimization (0 by default which means first in the list)
  38802. */
  38803. priority: number;
  38804. /**
  38805. * Defines the maximum scale to use (2 by default)
  38806. */
  38807. maximumScale: number;
  38808. /**
  38809. * Defines the step to use between two passes (0.5 by default)
  38810. */
  38811. step: number;
  38812. private _currentScale;
  38813. private _directionOffset;
  38814. /**
  38815. * Gets a string describing the action executed by the current optimization
  38816. * @return description string
  38817. */
  38818. getDescription(): string;
  38819. /**
  38820. * Creates the HardwareScalingOptimization object
  38821. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38822. * @param maximumScale defines the maximum scale to use (2 by default)
  38823. * @param step defines the step to use between two passes (0.5 by default)
  38824. */
  38825. constructor(
  38826. /**
  38827. * Defines the priority of this optimization (0 by default which means first in the list)
  38828. */
  38829. priority?: number,
  38830. /**
  38831. * Defines the maximum scale to use (2 by default)
  38832. */
  38833. maximumScale?: number,
  38834. /**
  38835. * Defines the step to use between two passes (0.5 by default)
  38836. */
  38837. step?: number);
  38838. /**
  38839. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38840. * @param scene defines the current scene where to apply this optimization
  38841. * @param optimizer defines the current optimizer
  38842. * @returns true if everything that can be done was applied
  38843. */
  38844. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38845. }
  38846. /**
  38847. * Defines an optimization used to remove shadows
  38848. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38849. */
  38850. class ShadowsOptimization extends SceneOptimization {
  38851. /**
  38852. * Gets a string describing the action executed by the current optimization
  38853. * @return description string
  38854. */
  38855. getDescription(): string;
  38856. /**
  38857. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38858. * @param scene defines the current scene where to apply this optimization
  38859. * @param optimizer defines the current optimizer
  38860. * @returns true if everything that can be done was applied
  38861. */
  38862. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38863. }
  38864. /**
  38865. * Defines an optimization used to turn post-processes off
  38866. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38867. */
  38868. class PostProcessesOptimization extends SceneOptimization {
  38869. /**
  38870. * Gets a string describing the action executed by the current optimization
  38871. * @return description string
  38872. */
  38873. getDescription(): string;
  38874. /**
  38875. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38876. * @param scene defines the current scene where to apply this optimization
  38877. * @param optimizer defines the current optimizer
  38878. * @returns true if everything that can be done was applied
  38879. */
  38880. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38881. }
  38882. /**
  38883. * Defines an optimization used to turn lens flares off
  38884. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38885. */
  38886. class LensFlaresOptimization extends SceneOptimization {
  38887. /**
  38888. * Gets a string describing the action executed by the current optimization
  38889. * @return description string
  38890. */
  38891. getDescription(): string;
  38892. /**
  38893. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38894. * @param scene defines the current scene where to apply this optimization
  38895. * @param optimizer defines the current optimizer
  38896. * @returns true if everything that can be done was applied
  38897. */
  38898. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38899. }
  38900. /**
  38901. * Defines an optimization based on user defined callback.
  38902. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38903. */
  38904. class CustomOptimization extends SceneOptimization {
  38905. /**
  38906. * Callback called to apply the custom optimization.
  38907. */
  38908. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  38909. /**
  38910. * Callback called to get custom description
  38911. */
  38912. onGetDescription: () => string;
  38913. /**
  38914. * Gets a string describing the action executed by the current optimization
  38915. * @returns description string
  38916. */
  38917. getDescription(): string;
  38918. /**
  38919. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38920. * @param scene defines the current scene where to apply this optimization
  38921. * @param optimizer defines the current optimizer
  38922. * @returns true if everything that can be done was applied
  38923. */
  38924. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38925. }
  38926. /**
  38927. * Defines an optimization used to turn particles off
  38928. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38929. */
  38930. class ParticlesOptimization extends SceneOptimization {
  38931. /**
  38932. * Gets a string describing the action executed by the current optimization
  38933. * @return description string
  38934. */
  38935. getDescription(): string;
  38936. /**
  38937. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38938. * @param scene defines the current scene where to apply this optimization
  38939. * @param optimizer defines the current optimizer
  38940. * @returns true if everything that can be done was applied
  38941. */
  38942. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38943. }
  38944. /**
  38945. * Defines an optimization used to turn render targets off
  38946. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38947. */
  38948. class RenderTargetsOptimization extends SceneOptimization {
  38949. /**
  38950. * Gets a string describing the action executed by the current optimization
  38951. * @return description string
  38952. */
  38953. getDescription(): string;
  38954. /**
  38955. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38956. * @param scene defines the current scene where to apply this optimization
  38957. * @param optimizer defines the current optimizer
  38958. * @returns true if everything that can be done was applied
  38959. */
  38960. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38961. }
  38962. /**
  38963. * Defines an optimization used to merge meshes with compatible materials
  38964. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38965. */
  38966. class MergeMeshesOptimization extends SceneOptimization {
  38967. private static _UpdateSelectionTree;
  38968. /**
  38969. * Gets or sets a boolean which defines if optimization octree has to be updated
  38970. */
  38971. /**
  38972. * Gets or sets a boolean which defines if optimization octree has to be updated
  38973. */
  38974. static UpdateSelectionTree: boolean;
  38975. /**
  38976. * Gets a string describing the action executed by the current optimization
  38977. * @return description string
  38978. */
  38979. getDescription(): string;
  38980. private _canBeMerged;
  38981. /**
  38982. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38983. * @param scene defines the current scene where to apply this optimization
  38984. * @param optimizer defines the current optimizer
  38985. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  38986. * @returns true if everything that can be done was applied
  38987. */
  38988. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  38989. }
  38990. /**
  38991. * Defines a list of options used by SceneOptimizer
  38992. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38993. */
  38994. class SceneOptimizerOptions {
  38995. /**
  38996. * Defines the target frame rate to reach (60 by default)
  38997. */
  38998. targetFrameRate: number;
  38999. /**
  39000. * Defines the interval between two checkes (2000ms by default)
  39001. */
  39002. trackerDuration: number;
  39003. /**
  39004. * Gets the list of optimizations to apply
  39005. */
  39006. optimizations: SceneOptimization[];
  39007. /**
  39008. * Creates a new list of options used by SceneOptimizer
  39009. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  39010. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  39011. */
  39012. constructor(
  39013. /**
  39014. * Defines the target frame rate to reach (60 by default)
  39015. */
  39016. targetFrameRate?: number,
  39017. /**
  39018. * Defines the interval between two checkes (2000ms by default)
  39019. */
  39020. trackerDuration?: number);
  39021. /**
  39022. * Add a new optimization
  39023. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  39024. * @returns the current SceneOptimizerOptions
  39025. */
  39026. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  39027. /**
  39028. * Add a new custom optimization
  39029. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  39030. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  39031. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  39032. * @returns the current SceneOptimizerOptions
  39033. */
  39034. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  39035. /**
  39036. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  39037. * @param targetFrameRate defines the target frame rate (60 by default)
  39038. * @returns a SceneOptimizerOptions object
  39039. */
  39040. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39041. /**
  39042. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  39043. * @param targetFrameRate defines the target frame rate (60 by default)
  39044. * @returns a SceneOptimizerOptions object
  39045. */
  39046. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39047. /**
  39048. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  39049. * @param targetFrameRate defines the target frame rate (60 by default)
  39050. * @returns a SceneOptimizerOptions object
  39051. */
  39052. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  39053. }
  39054. /**
  39055. * Class used to run optimizations in order to reach a target frame rate
  39056. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  39057. */
  39058. class SceneOptimizer implements IDisposable {
  39059. private _isRunning;
  39060. private _options;
  39061. private _scene;
  39062. private _currentPriorityLevel;
  39063. private _targetFrameRate;
  39064. private _trackerDuration;
  39065. private _currentFrameRate;
  39066. private _sceneDisposeObserver;
  39067. private _improvementMode;
  39068. /**
  39069. * Defines an observable called when the optimizer reaches the target frame rate
  39070. */
  39071. onSuccessObservable: Observable<SceneOptimizer>;
  39072. /**
  39073. * Defines an observable called when the optimizer enables an optimization
  39074. */
  39075. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  39076. /**
  39077. * Defines an observable called when the optimizer is not able to reach the target frame rate
  39078. */
  39079. onFailureObservable: Observable<SceneOptimizer>;
  39080. /**
  39081. * Gets a boolean indicating if the optimizer is in improvement mode
  39082. */
  39083. readonly isInImprovementMode: boolean;
  39084. /**
  39085. * Gets the current priority level (0 at start)
  39086. */
  39087. readonly currentPriorityLevel: number;
  39088. /**
  39089. * Gets the current frame rate checked by the SceneOptimizer
  39090. */
  39091. readonly currentFrameRate: number;
  39092. /**
  39093. * Gets or sets the current target frame rate (60 by default)
  39094. */
  39095. /**
  39096. * Gets or sets the current target frame rate (60 by default)
  39097. */
  39098. targetFrameRate: number;
  39099. /**
  39100. * Gets or sets the current interval between two checks (every 2000ms by default)
  39101. */
  39102. /**
  39103. * Gets or sets the current interval between two checks (every 2000ms by default)
  39104. */
  39105. trackerDuration: number;
  39106. /**
  39107. * Gets the list of active optimizations
  39108. */
  39109. readonly optimizations: SceneOptimization[];
  39110. /**
  39111. * Creates a new SceneOptimizer
  39112. * @param scene defines the scene to work on
  39113. * @param options defines the options to use with the SceneOptimizer
  39114. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  39115. * @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)
  39116. */
  39117. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  39118. /**
  39119. * Stops the current optimizer
  39120. */
  39121. stop(): void;
  39122. /**
  39123. * Reset the optimizer to initial step (current priority level = 0)
  39124. */
  39125. reset(): void;
  39126. /**
  39127. * Start the optimizer. By default it will try to reach a specific framerate
  39128. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  39129. */
  39130. start(): void;
  39131. private _checkCurrentState;
  39132. /**
  39133. * Release all resources
  39134. */
  39135. dispose(): void;
  39136. /**
  39137. * Helper function to create a SceneOptimizer with one single line of code
  39138. * @param scene defines the scene to work on
  39139. * @param options defines the options to use with the SceneOptimizer
  39140. * @param onSuccess defines a callback to call on success
  39141. * @param onFailure defines a callback to call on failure
  39142. * @returns the new SceneOptimizer object
  39143. */
  39144. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  39145. }
  39146. }
  39147. declare module BABYLON {
  39148. /**
  39149. * Class used to serialize a scene into a string
  39150. */
  39151. class SceneSerializer {
  39152. /**
  39153. * Clear cache used by a previous serialization
  39154. */
  39155. static ClearCache(): void;
  39156. /**
  39157. * Serialize a scene into a JSON compatible object
  39158. * @param scene defines the scene to serialize
  39159. * @returns a JSON compatible object
  39160. */
  39161. static Serialize(scene: Scene): any;
  39162. /**
  39163. * Serialize a mesh into a JSON compatible object
  39164. * @param toSerialize defines the mesh to serialize
  39165. * @param withParents defines if parents must be serialized as well
  39166. * @param withChildren defines if children must be serialized as well
  39167. * @returns a JSON compatible object
  39168. */
  39169. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  39170. }
  39171. }
  39172. declare module BABYLON {
  39173. /**
  39174. * Defines an array and its length.
  39175. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  39176. */
  39177. interface ISmartArrayLike<T> {
  39178. /**
  39179. * The data of the array.
  39180. */
  39181. data: Array<T>;
  39182. /**
  39183. * The active length of the array.
  39184. */
  39185. length: number;
  39186. }
  39187. /**
  39188. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39189. */
  39190. class SmartArray<T> implements ISmartArrayLike<T> {
  39191. /**
  39192. * The full set of data from the array.
  39193. */
  39194. data: Array<T>;
  39195. /**
  39196. * The active length of the array.
  39197. */
  39198. length: number;
  39199. protected _id: number;
  39200. /**
  39201. * Instantiates a Smart Array.
  39202. * @param capacity defines the default capacity of the array.
  39203. */
  39204. constructor(capacity: number);
  39205. /**
  39206. * Pushes a value at the end of the active data.
  39207. * @param value defines the object to push in the array.
  39208. */
  39209. push(value: T): void;
  39210. /**
  39211. * Iterates over the active data and apply the lambda to them.
  39212. * @param func defines the action to apply on each value.
  39213. */
  39214. forEach(func: (content: T) => void): void;
  39215. /**
  39216. * Sorts the full sets of data.
  39217. * @param compareFn defines the comparison function to apply.
  39218. */
  39219. sort(compareFn: (a: T, b: T) => number): void;
  39220. /**
  39221. * Resets the active data to an empty array.
  39222. */
  39223. reset(): void;
  39224. /**
  39225. * Releases all the data from the array as well as the array.
  39226. */
  39227. dispose(): void;
  39228. /**
  39229. * Concats the active data with a given array.
  39230. * @param array defines the data to concatenate with.
  39231. */
  39232. concat(array: any): void;
  39233. /**
  39234. * Returns the position of a value in the active data.
  39235. * @param value defines the value to find the index for
  39236. * @returns the index if found in the active data otherwise -1
  39237. */
  39238. indexOf(value: T): number;
  39239. /**
  39240. * Returns whether an element is part of the active data.
  39241. * @param value defines the value to look for
  39242. * @returns true if found in the active data otherwise false
  39243. */
  39244. contains(value: T): boolean;
  39245. private static _GlobalId;
  39246. }
  39247. /**
  39248. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39249. * The data in this array can only be present once
  39250. */
  39251. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  39252. private _duplicateId;
  39253. /**
  39254. * Pushes a value at the end of the active data.
  39255. * THIS DOES NOT PREVENT DUPPLICATE DATA
  39256. * @param value defines the object to push in the array.
  39257. */
  39258. push(value: T): void;
  39259. /**
  39260. * Pushes a value at the end of the active data.
  39261. * If the data is already present, it won t be added again
  39262. * @param value defines the object to push in the array.
  39263. * @returns true if added false if it was already present
  39264. */
  39265. pushNoDuplicate(value: T): boolean;
  39266. /**
  39267. * Resets the active data to an empty array.
  39268. */
  39269. reset(): void;
  39270. /**
  39271. * Concats the active data with a given array.
  39272. * This ensures no dupplicate will be present in the result.
  39273. * @param array defines the data to concatenate with.
  39274. */
  39275. concatWithNoDuplicate(array: any): void;
  39276. }
  39277. }
  39278. declare module BABYLON {
  39279. /**
  39280. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39281. * The underlying implementation relies on an associative array to ensure the best performances.
  39282. * The value can be anything including 'null' but except 'undefined'
  39283. */
  39284. class StringDictionary<T> {
  39285. /**
  39286. * This will clear this dictionary and copy the content from the 'source' one.
  39287. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39288. * @param source the dictionary to take the content from and copy to this dictionary
  39289. */
  39290. copyFrom(source: StringDictionary<T>): void;
  39291. /**
  39292. * Get a value based from its key
  39293. * @param key the given key to get the matching value from
  39294. * @return the value if found, otherwise undefined is returned
  39295. */
  39296. get(key: string): T | undefined;
  39297. /**
  39298. * Get a value from its key or add it if it doesn't exist.
  39299. * This method will ensure you that a given key/data will be present in the dictionary.
  39300. * @param key the given key to get the matching value from
  39301. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39302. * The factory will only be invoked if there's no data for the given key.
  39303. * @return the value corresponding to the key.
  39304. */
  39305. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39306. /**
  39307. * Get a value from its key if present in the dictionary otherwise add it
  39308. * @param key the key to get the value from
  39309. * @param val if there's no such key/value pair in the dictionary add it with this value
  39310. * @return the value corresponding to the key
  39311. */
  39312. getOrAdd(key: string, val: T): T;
  39313. /**
  39314. * Check if there's a given key in the dictionary
  39315. * @param key the key to check for
  39316. * @return true if the key is present, false otherwise
  39317. */
  39318. contains(key: string): boolean;
  39319. /**
  39320. * Add a new key and its corresponding value
  39321. * @param key the key to add
  39322. * @param value the value corresponding to the key
  39323. * @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
  39324. */
  39325. add(key: string, value: T): boolean;
  39326. /**
  39327. * Update a specific value associated to a key
  39328. * @param key defines the key to use
  39329. * @param value defines the value to store
  39330. * @returns true if the value was updated (or false if the key was not found)
  39331. */
  39332. set(key: string, value: T): boolean;
  39333. /**
  39334. * Get the element of the given key and remove it from the dictionary
  39335. * @param key defines the key to search
  39336. * @returns the value associated with the key or null if not found
  39337. */
  39338. getAndRemove(key: string): Nullable<T>;
  39339. /**
  39340. * Remove a key/value from the dictionary.
  39341. * @param key the key to remove
  39342. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39343. */
  39344. remove(key: string): boolean;
  39345. /**
  39346. * Clear the whole content of the dictionary
  39347. */
  39348. clear(): void;
  39349. /**
  39350. * Gets the current count
  39351. */
  39352. readonly count: number;
  39353. /**
  39354. * Execute a callback on each key/val of the dictionary.
  39355. * Note that you can remove any element in this dictionary in the callback implementation
  39356. * @param callback the callback to execute on a given key/value pair
  39357. */
  39358. forEach(callback: (key: string, val: T) => void): void;
  39359. /**
  39360. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39361. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39362. * Note that you can remove any element in this dictionary in the callback implementation
  39363. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39364. * @returns the first item
  39365. */
  39366. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39367. private _count;
  39368. private _data;
  39369. }
  39370. }
  39371. declare module BABYLON {
  39372. /**
  39373. * Class used to store custom tags
  39374. */
  39375. class Tags {
  39376. /**
  39377. * Adds support for tags on the given object
  39378. * @param obj defines the object to use
  39379. */
  39380. static EnableFor(obj: any): void;
  39381. /**
  39382. * Removes tags support
  39383. * @param obj defines the object to use
  39384. */
  39385. static DisableFor(obj: any): void;
  39386. /**
  39387. * Gets a boolean indicating if the given object has tags
  39388. * @param obj defines the object to use
  39389. * @returns a boolean
  39390. */
  39391. static HasTags(obj: any): boolean;
  39392. /**
  39393. * Gets the tags available on a given object
  39394. * @param obj defines the object to use
  39395. * @param asString defines if the tags must be returned as a string instead of an array of strings
  39396. * @returns the tags
  39397. */
  39398. static GetTags(obj: any, asString?: boolean): any;
  39399. /**
  39400. * Adds tags to an object
  39401. * @param obj defines the object to use
  39402. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  39403. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  39404. */
  39405. static AddTagsTo(obj: any, tagsString: string): void;
  39406. /**
  39407. * @hidden
  39408. */
  39409. static _AddTagTo(obj: any, tag: string): void;
  39410. /**
  39411. * Removes specific tags from a specific object
  39412. * @param obj defines the object to use
  39413. * @param tagsString defines the tags to remove
  39414. */
  39415. static RemoveTagsFrom(obj: any, tagsString: string): void;
  39416. /**
  39417. * @hidden
  39418. */
  39419. static _RemoveTagFrom(obj: any, tag: string): void;
  39420. /**
  39421. * Defines if tags hosted on an object match a given query
  39422. * @param obj defines the object to use
  39423. * @param tagsQuery defines the tag query
  39424. * @returns a boolean
  39425. */
  39426. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  39427. }
  39428. }
  39429. declare module BABYLON {
  39430. /**
  39431. * Class used to host texture specific utilities
  39432. */
  39433. class TextureTools {
  39434. /**
  39435. * Uses the GPU to create a copy texture rescaled at a given size
  39436. * @param texture Texture to copy from
  39437. * @param width defines the desired width
  39438. * @param height defines the desired height
  39439. * @param useBilinearMode defines if bilinear mode has to be used
  39440. * @return the generated texture
  39441. */
  39442. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  39443. /**
  39444. * Gets an environment BRDF texture for a given scene
  39445. * @param scene defines the hosting scene
  39446. * @returns the environment BRDF texture
  39447. */
  39448. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  39449. private static _environmentBRDFBase64Texture;
  39450. }
  39451. }
  39452. declare module BABYLON {
  39453. /**
  39454. * Based on jsTGALoader - Javascript loader for TGA file
  39455. * By Vincent Thibault
  39456. * @see http://blog.robrowser.com/javascript-tga-loader.html
  39457. */
  39458. class TGATools {
  39459. private static _TYPE_INDEXED;
  39460. private static _TYPE_RGB;
  39461. private static _TYPE_GREY;
  39462. private static _TYPE_RLE_INDEXED;
  39463. private static _TYPE_RLE_RGB;
  39464. private static _TYPE_RLE_GREY;
  39465. private static _ORIGIN_MASK;
  39466. private static _ORIGIN_SHIFT;
  39467. private static _ORIGIN_BL;
  39468. private static _ORIGIN_BR;
  39469. private static _ORIGIN_UL;
  39470. private static _ORIGIN_UR;
  39471. /**
  39472. * Gets the header of a TGA file
  39473. * @param data defines the TGA data
  39474. * @returns the header
  39475. */
  39476. static GetTGAHeader(data: Uint8Array): any;
  39477. /**
  39478. * Uploads TGA content to a Babylon Texture
  39479. * @hidden
  39480. */
  39481. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  39482. /** @hidden */
  39483. 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;
  39484. /** @hidden */
  39485. 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;
  39486. /** @hidden */
  39487. 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;
  39488. /** @hidden */
  39489. 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;
  39490. /** @hidden */
  39491. 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;
  39492. /** @hidden */
  39493. 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;
  39494. }
  39495. }
  39496. declare module BABYLON {
  39497. /**
  39498. * Interface for any object that can request an animation frame
  39499. */
  39500. interface ICustomAnimationFrameRequester {
  39501. /**
  39502. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  39503. */
  39504. renderFunction?: Function;
  39505. /**
  39506. * Called to request the next frame to render to
  39507. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  39508. */
  39509. requestAnimationFrame: Function;
  39510. /**
  39511. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  39512. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  39513. */
  39514. requestID?: number;
  39515. }
  39516. /**
  39517. * Interface containing an array of animations
  39518. */
  39519. interface IAnimatable {
  39520. /**
  39521. * Array of animations
  39522. */
  39523. animations: Array<Animation>;
  39524. }
  39525. /** Interface used by value gradients (color, factor, ...) */
  39526. interface IValueGradient {
  39527. /**
  39528. * Gets or sets the gradient value (between 0 and 1)
  39529. */
  39530. gradient: number;
  39531. }
  39532. /** Class used to store color4 gradient */
  39533. class ColorGradient implements IValueGradient {
  39534. /**
  39535. * Gets or sets the gradient value (between 0 and 1)
  39536. */
  39537. gradient: number;
  39538. /**
  39539. * Gets or sets first associated color
  39540. */
  39541. color1: Color4;
  39542. /**
  39543. * Gets or sets second associated color
  39544. */
  39545. color2?: Color4;
  39546. /**
  39547. * Will get a color picked randomly between color1 and color2.
  39548. * If color2 is undefined then color1 will be used
  39549. * @param result defines the target Color4 to store the result in
  39550. */
  39551. getColorToRef(result: Color4): void;
  39552. }
  39553. /** Class used to store color 3 gradient */
  39554. class Color3Gradient implements IValueGradient {
  39555. /**
  39556. * Gets or sets the gradient value (between 0 and 1)
  39557. */
  39558. gradient: number;
  39559. /**
  39560. * Gets or sets the associated color
  39561. */
  39562. color: Color3;
  39563. }
  39564. /** Class used to store factor gradient */
  39565. class FactorGradient implements IValueGradient {
  39566. /**
  39567. * Gets or sets the gradient value (between 0 and 1)
  39568. */
  39569. gradient: number;
  39570. /**
  39571. * Gets or sets first associated factor
  39572. */
  39573. factor1: number;
  39574. /**
  39575. * Gets or sets second associated factor
  39576. */
  39577. factor2?: number;
  39578. /**
  39579. * Will get a number picked randomly between factor1 and factor2.
  39580. * If factor2 is undefined then factor1 will be used
  39581. * @returns the picked number
  39582. */
  39583. getFactor(): number;
  39584. }
  39585. /**
  39586. * @ignore
  39587. * Application error to support additional information when loading a file
  39588. */
  39589. class LoadFileError extends Error {
  39590. /** defines the optional XHR request */
  39591. request?: XMLHttpRequest | undefined;
  39592. private static _setPrototypeOf;
  39593. /**
  39594. * Creates a new LoadFileError
  39595. * @param message defines the message of the error
  39596. * @param request defines the optional XHR request
  39597. */
  39598. constructor(message: string,
  39599. /** defines the optional XHR request */
  39600. request?: XMLHttpRequest | undefined);
  39601. }
  39602. /**
  39603. * Class used to define a retry strategy when error happens while loading assets
  39604. */
  39605. class RetryStrategy {
  39606. /**
  39607. * Function used to defines an exponential back off strategy
  39608. * @param maxRetries defines the maximum number of retries (3 by default)
  39609. * @param baseInterval defines the interval between retries
  39610. * @returns the strategy function to use
  39611. */
  39612. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39613. }
  39614. /**
  39615. * File request interface
  39616. */
  39617. interface IFileRequest {
  39618. /**
  39619. * Raised when the request is complete (success or error).
  39620. */
  39621. onCompleteObservable: Observable<IFileRequest>;
  39622. /**
  39623. * Aborts the request for a file.
  39624. */
  39625. abort: () => void;
  39626. }
  39627. /**
  39628. * Class containing a set of static utilities functions
  39629. */
  39630. class Tools {
  39631. /**
  39632. * Gets or sets the base URL to use to load assets
  39633. */
  39634. static BaseUrl: string;
  39635. /**
  39636. * Enable/Disable Custom HTTP Request Headers globally.
  39637. * default = false
  39638. * @see CustomRequestHeaders
  39639. */
  39640. static UseCustomRequestHeaders: boolean;
  39641. /**
  39642. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39643. * i.e. when loading files, where the server/service expects an Authorization header.
  39644. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  39645. */
  39646. static CustomRequestHeaders: {
  39647. [key: string]: string;
  39648. };
  39649. /**
  39650. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39651. */
  39652. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39653. /**
  39654. * Default behaviour for cors in the application.
  39655. * It can be a string if the expected behavior is identical in the entire app.
  39656. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39657. */
  39658. static CorsBehavior: string | ((url: string | string[]) => string);
  39659. /**
  39660. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39661. * @ignorenaming
  39662. */
  39663. static UseFallbackTexture: boolean;
  39664. /**
  39665. * Use this object to register external classes like custom textures or material
  39666. * to allow the laoders to instantiate them
  39667. */
  39668. static RegisteredExternalClasses: {
  39669. [key: string]: Object;
  39670. };
  39671. /**
  39672. * Texture content used if a texture cannot loaded
  39673. * @ignorenaming
  39674. */
  39675. static fallbackTexture: string;
  39676. /**
  39677. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39678. * @param u defines the coordinate on X axis
  39679. * @param v defines the coordinate on Y axis
  39680. * @param width defines the width of the source data
  39681. * @param height defines the height of the source data
  39682. * @param pixels defines the source byte array
  39683. * @param color defines the output color
  39684. */
  39685. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  39686. /**
  39687. * Interpolates between a and b via alpha
  39688. * @param a The lower value (returned when alpha = 0)
  39689. * @param b The upper value (returned when alpha = 1)
  39690. * @param alpha The interpolation-factor
  39691. * @return The mixed value
  39692. */
  39693. static Mix(a: number, b: number, alpha: number): number;
  39694. /**
  39695. * Tries to instantiate a new object from a given class name
  39696. * @param className defines the class name to instantiate
  39697. * @returns the new object or null if the system was not able to do the instantiation
  39698. */
  39699. static Instantiate(className: string): any;
  39700. /**
  39701. * Provides a slice function that will work even on IE
  39702. * @param data defines the array to slice
  39703. * @param start defines the start of the data (optional)
  39704. * @param end defines the end of the data (optional)
  39705. * @returns the new sliced array
  39706. */
  39707. static Slice<T>(data: T, start?: number, end?: number): T;
  39708. /**
  39709. * Polyfill for setImmediate
  39710. * @param action defines the action to execute after the current execution block
  39711. */
  39712. static SetImmediate(action: () => void): void;
  39713. /**
  39714. * Function indicating if a number is an exponent of 2
  39715. * @param value defines the value to test
  39716. * @returns true if the value is an exponent of 2
  39717. */
  39718. static IsExponentOfTwo(value: number): boolean;
  39719. private static _tmpFloatArray;
  39720. /**
  39721. * Returns the nearest 32-bit single precision float representation of a Number
  39722. * @param value A Number. If the parameter is of a different type, it will get converted
  39723. * to a number or to NaN if it cannot be converted
  39724. * @returns number
  39725. */
  39726. static FloatRound(value: number): number;
  39727. /**
  39728. * Find the next highest power of two.
  39729. * @param x Number to start search from.
  39730. * @return Next highest power of two.
  39731. */
  39732. static CeilingPOT(x: number): number;
  39733. /**
  39734. * Find the next lowest power of two.
  39735. * @param x Number to start search from.
  39736. * @return Next lowest power of two.
  39737. */
  39738. static FloorPOT(x: number): number;
  39739. /**
  39740. * Find the nearest power of two.
  39741. * @param x Number to start search from.
  39742. * @return Next nearest power of two.
  39743. */
  39744. static NearestPOT(x: number): number;
  39745. /**
  39746. * Get the closest exponent of two
  39747. * @param value defines the value to approximate
  39748. * @param max defines the maximum value to return
  39749. * @param mode defines how to define the closest value
  39750. * @returns closest exponent of two of the given value
  39751. */
  39752. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39753. /**
  39754. * Extracts the filename from a path
  39755. * @param path defines the path to use
  39756. * @returns the filename
  39757. */
  39758. static GetFilename(path: string): string;
  39759. /**
  39760. * Extracts the "folder" part of a path (everything before the filename).
  39761. * @param uri The URI to extract the info from
  39762. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39763. * @returns The "folder" part of the path
  39764. */
  39765. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39766. /**
  39767. * Extracts text content from a DOM element hierarchy
  39768. * @param element defines the root element
  39769. * @returns a string
  39770. */
  39771. static GetDOMTextContent(element: HTMLElement): string;
  39772. /**
  39773. * Convert an angle in radians to degrees
  39774. * @param angle defines the angle to convert
  39775. * @returns the angle in degrees
  39776. */
  39777. static ToDegrees(angle: number): number;
  39778. /**
  39779. * Convert an angle in degrees to radians
  39780. * @param angle defines the angle to convert
  39781. * @returns the angle in radians
  39782. */
  39783. static ToRadians(angle: number): number;
  39784. /**
  39785. * Encode a buffer to a base64 string
  39786. * @param buffer defines the buffer to encode
  39787. * @returns the encoded string
  39788. */
  39789. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  39790. /**
  39791. * Extracts minimum and maximum values from a list of indexed positions
  39792. * @param positions defines the positions to use
  39793. * @param indices defines the indices to the positions
  39794. * @param indexStart defines the start index
  39795. * @param indexCount defines the end index
  39796. * @param bias defines bias value to add to the result
  39797. * @return minimum and maximum values
  39798. */
  39799. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  39800. minimum: Vector3;
  39801. maximum: Vector3;
  39802. };
  39803. /**
  39804. * Extracts minimum and maximum values from a list of positions
  39805. * @param positions defines the positions to use
  39806. * @param start defines the start index in the positions array
  39807. * @param count defines the number of positions to handle
  39808. * @param bias defines bias value to add to the result
  39809. * @param stride defines the stride size to use (distance between two positions in the positions array)
  39810. * @return minimum and maximum values
  39811. */
  39812. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  39813. minimum: Vector3;
  39814. maximum: Vector3;
  39815. };
  39816. /**
  39817. * Returns an array if obj is not an array
  39818. * @param obj defines the object to evaluate as an array
  39819. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39820. * @returns either obj directly if obj is an array or a new array containing obj
  39821. */
  39822. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39823. /**
  39824. * Returns an array of the given size filled with element built from the given constructor and the paramters
  39825. * @param size the number of element to construct and put in the array
  39826. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  39827. * @returns a new array filled with new objects
  39828. */
  39829. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  39830. /**
  39831. * Gets the pointer prefix to use
  39832. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39833. */
  39834. static GetPointerPrefix(): string;
  39835. /**
  39836. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39837. * @param func - the function to be called
  39838. * @param requester - the object that will request the next frame. Falls back to window.
  39839. * @returns frame number
  39840. */
  39841. static QueueNewFrame(func: () => void, requester?: any): number;
  39842. /**
  39843. * Ask the browser to promote the current element to fullscreen rendering mode
  39844. * @param element defines the DOM element to promote
  39845. */
  39846. static RequestFullscreen(element: HTMLElement): void;
  39847. /**
  39848. * Asks the browser to exit fullscreen mode
  39849. */
  39850. static ExitFullscreen(): void;
  39851. /**
  39852. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39853. * @param url define the url we are trying
  39854. * @param element define the dom element where to configure the cors policy
  39855. */
  39856. static SetCorsBehavior(url: string | string[], element: {
  39857. crossOrigin: string | null;
  39858. }): void;
  39859. /**
  39860. * Removes unwanted characters from an url
  39861. * @param url defines the url to clean
  39862. * @returns the cleaned url
  39863. */
  39864. static CleanUrl(url: string): string;
  39865. /**
  39866. * Gets or sets a function used to pre-process url before using them to load assets
  39867. */
  39868. static PreprocessUrl: (url: string) => string;
  39869. /**
  39870. * Loads an image as an HTMLImageElement.
  39871. * @param input url string, ArrayBuffer, or Blob to load
  39872. * @param onLoad callback called when the image successfully loads
  39873. * @param onError callback called when the image fails to load
  39874. * @param offlineProvider offline provider for caching
  39875. * @returns the HTMLImageElement of the loaded image
  39876. */
  39877. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  39878. /**
  39879. * Loads a file
  39880. * @param url url string, ArrayBuffer, or Blob to load
  39881. * @param onSuccess callback called when the file successfully loads
  39882. * @param onProgress callback called while file is loading (if the server supports this mode)
  39883. * @param offlineProvider defines the offline provider for caching
  39884. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39885. * @param onError callback called when the file fails to load
  39886. * @returns a file request object
  39887. */
  39888. 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;
  39889. /**
  39890. * Load a script (identified by an url). When the url returns, the
  39891. * content of this file is added into a new script element, attached to the DOM (body element)
  39892. * @param scriptUrl defines the url of the script to laod
  39893. * @param onSuccess defines the callback called when the script is loaded
  39894. * @param onError defines the callback to call if an error occurs
  39895. */
  39896. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  39897. /**
  39898. * Loads a file from a blob
  39899. * @param fileToLoad defines the blob to use
  39900. * @param callback defines the callback to call when data is loaded
  39901. * @param progressCallback defines the callback to call during loading process
  39902. * @returns a file request object
  39903. */
  39904. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39905. /**
  39906. * Loads a file
  39907. * @param fileToLoad defines the file to load
  39908. * @param callback defines the callback to call when data is loaded
  39909. * @param progressCallBack defines the callback to call during loading process
  39910. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39911. * @returns a file request object
  39912. */
  39913. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  39914. /**
  39915. * Creates a data url from a given string content
  39916. * @param content defines the content to convert
  39917. * @returns the new data url link
  39918. */
  39919. static FileAsURL(content: string): string;
  39920. /**
  39921. * Format the given number to a specific decimal format
  39922. * @param value defines the number to format
  39923. * @param decimals defines the number of decimals to use
  39924. * @returns the formatted string
  39925. */
  39926. static Format(value: number, decimals?: number): string;
  39927. /**
  39928. * Checks if a given vector is inside a specific range
  39929. * @param v defines the vector to test
  39930. * @param min defines the minimum range
  39931. * @param max defines the maximum range
  39932. */
  39933. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  39934. /**
  39935. * Tries to copy an object by duplicating every property
  39936. * @param source defines the source object
  39937. * @param destination defines the target object
  39938. * @param doNotCopyList defines a list of properties to avoid
  39939. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39940. */
  39941. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39942. /**
  39943. * Gets a boolean indicating if the given object has no own property
  39944. * @param obj defines the object to test
  39945. * @returns true if object has no own property
  39946. */
  39947. static IsEmpty(obj: any): boolean;
  39948. /**
  39949. * Function used to register events at window level
  39950. * @param events defines the events to register
  39951. */
  39952. static RegisterTopRootEvents(events: {
  39953. name: string;
  39954. handler: Nullable<(e: FocusEvent) => any>;
  39955. }[]): void;
  39956. /**
  39957. * Function used to unregister events from window level
  39958. * @param events defines the events to unregister
  39959. */
  39960. static UnregisterTopRootEvents(events: {
  39961. name: string;
  39962. handler: Nullable<(e: FocusEvent) => any>;
  39963. }[]): void;
  39964. /**
  39965. * Dumps the current bound framebuffer
  39966. * @param width defines the rendering width
  39967. * @param height defines the rendering height
  39968. * @param engine defines the hosting engine
  39969. * @param successCallback defines the callback triggered once the data are available
  39970. * @param mimeType defines the mime type of the result
  39971. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39972. */
  39973. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39974. /**
  39975. * Converts the canvas data to blob.
  39976. * This acts as a polyfill for browsers not supporting the to blob function.
  39977. * @param canvas Defines the canvas to extract the data from
  39978. * @param successCallback Defines the callback triggered once the data are available
  39979. * @param mimeType Defines the mime type of the result
  39980. */
  39981. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39982. /**
  39983. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39984. * @param successCallback defines the callback triggered once the data are available
  39985. * @param mimeType defines the mime type of the result
  39986. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39987. */
  39988. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39989. /**
  39990. * Downloads a blob in the browser
  39991. * @param blob defines the blob to download
  39992. * @param fileName defines the name of the downloaded file
  39993. */
  39994. static Download(blob: Blob, fileName: string): void;
  39995. /**
  39996. * Captures a screenshot of the current rendering
  39997. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39998. * @param engine defines the rendering engine
  39999. * @param camera defines the source camera
  40000. * @param size This parameter can be set to a single number or to an object with the
  40001. * following (optional) properties: precision, width, height. If a single number is passed,
  40002. * it will be used for both width and height. If an object is passed, the screenshot size
  40003. * will be derived from the parameters. The precision property is a multiplier allowing
  40004. * rendering at a higher or lower resolution
  40005. * @param successCallback defines the callback receives a single parameter which contains the
  40006. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  40007. * src parameter of an <img> to display it
  40008. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  40009. * Check your browser for supported MIME types
  40010. */
  40011. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  40012. /**
  40013. * Generates an image screenshot from the specified camera.
  40014. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  40015. * @param engine The engine to use for rendering
  40016. * @param camera The camera to use for rendering
  40017. * @param size This parameter can be set to a single number or to an object with the
  40018. * following (optional) properties: precision, width, height. If a single number is passed,
  40019. * it will be used for both width and height. If an object is passed, the screenshot size
  40020. * will be derived from the parameters. The precision property is a multiplier allowing
  40021. * rendering at a higher or lower resolution
  40022. * @param successCallback The callback receives a single parameter which contains the
  40023. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  40024. * src parameter of an <img> to display it
  40025. * @param mimeType The MIME type of the screenshot image (default: image/png).
  40026. * Check your browser for supported MIME types
  40027. * @param samples Texture samples (default: 1)
  40028. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  40029. * @param fileName A name for for the downloaded file.
  40030. */
  40031. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  40032. /**
  40033. * Validates if xhr data is correct
  40034. * @param xhr defines the request to validate
  40035. * @param dataType defines the expected data type
  40036. * @returns true if data is correct
  40037. */
  40038. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  40039. /**
  40040. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  40041. * Be aware Math.random() could cause collisions, but:
  40042. * "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"
  40043. * @returns a pseudo random id
  40044. */
  40045. static RandomId(): string;
  40046. /**
  40047. * Test if the given uri is a base64 string
  40048. * @param uri The uri to test
  40049. * @return True if the uri is a base64 string or false otherwise
  40050. */
  40051. static IsBase64(uri: string): boolean;
  40052. /**
  40053. * Decode the given base64 uri.
  40054. * @param uri The uri to decode
  40055. * @return The decoded base64 data.
  40056. */
  40057. static DecodeBase64(uri: string): ArrayBuffer;
  40058. /**
  40059. * No log
  40060. */
  40061. static readonly NoneLogLevel: number;
  40062. /**
  40063. * Only message logs
  40064. */
  40065. static readonly MessageLogLevel: number;
  40066. /**
  40067. * Only warning logs
  40068. */
  40069. static readonly WarningLogLevel: number;
  40070. /**
  40071. * Only error logs
  40072. */
  40073. static readonly ErrorLogLevel: number;
  40074. /**
  40075. * All logs
  40076. */
  40077. static readonly AllLogLevel: number;
  40078. private static _LogCache;
  40079. /**
  40080. * Gets a value indicating the number of loading errors
  40081. * @ignorenaming
  40082. */
  40083. static errorsCount: number;
  40084. /**
  40085. * Callback called when a new log is added
  40086. */
  40087. static OnNewCacheEntry: (entry: string) => void;
  40088. private static _AddLogEntry;
  40089. private static _FormatMessage;
  40090. private static _LogDisabled;
  40091. private static _LogEnabled;
  40092. private static _WarnDisabled;
  40093. private static _WarnEnabled;
  40094. private static _ErrorDisabled;
  40095. private static _ErrorEnabled;
  40096. /**
  40097. * Log a message to the console
  40098. */
  40099. static Log: (message: string) => void;
  40100. /**
  40101. * Write a warning message to the console
  40102. */
  40103. static Warn: (message: string) => void;
  40104. /**
  40105. * Write an error message to the console
  40106. */
  40107. static Error: (message: string) => void;
  40108. /**
  40109. * Gets current log cache (list of logs)
  40110. */
  40111. static readonly LogCache: string;
  40112. /**
  40113. * Clears the log cache
  40114. */
  40115. static ClearLogCache(): void;
  40116. /**
  40117. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  40118. */
  40119. static LogLevels: number;
  40120. /**
  40121. * Checks if the loaded document was accessed via `file:`-Protocol.
  40122. * @returns boolean
  40123. */
  40124. static IsFileURL(): boolean;
  40125. /**
  40126. * Checks if the window object exists
  40127. * @returns true if the window object exists
  40128. */
  40129. static IsWindowObjectExist(): boolean;
  40130. /**
  40131. * No performance log
  40132. */
  40133. static readonly PerformanceNoneLogLevel: number;
  40134. /**
  40135. * Use user marks to log performance
  40136. */
  40137. static readonly PerformanceUserMarkLogLevel: number;
  40138. /**
  40139. * Log performance to the console
  40140. */
  40141. static readonly PerformanceConsoleLogLevel: number;
  40142. private static _performance;
  40143. /**
  40144. * Sets the current performance log level
  40145. */
  40146. static PerformanceLogLevel: number;
  40147. private static _StartPerformanceCounterDisabled;
  40148. private static _EndPerformanceCounterDisabled;
  40149. private static _StartUserMark;
  40150. private static _EndUserMark;
  40151. private static _StartPerformanceConsole;
  40152. private static _EndPerformanceConsole;
  40153. /**
  40154. * Injects the @see CustomRequestHeaders into the given request
  40155. * @param request the request that should be used for injection
  40156. */
  40157. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  40158. /**
  40159. * Starts a performance counter
  40160. */
  40161. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40162. /**
  40163. * Ends a specific performance coutner
  40164. */
  40165. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40166. /**
  40167. * Gets either window.performance.now() if supported or Date.now() else
  40168. */
  40169. static readonly Now: number;
  40170. /**
  40171. * This method will return the name of the class used to create the instance of the given object.
  40172. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40173. * @param object the object to get the class name from
  40174. * @param isType defines if the object is actually a type
  40175. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40176. */
  40177. static GetClassName(object: any, isType?: boolean): string;
  40178. /**
  40179. * Gets the first element of an array satisfying a given predicate
  40180. * @param array defines the array to browse
  40181. * @param predicate defines the predicate to use
  40182. * @returns null if not found or the element
  40183. */
  40184. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40185. /**
  40186. * This method will return the name of the full name of the class, including its owning module (if any).
  40187. * 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).
  40188. * @param object the object to get the class name from
  40189. * @param isType defines if the object is actually a type
  40190. * @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.
  40191. * @ignorenaming
  40192. */
  40193. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40194. /**
  40195. * Returns a promise that resolves after the given amount of time.
  40196. * @param delay Number of milliseconds to delay
  40197. * @returns Promise that resolves after the given amount of time
  40198. */
  40199. static DelayAsync(delay: number): Promise<void>;
  40200. /**
  40201. * Gets the current gradient from an array of IValueGradient
  40202. * @param ratio defines the current ratio to get
  40203. * @param gradients defines the array of IValueGradient
  40204. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  40205. */
  40206. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  40207. }
  40208. /**
  40209. * This class is used to track a performance counter which is number based.
  40210. * The user has access to many properties which give statistics of different nature.
  40211. *
  40212. * The implementer can track two kinds of Performance Counter: time and count.
  40213. * 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.
  40214. * 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.
  40215. */
  40216. class PerfCounter {
  40217. /**
  40218. * Gets or sets a global boolean to turn on and off all the counters
  40219. */
  40220. static Enabled: boolean;
  40221. /**
  40222. * Returns the smallest value ever
  40223. */
  40224. readonly min: number;
  40225. /**
  40226. * Returns the biggest value ever
  40227. */
  40228. readonly max: number;
  40229. /**
  40230. * Returns the average value since the performance counter is running
  40231. */
  40232. readonly average: number;
  40233. /**
  40234. * Returns the average value of the last second the counter was monitored
  40235. */
  40236. readonly lastSecAverage: number;
  40237. /**
  40238. * Returns the current value
  40239. */
  40240. readonly current: number;
  40241. /**
  40242. * Gets the accumulated total
  40243. */
  40244. readonly total: number;
  40245. /**
  40246. * Gets the total value count
  40247. */
  40248. readonly count: number;
  40249. /**
  40250. * Creates a new counter
  40251. */
  40252. constructor();
  40253. /**
  40254. * Call this method to start monitoring a new frame.
  40255. * 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.
  40256. */
  40257. fetchNewFrame(): void;
  40258. /**
  40259. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40260. * @param newCount the count value to add to the monitored count
  40261. * @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.
  40262. */
  40263. addCount(newCount: number, fetchResult: boolean): void;
  40264. /**
  40265. * Start monitoring this performance counter
  40266. */
  40267. beginMonitoring(): void;
  40268. /**
  40269. * Compute the time lapsed since the previous beginMonitoring() call.
  40270. * @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
  40271. */
  40272. endMonitoring(newFrame?: boolean): void;
  40273. private _fetchResult;
  40274. private _startMonitoringTime;
  40275. private _min;
  40276. private _max;
  40277. private _average;
  40278. private _current;
  40279. private _totalValueCount;
  40280. private _totalAccumulated;
  40281. private _lastSecAverage;
  40282. private _lastSecAccumulated;
  40283. private _lastSecTime;
  40284. private _lastSecValueCount;
  40285. }
  40286. /**
  40287. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40288. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40289. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40290. * @param name The name of the class, case should be preserved
  40291. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40292. */
  40293. function className(name: string, module?: string): (target: Object) => void;
  40294. /**
  40295. * An implementation of a loop for asynchronous functions.
  40296. */
  40297. class AsyncLoop {
  40298. /**
  40299. * Defines the number of iterations for the loop
  40300. */
  40301. iterations: number;
  40302. /**
  40303. * Defines the current index of the loop.
  40304. */
  40305. index: number;
  40306. private _done;
  40307. private _fn;
  40308. private _successCallback;
  40309. /**
  40310. * Constructor.
  40311. * @param iterations the number of iterations.
  40312. * @param func the function to run each iteration
  40313. * @param successCallback the callback that will be called upon succesful execution
  40314. * @param offset starting offset.
  40315. */
  40316. constructor(
  40317. /**
  40318. * Defines the number of iterations for the loop
  40319. */
  40320. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40321. /**
  40322. * Execute the next iteration. Must be called after the last iteration was finished.
  40323. */
  40324. executeNext(): void;
  40325. /**
  40326. * Break the loop and run the success callback.
  40327. */
  40328. breakLoop(): void;
  40329. /**
  40330. * Create and run an async loop.
  40331. * @param iterations the number of iterations.
  40332. * @param fn the function to run each iteration
  40333. * @param successCallback the callback that will be called upon succesful execution
  40334. * @param offset starting offset.
  40335. * @returns the created async loop object
  40336. */
  40337. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40338. /**
  40339. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40340. * @param iterations total number of iterations
  40341. * @param syncedIterations number of synchronous iterations in each async iteration.
  40342. * @param fn the function to call each iteration.
  40343. * @param callback a success call back that will be called when iterating stops.
  40344. * @param breakFunction a break condition (optional)
  40345. * @param timeout timeout settings for the setTimeout function. default - 0.
  40346. * @returns the created async loop object
  40347. */
  40348. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40349. }
  40350. }
  40351. interface HTMLCanvasElement {
  40352. /** Track wether a record is in progress */
  40353. isRecording: boolean;
  40354. /** Capture Stream method defined by some browsers */
  40355. captureStream(fps?: number): MediaStream;
  40356. }
  40357. interface MediaRecorder {
  40358. /** Starts recording */
  40359. start(timeSlice: number): void;
  40360. /** Stops recording */
  40361. stop(): void;
  40362. /** Event raised when an error arised. */
  40363. onerror: (event: ErrorEvent) => void;
  40364. /** Event raised when the recording stops. */
  40365. onstop: (event: Event) => void;
  40366. /** Event raised when a new chunk of data is available and should be tracked. */
  40367. ondataavailable: (event: Event) => void;
  40368. }
  40369. interface MediaRecorderOptions {
  40370. /** The mime type you want to use as the recording container for the new MediaRecorder */
  40371. mimeType?: string;
  40372. /** The chosen bitrate for the audio component of the media. */
  40373. audioBitsPerSecond?: number;
  40374. /** The chosen bitrate for the video component of the media. */
  40375. videoBitsPerSecond?: number;
  40376. /** The chosen bitrate for the audio and video components of the media. This can be specified instead of the above two properties. If this is specified along with one or the other of the above properties, this will be used for the one that isn't specified. */
  40377. bitsPerSecond?: number;
  40378. }
  40379. interface MediaRecorderConstructor {
  40380. /**
  40381. * A reference to the prototype.
  40382. */
  40383. readonly prototype: MediaRecorder;
  40384. /**
  40385. * Creates a new MediaRecorder.
  40386. * @param stream Defines the stream to record.
  40387. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  40388. */
  40389. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  40390. }
  40391. /**
  40392. * MediaRecoreder object available in some browsers.
  40393. */
  40394. declare var MediaRecorder: MediaRecorderConstructor;
  40395. declare module BABYLON {
  40396. /**
  40397. * This represents the different options avilable for the video capture.
  40398. */
  40399. interface VideoRecorderOptions {
  40400. /** Defines the mime type of the video */
  40401. mimeType: string;
  40402. /** Defines the video the video should be recorded at */
  40403. fps: number;
  40404. /** Defines the chunk size for the recording data */
  40405. recordChunckSize: number;
  40406. }
  40407. /**
  40408. * This can helps recording videos from BabylonJS.
  40409. * This is based on the available WebRTC functionalities of the browser.
  40410. *
  40411. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  40412. */
  40413. class VideoRecorder {
  40414. private static readonly _defaultOptions;
  40415. /**
  40416. * Returns wehther or not the VideoRecorder is available in your browser.
  40417. * @param engine Defines the Babylon Engine to check the support for
  40418. * @returns true if supported otherwise false
  40419. */
  40420. static IsSupported(engine: Engine): boolean;
  40421. private readonly _options;
  40422. private _canvas;
  40423. private _mediaRecorder;
  40424. private _recordedChunks;
  40425. private _fileName;
  40426. private _resolve;
  40427. private _reject;
  40428. /**
  40429. * True wether a recording is already in progress.
  40430. */
  40431. readonly isRecording: boolean;
  40432. /**
  40433. * Create a new VideoCapture object which can help converting what you see in Babylon to
  40434. * a video file.
  40435. * @param engine Defines the BabylonJS Engine you wish to record
  40436. * @param options Defines options that can be used to customized the capture
  40437. */
  40438. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  40439. /**
  40440. * Stops the current recording before the default capture timeout passed in the startRecording
  40441. * functions.
  40442. */
  40443. stopRecording(): void;
  40444. /**
  40445. * Starts recording the canvas for a max duration specified in parameters.
  40446. * @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.
  40447. * @param maxDuration Defines the maximum recording time in seconds.
  40448. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  40449. * @return a promise callback at the end of the recording with the video data in Blob.
  40450. */
  40451. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  40452. /**
  40453. * Releases internal resources used during the recording.
  40454. */
  40455. dispose(): void;
  40456. private _handleDataAvailable;
  40457. private _handleError;
  40458. private _handleStop;
  40459. }
  40460. }
  40461. declare module BABYLON {
  40462. /**
  40463. * Defines the potential axis of a Joystick
  40464. */
  40465. enum JoystickAxis {
  40466. /** X axis */
  40467. X = 0,
  40468. /** Y axis */
  40469. Y = 1,
  40470. /** Z axis */
  40471. Z = 2
  40472. }
  40473. /**
  40474. * Class used to define virtual joystick (used in touch mode)
  40475. */
  40476. class VirtualJoystick {
  40477. /**
  40478. * Gets or sets a boolean indicating that left and right values must be inverted
  40479. */
  40480. reverseLeftRight: boolean;
  40481. /**
  40482. * Gets or sets a boolean indicating that up and down values must be inverted
  40483. */
  40484. reverseUpDown: boolean;
  40485. /**
  40486. * Gets the offset value for the position (ie. the change of the position value)
  40487. */
  40488. deltaPosition: Vector3;
  40489. /**
  40490. * Gets a boolean indicating if the virtual joystick was pressed
  40491. */
  40492. pressed: boolean;
  40493. /**
  40494. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40495. */
  40496. static Canvas: Nullable<HTMLCanvasElement>;
  40497. private static _globalJoystickIndex;
  40498. private static vjCanvasContext;
  40499. private static vjCanvasWidth;
  40500. private static vjCanvasHeight;
  40501. private static halfWidth;
  40502. private _action;
  40503. private _axisTargetedByLeftAndRight;
  40504. private _axisTargetedByUpAndDown;
  40505. private _joystickSensibility;
  40506. private _inversedSensibility;
  40507. private _joystickPointerID;
  40508. private _joystickColor;
  40509. private _joystickPointerPos;
  40510. private _joystickPreviousPointerPos;
  40511. private _joystickPointerStartPos;
  40512. private _deltaJoystickVector;
  40513. private _leftJoystick;
  40514. private _touches;
  40515. private _onPointerDownHandlerRef;
  40516. private _onPointerMoveHandlerRef;
  40517. private _onPointerUpHandlerRef;
  40518. private _onResize;
  40519. /**
  40520. * Creates a new virtual joystick
  40521. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40522. */
  40523. constructor(leftJoystick?: boolean);
  40524. /**
  40525. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40526. * @param newJoystickSensibility defines the new sensibility
  40527. */
  40528. setJoystickSensibility(newJoystickSensibility: number): void;
  40529. private _onPointerDown;
  40530. private _onPointerMove;
  40531. private _onPointerUp;
  40532. /**
  40533. * Change the color of the virtual joystick
  40534. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40535. */
  40536. setJoystickColor(newColor: string): void;
  40537. /**
  40538. * Defines a callback to call when the joystick is touched
  40539. * @param action defines the callback
  40540. */
  40541. setActionOnTouch(action: () => any): void;
  40542. /**
  40543. * Defines which axis you'd like to control for left & right
  40544. * @param axis defines the axis to use
  40545. */
  40546. setAxisForLeftRight(axis: JoystickAxis): void;
  40547. /**
  40548. * Defines which axis you'd like to control for up & down
  40549. * @param axis defines the axis to use
  40550. */
  40551. setAxisForUpDown(axis: JoystickAxis): void;
  40552. private _drawVirtualJoystick;
  40553. /**
  40554. * Release internal HTML canvas
  40555. */
  40556. releaseCanvas(): void;
  40557. }
  40558. }
  40559. declare module BABYLON {
  40560. /**
  40561. * Helper class to push actions to a pool of workers.
  40562. */
  40563. class WorkerPool implements IDisposable {
  40564. private _workerInfos;
  40565. private _pendingActions;
  40566. /**
  40567. * Constructor
  40568. * @param workers Array of workers to use for actions
  40569. */
  40570. constructor(workers: Array<Worker>);
  40571. /**
  40572. * Terminates all workers and clears any pending actions.
  40573. */
  40574. dispose(): void;
  40575. /**
  40576. * Pushes an action to the worker pool. If all the workers are active, the action will be
  40577. * pended until a worker has completed its action.
  40578. * @param action The action to perform. Call onComplete when the action is complete.
  40579. */
  40580. push(action: (worker: Worker, onComplete: () => void) => void): void;
  40581. private _execute;
  40582. }
  40583. }
  40584. declare module BABYLON {
  40585. /**
  40586. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40587. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40588. */
  40589. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40590. /**
  40591. * Gets the name of the behavior.
  40592. */
  40593. readonly name: string;
  40594. private _zoomStopsAnimation;
  40595. private _idleRotationSpeed;
  40596. private _idleRotationWaitTime;
  40597. private _idleRotationSpinupTime;
  40598. /**
  40599. * Sets the flag that indicates if user zooming should stop animation.
  40600. */
  40601. /**
  40602. * Gets the flag that indicates if user zooming should stop animation.
  40603. */
  40604. zoomStopsAnimation: boolean;
  40605. /**
  40606. * Sets the default speed at which the camera rotates around the model.
  40607. */
  40608. /**
  40609. * Gets the default speed at which the camera rotates around the model.
  40610. */
  40611. idleRotationSpeed: number;
  40612. /**
  40613. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40614. */
  40615. /**
  40616. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40617. */
  40618. idleRotationWaitTime: number;
  40619. /**
  40620. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40621. */
  40622. /**
  40623. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40624. */
  40625. idleRotationSpinupTime: number;
  40626. /**
  40627. * Gets a value indicating if the camera is currently rotating because of this behavior
  40628. */
  40629. readonly rotationInProgress: boolean;
  40630. private _onPrePointerObservableObserver;
  40631. private _onAfterCheckInputsObserver;
  40632. private _attachedCamera;
  40633. private _isPointerDown;
  40634. private _lastFrameTime;
  40635. private _lastInteractionTime;
  40636. private _cameraRotationSpeed;
  40637. /**
  40638. * Initializes the behavior.
  40639. */
  40640. init(): void;
  40641. /**
  40642. * Attaches the behavior to its arc rotate camera.
  40643. * @param camera Defines the camera to attach the behavior to
  40644. */
  40645. attach(camera: ArcRotateCamera): void;
  40646. /**
  40647. * Detaches the behavior from its current arc rotate camera.
  40648. */
  40649. detach(): void;
  40650. /**
  40651. * Returns true if user is scrolling.
  40652. * @return true if user is scrolling.
  40653. */
  40654. private _userIsZooming;
  40655. private _lastFrameRadius;
  40656. private _shouldAnimationStopForInteraction;
  40657. /**
  40658. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40659. */
  40660. private _applyUserInteraction;
  40661. private _userIsMoving;
  40662. }
  40663. }
  40664. declare module BABYLON {
  40665. /**
  40666. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40667. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40668. */
  40669. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40670. /**
  40671. * Gets the name of the behavior.
  40672. */
  40673. readonly name: string;
  40674. /**
  40675. * The easing function used by animations
  40676. */
  40677. static EasingFunction: BackEase;
  40678. /**
  40679. * The easing mode used by animations
  40680. */
  40681. static EasingMode: number;
  40682. /**
  40683. * The duration of the animation, in milliseconds
  40684. */
  40685. transitionDuration: number;
  40686. /**
  40687. * Length of the distance animated by the transition when lower radius is reached
  40688. */
  40689. lowerRadiusTransitionRange: number;
  40690. /**
  40691. * Length of the distance animated by the transition when upper radius is reached
  40692. */
  40693. upperRadiusTransitionRange: number;
  40694. private _autoTransitionRange;
  40695. /**
  40696. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40697. */
  40698. /**
  40699. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40700. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40701. */
  40702. autoTransitionRange: boolean;
  40703. private _attachedCamera;
  40704. private _onAfterCheckInputsObserver;
  40705. private _onMeshTargetChangedObserver;
  40706. /**
  40707. * Initializes the behavior.
  40708. */
  40709. init(): void;
  40710. /**
  40711. * Attaches the behavior to its arc rotate camera.
  40712. * @param camera Defines the camera to attach the behavior to
  40713. */
  40714. attach(camera: ArcRotateCamera): void;
  40715. /**
  40716. * Detaches the behavior from its current arc rotate camera.
  40717. */
  40718. detach(): void;
  40719. private _radiusIsAnimating;
  40720. private _radiusBounceTransition;
  40721. private _animatables;
  40722. private _cachedWheelPrecision;
  40723. /**
  40724. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40725. * @param radiusLimit The limit to check against.
  40726. * @return Bool to indicate if at limit.
  40727. */
  40728. private _isRadiusAtLimit;
  40729. /**
  40730. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40731. * @param radiusDelta The delta by which to animate to. Can be negative.
  40732. */
  40733. private _applyBoundRadiusAnimation;
  40734. /**
  40735. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40736. */
  40737. protected _clearAnimationLocks(): void;
  40738. /**
  40739. * Stops and removes all animations that have been applied to the camera
  40740. */
  40741. stopAllAnimations(): void;
  40742. }
  40743. }
  40744. declare module BABYLON {
  40745. /**
  40746. * The framing behavior (BABYLON.FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  40747. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40748. */
  40749. class FramingBehavior implements Behavior<ArcRotateCamera> {
  40750. /**
  40751. * Gets the name of the behavior.
  40752. */
  40753. readonly name: string;
  40754. private _mode;
  40755. private _radiusScale;
  40756. private _positionScale;
  40757. private _defaultElevation;
  40758. private _elevationReturnTime;
  40759. private _elevationReturnWaitTime;
  40760. private _zoomStopsAnimation;
  40761. private _framingTime;
  40762. /**
  40763. * The easing function used by animations
  40764. */
  40765. static EasingFunction: ExponentialEase;
  40766. /**
  40767. * The easing mode used by animations
  40768. */
  40769. static EasingMode: number;
  40770. /**
  40771. * Sets the current mode used by the behavior
  40772. */
  40773. /**
  40774. * Gets current mode used by the behavior.
  40775. */
  40776. mode: number;
  40777. /**
  40778. * Sets the scale applied to the radius (1 by default)
  40779. */
  40780. /**
  40781. * Gets the scale applied to the radius
  40782. */
  40783. radiusScale: number;
  40784. /**
  40785. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40786. */
  40787. /**
  40788. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40789. */
  40790. positionScale: number;
  40791. /**
  40792. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40793. * behaviour is triggered, in radians.
  40794. */
  40795. /**
  40796. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40797. * behaviour is triggered, in radians.
  40798. */
  40799. defaultElevation: number;
  40800. /**
  40801. * Sets the time (in milliseconds) taken to return to the default beta position.
  40802. * Negative value indicates camera should not return to default.
  40803. */
  40804. /**
  40805. * Gets the time (in milliseconds) taken to return to the default beta position.
  40806. * Negative value indicates camera should not return to default.
  40807. */
  40808. elevationReturnTime: number;
  40809. /**
  40810. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40811. */
  40812. /**
  40813. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40814. */
  40815. elevationReturnWaitTime: number;
  40816. /**
  40817. * Sets the flag that indicates if user zooming should stop animation.
  40818. */
  40819. /**
  40820. * Gets the flag that indicates if user zooming should stop animation.
  40821. */
  40822. zoomStopsAnimation: boolean;
  40823. /**
  40824. * Sets the transition time when framing the mesh, in milliseconds
  40825. */
  40826. /**
  40827. * Gets the transition time when framing the mesh, in milliseconds
  40828. */
  40829. framingTime: number;
  40830. /**
  40831. * Define if the behavior should automatically change the configured
  40832. * camera limits and sensibilities.
  40833. */
  40834. autoCorrectCameraLimitsAndSensibility: boolean;
  40835. private _onPrePointerObservableObserver;
  40836. private _onAfterCheckInputsObserver;
  40837. private _onMeshTargetChangedObserver;
  40838. private _attachedCamera;
  40839. private _isPointerDown;
  40840. private _lastInteractionTime;
  40841. /**
  40842. * Initializes the behavior.
  40843. */
  40844. init(): void;
  40845. /**
  40846. * Attaches the behavior to its arc rotate camera.
  40847. * @param camera Defines the camera to attach the behavior to
  40848. */
  40849. attach(camera: ArcRotateCamera): void;
  40850. /**
  40851. * Detaches the behavior from its current arc rotate camera.
  40852. */
  40853. detach(): void;
  40854. private _animatables;
  40855. private _betaIsAnimating;
  40856. private _betaTransition;
  40857. private _radiusTransition;
  40858. private _vectorTransition;
  40859. /**
  40860. * Targets the given mesh and updates zoom level accordingly.
  40861. * @param mesh The mesh to target.
  40862. * @param radius Optional. If a cached radius position already exists, overrides default.
  40863. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40864. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40865. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40866. */
  40867. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40868. /**
  40869. * Targets the given mesh with its children and updates zoom level accordingly.
  40870. * @param mesh The mesh to target.
  40871. * @param radius Optional. If a cached radius position already exists, overrides default.
  40872. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40873. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40874. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40875. */
  40876. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40877. /**
  40878. * Targets the given meshes with their children and updates zoom level accordingly.
  40879. * @param meshes The mesh to target.
  40880. * @param radius Optional. If a cached radius position already exists, overrides default.
  40881. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40882. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40883. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40884. */
  40885. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40886. /**
  40887. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  40888. * @param minimumWorld Determines the smaller position of the bounding box extend
  40889. * @param maximumWorld Determines the bigger position of the bounding box extend
  40890. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40891. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40892. */
  40893. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40894. /**
  40895. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  40896. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  40897. * frustum width.
  40898. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  40899. * to fully enclose the mesh in the viewing frustum.
  40900. */
  40901. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  40902. /**
  40903. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  40904. * is automatically returned to its default position (expected to be above ground plane).
  40905. */
  40906. private _maintainCameraAboveGround;
  40907. /**
  40908. * Returns the frustum slope based on the canvas ratio and camera FOV
  40909. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  40910. */
  40911. private _getFrustumSlope;
  40912. /**
  40913. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  40914. */
  40915. private _clearAnimationLocks;
  40916. /**
  40917. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40918. */
  40919. private _applyUserInteraction;
  40920. /**
  40921. * Stops and removes all animations that have been applied to the camera
  40922. */
  40923. stopAllAnimations(): void;
  40924. /**
  40925. * Gets a value indicating if the user is moving the camera
  40926. */
  40927. readonly isUserIsMoving: boolean;
  40928. /**
  40929. * The camera can move all the way towards the mesh.
  40930. */
  40931. static IgnoreBoundsSizeMode: number;
  40932. /**
  40933. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  40934. */
  40935. static FitFrustumSidesMode: number;
  40936. }
  40937. }
  40938. declare module BABYLON {
  40939. /**
  40940. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40941. */
  40942. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  40943. private ui;
  40944. /**
  40945. * The name of the behavior
  40946. */
  40947. name: string;
  40948. /**
  40949. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40950. */
  40951. distanceAwayFromFace: number;
  40952. /**
  40953. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40954. */
  40955. distanceAwayFromBottomOfFace: number;
  40956. private _faceVectors;
  40957. private _target;
  40958. private _scene;
  40959. private _onRenderObserver;
  40960. private _tmpMatrix;
  40961. private _tmpVector;
  40962. /**
  40963. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40964. * @param ui The transform node that should be attched to the mesh
  40965. */
  40966. constructor(ui: BABYLON.TransformNode);
  40967. /**
  40968. * Initializes the behavior
  40969. */
  40970. init(): void;
  40971. private _closestFace;
  40972. private _zeroVector;
  40973. private _lookAtTmpMatrix;
  40974. private _lookAtToRef;
  40975. /**
  40976. * Attaches the AttachToBoxBehavior to the passed in mesh
  40977. * @param target The mesh that the specified node will be attached to
  40978. */
  40979. attach(target: BABYLON.Mesh): void;
  40980. /**
  40981. * Detaches the behavior from the mesh
  40982. */
  40983. detach(): void;
  40984. }
  40985. }
  40986. declare module BABYLON {
  40987. /**
  40988. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40989. */
  40990. class FadeInOutBehavior implements Behavior<Mesh> {
  40991. /**
  40992. * Time in milliseconds to delay before fading in (Default: 0)
  40993. */
  40994. delay: number;
  40995. /**
  40996. * Time in milliseconds for the mesh to fade in (Default: 300)
  40997. */
  40998. fadeInTime: number;
  40999. private _millisecondsPerFrame;
  41000. private _hovered;
  41001. private _hoverValue;
  41002. private _ownerNode;
  41003. /**
  41004. * Instatiates the FadeInOutBehavior
  41005. */
  41006. constructor();
  41007. /**
  41008. * The name of the behavior
  41009. */
  41010. readonly name: string;
  41011. /**
  41012. * Initializes the behavior
  41013. */
  41014. init(): void;
  41015. /**
  41016. * Attaches the fade behavior on the passed in mesh
  41017. * @param ownerNode The mesh that will be faded in/out once attached
  41018. */
  41019. attach(ownerNode: Mesh): void;
  41020. /**
  41021. * Detaches the behavior from the mesh
  41022. */
  41023. detach(): void;
  41024. /**
  41025. * Triggers the mesh to begin fading in or out
  41026. * @param value if the object should fade in or out (true to fade in)
  41027. */
  41028. fadeIn(value: boolean): void;
  41029. private _update;
  41030. private _setAllVisibility;
  41031. }
  41032. }
  41033. declare module BABYLON {
  41034. /**
  41035. * A behavior that when attached to a mesh will allow the mesh to be scaled
  41036. */
  41037. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  41038. private _dragBehaviorA;
  41039. private _dragBehaviorB;
  41040. private _startDistance;
  41041. private _initialScale;
  41042. private _targetScale;
  41043. private _ownerNode;
  41044. private _sceneRenderObserver;
  41045. /**
  41046. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  41047. */
  41048. constructor();
  41049. /**
  41050. * The name of the behavior
  41051. */
  41052. readonly name: string;
  41053. /**
  41054. * Initializes the behavior
  41055. */
  41056. init(): void;
  41057. private _getCurrentDistance;
  41058. /**
  41059. * Attaches the scale behavior the passed in mesh
  41060. * @param ownerNode The mesh that will be scaled around once attached
  41061. */
  41062. attach(ownerNode: Mesh): void;
  41063. /**
  41064. * Detaches the behavior from the mesh
  41065. */
  41066. detach(): void;
  41067. }
  41068. }
  41069. declare module BABYLON {
  41070. /**
  41071. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  41072. */
  41073. class PointerDragBehavior implements Behavior<AbstractMesh> {
  41074. private static _AnyMouseID;
  41075. private _attachedNode;
  41076. private _dragPlane;
  41077. private _scene;
  41078. private _pointerObserver;
  41079. private _beforeRenderObserver;
  41080. private static _planeScene;
  41081. /**
  41082. * 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)
  41083. */
  41084. maxDragAngle: number;
  41085. /**
  41086. * @hidden
  41087. */
  41088. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  41089. /**
  41090. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41091. */
  41092. currentDraggingPointerID: number;
  41093. /**
  41094. * The last position where the pointer hit the drag plane in world space
  41095. */
  41096. lastDragPosition: Vector3;
  41097. /**
  41098. * If the behavior is currently in a dragging state
  41099. */
  41100. dragging: boolean;
  41101. /**
  41102. * 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)
  41103. */
  41104. dragDeltaRatio: number;
  41105. /**
  41106. * If the drag plane orientation should be updated during the dragging (Default: true)
  41107. */
  41108. updateDragPlane: boolean;
  41109. private _debugMode;
  41110. private _moving;
  41111. /**
  41112. * Fires each time the attached mesh is dragged with the pointer
  41113. * * delta between last drag position and current drag position in world space
  41114. * * dragDistance along the drag axis
  41115. * * dragPlaneNormal normal of the current drag plane used during the drag
  41116. * * dragPlanePoint in world space where the drag intersects the drag plane
  41117. */
  41118. onDragObservable: Observable<{
  41119. delta: Vector3;
  41120. dragPlanePoint: Vector3;
  41121. dragPlaneNormal: Vector3;
  41122. dragDistance: number;
  41123. pointerId: number;
  41124. }>;
  41125. /**
  41126. * Fires each time a drag begins (eg. mouse down on mesh)
  41127. */
  41128. onDragStartObservable: Observable<{
  41129. dragPlanePoint: Vector3;
  41130. pointerId: number;
  41131. }>;
  41132. /**
  41133. * Fires each time a drag ends (eg. mouse release after drag)
  41134. */
  41135. onDragEndObservable: Observable<{
  41136. dragPlanePoint: Vector3;
  41137. pointerId: number;
  41138. }>;
  41139. /**
  41140. * If the attached mesh should be moved when dragged
  41141. */
  41142. moveAttached: boolean;
  41143. /**
  41144. * If the drag behavior will react to drag events (Default: true)
  41145. */
  41146. enabled: boolean;
  41147. /**
  41148. * If camera controls should be detached during the drag
  41149. */
  41150. detachCameraControls: boolean;
  41151. /**
  41152. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  41153. */
  41154. useObjectOrienationForDragging: boolean;
  41155. private _options;
  41156. /**
  41157. * Creates a pointer drag behavior that can be attached to a mesh
  41158. * @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)
  41159. */
  41160. constructor(options?: {
  41161. dragAxis?: Vector3;
  41162. dragPlaneNormal?: Vector3;
  41163. });
  41164. /**
  41165. * The name of the behavior
  41166. */
  41167. readonly name: string;
  41168. /**
  41169. * Initializes the behavior
  41170. */
  41171. init(): void;
  41172. private _tmpVector;
  41173. private _alternatePickedPoint;
  41174. private _worldDragAxis;
  41175. private _targetPosition;
  41176. private _attachedElement;
  41177. /**
  41178. * Attaches the drag behavior the passed in mesh
  41179. * @param ownerNode The mesh that will be dragged around once attached
  41180. */
  41181. attach(ownerNode: AbstractMesh): void;
  41182. /**
  41183. * Force relase the drag action by code.
  41184. */
  41185. releaseDrag(): void;
  41186. private _startDragRay;
  41187. private _lastPointerRay;
  41188. /**
  41189. * Simulates the start of a pointer drag event on the behavior
  41190. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  41191. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  41192. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  41193. */
  41194. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  41195. private _startDrag;
  41196. private _dragDelta;
  41197. private _moveDrag;
  41198. private _pickWithRayOnDragPlane;
  41199. private _pointA;
  41200. private _pointB;
  41201. private _pointC;
  41202. private _lineA;
  41203. private _lineB;
  41204. private _localAxis;
  41205. private _lookAt;
  41206. private _updateDragPlanePosition;
  41207. /**
  41208. * Detaches the behavior from the mesh
  41209. */
  41210. detach(): void;
  41211. }
  41212. }
  41213. declare module BABYLON {
  41214. /**
  41215. * 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
  41216. */
  41217. class SixDofDragBehavior implements Behavior<Mesh> {
  41218. private static _virtualScene;
  41219. private _ownerNode;
  41220. private _sceneRenderObserver;
  41221. private _scene;
  41222. private _targetPosition;
  41223. private _virtualOriginMesh;
  41224. private _virtualDragMesh;
  41225. private _pointerObserver;
  41226. private _moving;
  41227. private _startingOrientation;
  41228. /**
  41229. * 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)
  41230. */
  41231. private zDragFactor;
  41232. /**
  41233. * If the object should rotate to face the drag origin
  41234. */
  41235. rotateDraggedObject: boolean;
  41236. /**
  41237. * If the behavior is currently in a dragging state
  41238. */
  41239. dragging: boolean;
  41240. /**
  41241. * 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)
  41242. */
  41243. dragDeltaRatio: number;
  41244. /**
  41245. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41246. */
  41247. currentDraggingPointerID: number;
  41248. /**
  41249. * If camera controls should be detached during the drag
  41250. */
  41251. detachCameraControls: boolean;
  41252. /**
  41253. * Fires each time a drag starts
  41254. */
  41255. onDragStartObservable: Observable<{}>;
  41256. /**
  41257. * Fires each time a drag ends (eg. mouse release after drag)
  41258. */
  41259. onDragEndObservable: Observable<{}>;
  41260. /**
  41261. * 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
  41262. */
  41263. constructor();
  41264. /**
  41265. * The name of the behavior
  41266. */
  41267. readonly name: string;
  41268. /**
  41269. * Initializes the behavior
  41270. */
  41271. init(): void;
  41272. /**
  41273. * Attaches the scale behavior the passed in mesh
  41274. * @param ownerNode The mesh that will be scaled around once attached
  41275. */
  41276. attach(ownerNode: Mesh): void;
  41277. /**
  41278. * Detaches the behavior from the mesh
  41279. */
  41280. detach(): void;
  41281. }
  41282. }
  41283. declare module BABYLON {
  41284. /**
  41285. * Manage the gamepad inputs to control an arc rotate camera.
  41286. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41287. */
  41288. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41289. /**
  41290. * Defines the camera the input is attached to.
  41291. */
  41292. camera: ArcRotateCamera;
  41293. /**
  41294. * Defines the gamepad the input is gathering event from.
  41295. */
  41296. gamepad: Nullable<Gamepad>;
  41297. /**
  41298. * Defines the gamepad rotation sensiblity.
  41299. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41300. */
  41301. gamepadRotationSensibility: number;
  41302. /**
  41303. * Defines the gamepad move sensiblity.
  41304. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41305. */
  41306. gamepadMoveSensibility: number;
  41307. private _onGamepadConnectedObserver;
  41308. private _onGamepadDisconnectedObserver;
  41309. /**
  41310. * Attach the input controls to a specific dom element to get the input from.
  41311. * @param element Defines the element the controls should be listened from
  41312. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41313. */
  41314. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41315. /**
  41316. * Detach the current controls from the specified dom element.
  41317. * @param element Defines the element to stop listening the inputs from
  41318. */
  41319. detachControl(element: Nullable<HTMLElement>): void;
  41320. /**
  41321. * Update the current camera state depending on the inputs that have been used this frame.
  41322. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41323. */
  41324. checkInputs(): void;
  41325. /**
  41326. * Gets the class name of the current intput.
  41327. * @returns the class name
  41328. */
  41329. getClassName(): string;
  41330. /**
  41331. * Get the friendly name associated with the input class.
  41332. * @returns the input friendly name
  41333. */
  41334. getSimpleName(): string;
  41335. }
  41336. }
  41337. declare module BABYLON {
  41338. /**
  41339. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41340. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41341. */
  41342. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41343. /**
  41344. * Defines the camera the input is attached to.
  41345. */
  41346. camera: ArcRotateCamera;
  41347. /**
  41348. * Defines the list of key codes associated with the up action (increase alpha)
  41349. */
  41350. keysUp: number[];
  41351. /**
  41352. * Defines the list of key codes associated with the down action (decrease alpha)
  41353. */
  41354. keysDown: number[];
  41355. /**
  41356. * Defines the list of key codes associated with the left action (increase beta)
  41357. */
  41358. keysLeft: number[];
  41359. /**
  41360. * Defines the list of key codes associated with the right action (decrease beta)
  41361. */
  41362. keysRight: number[];
  41363. /**
  41364. * Defines the list of key codes associated with the reset action.
  41365. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41366. */
  41367. keysReset: number[];
  41368. /**
  41369. * Defines the panning sensibility of the inputs.
  41370. * (How fast is the camera paning)
  41371. */
  41372. panningSensibility: number;
  41373. /**
  41374. * Defines the zooming sensibility of the inputs.
  41375. * (How fast is the camera zooming)
  41376. */
  41377. zoomingSensibility: number;
  41378. /**
  41379. * Defines wether maintaining the alt key down switch the movement mode from
  41380. * orientation to zoom.
  41381. */
  41382. useAltToZoom: boolean;
  41383. /**
  41384. * Rotation speed of the camera
  41385. */
  41386. angularSpeed: number;
  41387. private _keys;
  41388. private _ctrlPressed;
  41389. private _altPressed;
  41390. private _onCanvasBlurObserver;
  41391. private _onKeyboardObserver;
  41392. private _engine;
  41393. private _scene;
  41394. /**
  41395. * Attach the input controls to a specific dom element to get the input from.
  41396. * @param element Defines the element the controls should be listened from
  41397. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41398. */
  41399. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41400. /**
  41401. * Detach the current controls from the specified dom element.
  41402. * @param element Defines the element to stop listening the inputs from
  41403. */
  41404. detachControl(element: Nullable<HTMLElement>): void;
  41405. /**
  41406. * Update the current camera state depending on the inputs that have been used this frame.
  41407. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41408. */
  41409. checkInputs(): void;
  41410. /**
  41411. * Gets the class name of the current intput.
  41412. * @returns the class name
  41413. */
  41414. getClassName(): string;
  41415. /**
  41416. * Get the friendly name associated with the input class.
  41417. * @returns the input friendly name
  41418. */
  41419. getSimpleName(): string;
  41420. }
  41421. }
  41422. declare module BABYLON {
  41423. /**
  41424. * Manage the mouse wheel inputs to control an arc rotate camera.
  41425. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41426. */
  41427. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41428. /**
  41429. * Defines the camera the input is attached to.
  41430. */
  41431. camera: ArcRotateCamera;
  41432. /**
  41433. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41434. */
  41435. wheelPrecision: number;
  41436. /**
  41437. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41438. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41439. */
  41440. wheelDeltaPercentage: number;
  41441. private _wheel;
  41442. private _observer;
  41443. /**
  41444. * Attach the input controls to a specific dom element to get the input from.
  41445. * @param element Defines the element the controls should be listened from
  41446. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41447. */
  41448. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41449. /**
  41450. * Detach the current controls from the specified dom element.
  41451. * @param element Defines the element to stop listening the inputs from
  41452. */
  41453. detachControl(element: Nullable<HTMLElement>): void;
  41454. /**
  41455. * Gets the class name of the current intput.
  41456. * @returns the class name
  41457. */
  41458. getClassName(): string;
  41459. /**
  41460. * Get the friendly name associated with the input class.
  41461. * @returns the input friendly name
  41462. */
  41463. getSimpleName(): string;
  41464. }
  41465. }
  41466. declare module BABYLON {
  41467. /**
  41468. * Manage the pointers inputs to control an arc rotate camera.
  41469. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41470. */
  41471. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  41472. /**
  41473. * Defines the camera the input is attached to.
  41474. */
  41475. camera: ArcRotateCamera;
  41476. /**
  41477. * Defines the buttons associated with the input to handle camera move.
  41478. */
  41479. buttons: number[];
  41480. /**
  41481. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41482. */
  41483. angularSensibilityX: number;
  41484. /**
  41485. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41486. */
  41487. angularSensibilityY: number;
  41488. /**
  41489. * Defines the pointer pinch precision or how fast is the camera zooming.
  41490. */
  41491. pinchPrecision: number;
  41492. /**
  41493. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  41494. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41495. */
  41496. pinchDeltaPercentage: number;
  41497. /**
  41498. * Defines the pointer panning sensibility or how fast is the camera moving.
  41499. */
  41500. panningSensibility: number;
  41501. /**
  41502. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41503. */
  41504. multiTouchPanning: boolean;
  41505. /**
  41506. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  41507. */
  41508. multiTouchPanAndZoom: boolean;
  41509. /**
  41510. * Revers pinch action direction.
  41511. */
  41512. pinchInwards: boolean;
  41513. private _isPanClick;
  41514. private _pointerInput;
  41515. private _observer;
  41516. private _onMouseMove;
  41517. private _onGestureStart;
  41518. private _onGesture;
  41519. private _MSGestureHandler;
  41520. private _onLostFocus;
  41521. private _onContextMenu;
  41522. /**
  41523. * Attach the input controls to a specific dom element to get the input from.
  41524. * @param element Defines the element the controls should be listened from
  41525. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41526. */
  41527. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41528. /**
  41529. * Detach the current controls from the specified dom element.
  41530. * @param element Defines the element to stop listening the inputs from
  41531. */
  41532. detachControl(element: Nullable<HTMLElement>): void;
  41533. /**
  41534. * Gets the class name of the current intput.
  41535. * @returns the class name
  41536. */
  41537. getClassName(): string;
  41538. /**
  41539. * Get the friendly name associated with the input class.
  41540. * @returns the input friendly name
  41541. */
  41542. getSimpleName(): string;
  41543. }
  41544. }
  41545. declare module BABYLON {
  41546. /**
  41547. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41548. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41549. */
  41550. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41551. /**
  41552. * Defines the camera the input is attached to.
  41553. */
  41554. camera: ArcRotateCamera;
  41555. /**
  41556. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41557. */
  41558. alphaCorrection: number;
  41559. /**
  41560. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41561. */
  41562. gammaCorrection: number;
  41563. private _alpha;
  41564. private _gamma;
  41565. private _dirty;
  41566. private _deviceOrientationHandler;
  41567. /**
  41568. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41569. */
  41570. constructor();
  41571. /**
  41572. * Attach the input controls to a specific dom element to get the input from.
  41573. * @param element Defines the element the controls should be listened from
  41574. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41575. */
  41576. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41577. /** @hidden */
  41578. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41579. /**
  41580. * Update the current camera state depending on the inputs that have been used this frame.
  41581. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41582. */
  41583. checkInputs(): void;
  41584. /**
  41585. * Detach the current controls from the specified dom element.
  41586. * @param element Defines the element to stop listening the inputs from
  41587. */
  41588. detachControl(element: Nullable<HTMLElement>): void;
  41589. /**
  41590. * Gets the class name of the current intput.
  41591. * @returns the class name
  41592. */
  41593. getClassName(): string;
  41594. /**
  41595. * Get the friendly name associated with the input class.
  41596. * @returns the input friendly name
  41597. */
  41598. getSimpleName(): string;
  41599. }
  41600. }
  41601. declare module BABYLON {
  41602. /**
  41603. * Listen to keyboard events to control the camera.
  41604. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41605. */
  41606. class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41607. /**
  41608. * Defines the camera the input is attached to.
  41609. */
  41610. camera: FlyCamera;
  41611. /**
  41612. * The list of keyboard keys used to control the forward move of the camera.
  41613. */
  41614. keysForward: number[];
  41615. /**
  41616. * The list of keyboard keys used to control the backward move of the camera.
  41617. */
  41618. keysBackward: number[];
  41619. /**
  41620. * The list of keyboard keys used to control the forward move of the camera.
  41621. */
  41622. keysUp: number[];
  41623. /**
  41624. * The list of keyboard keys used to control the backward move of the camera.
  41625. */
  41626. keysDown: number[];
  41627. /**
  41628. * The list of keyboard keys used to control the right strafe move of the camera.
  41629. */
  41630. keysRight: number[];
  41631. /**
  41632. * The list of keyboard keys used to control the left strafe move of the camera.
  41633. */
  41634. keysLeft: number[];
  41635. private _keys;
  41636. private _onCanvasBlurObserver;
  41637. private _onKeyboardObserver;
  41638. private _engine;
  41639. private _scene;
  41640. /**
  41641. * Attach the input controls to a specific dom element to get the input from.
  41642. * @param element Defines the element the controls should be listened from
  41643. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41644. */
  41645. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41646. /**
  41647. * Detach the current controls from the specified dom element.
  41648. * @param element Defines the element to stop listening the inputs from
  41649. */
  41650. detachControl(element: Nullable<HTMLElement>): void;
  41651. /**
  41652. * Gets the class name of the current intput.
  41653. * @returns the class name
  41654. */
  41655. getClassName(): string;
  41656. /** @hidden */
  41657. _onLostFocus(e: FocusEvent): void;
  41658. /**
  41659. * Get the friendly name associated with the input class.
  41660. * @returns the input friendly name
  41661. */
  41662. getSimpleName(): string;
  41663. /**
  41664. * Update the current camera state depending on the inputs that have been used this frame.
  41665. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41666. */
  41667. checkInputs(): void;
  41668. }
  41669. }
  41670. declare module BABYLON {
  41671. /**
  41672. * Listen to mouse events to control the camera.
  41673. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41674. */
  41675. class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41676. /**
  41677. * Defines the camera the input is attached to.
  41678. */
  41679. camera: FlyCamera;
  41680. /**
  41681. * Defines if touch is enabled. (Default is true.)
  41682. */
  41683. touchEnabled: boolean;
  41684. /**
  41685. * Defines the buttons associated with the input to handle camera rotation.
  41686. */
  41687. buttons: number[];
  41688. /**
  41689. * Assign buttons for Yaw control.
  41690. */
  41691. buttonsYaw: number[];
  41692. /**
  41693. * Assign buttons for Pitch control.
  41694. */
  41695. buttonsPitch: number[];
  41696. /**
  41697. * Assign buttons for Roll control.
  41698. */
  41699. buttonsRoll: number[];
  41700. /**
  41701. * Detect if any button is being pressed while mouse is moved.
  41702. * -1 = Mouse locked.
  41703. * 0 = Left button.
  41704. * 1 = Middle Button.
  41705. * 2 = Right Button.
  41706. */
  41707. activeButton: number;
  41708. /**
  41709. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41710. * Higher values reduce its sensitivity.
  41711. */
  41712. angularSensibility: number;
  41713. private _mousemoveCallback;
  41714. private _observer;
  41715. private _rollObserver;
  41716. private previousPosition;
  41717. private noPreventDefault;
  41718. private element;
  41719. /**
  41720. * Listen to mouse events to control the camera.
  41721. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41722. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41723. */
  41724. constructor(touchEnabled?: boolean);
  41725. /**
  41726. * Attach the mouse control to the HTML DOM element.
  41727. * @param element Defines the element that listens to the input events.
  41728. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41729. */
  41730. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41731. /**
  41732. * Detach the current controls from the specified dom element.
  41733. * @param element Defines the element to stop listening the inputs from
  41734. */
  41735. detachControl(element: Nullable<HTMLElement>): void;
  41736. /**
  41737. * Gets the class name of the current input.
  41738. * @returns the class name.
  41739. */
  41740. getClassName(): string;
  41741. /**
  41742. * Get the friendly name associated with the input class.
  41743. * @returns the input's friendly name.
  41744. */
  41745. getSimpleName(): string;
  41746. private _pointerInput;
  41747. private _onMouseMove;
  41748. /**
  41749. * Rotate camera by mouse offset.
  41750. */
  41751. private rotateCamera;
  41752. }
  41753. }
  41754. declare module BABYLON {
  41755. /**
  41756. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41757. * Screen rotation is taken into account.
  41758. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41759. */
  41760. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41761. private _camera;
  41762. private _screenOrientationAngle;
  41763. private _constantTranform;
  41764. private _screenQuaternion;
  41765. private _alpha;
  41766. private _beta;
  41767. private _gamma;
  41768. /**
  41769. * Instantiates a new input
  41770. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41771. */
  41772. constructor();
  41773. /**
  41774. * Define the camera controlled by the input.
  41775. */
  41776. camera: FreeCamera;
  41777. /**
  41778. * Attach the input controls to a specific dom element to get the input from.
  41779. * @param element Defines the element the controls should be listened from
  41780. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41781. */
  41782. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41783. private _orientationChanged;
  41784. private _deviceOrientation;
  41785. /**
  41786. * Detach the current controls from the specified dom element.
  41787. * @param element Defines the element to stop listening the inputs from
  41788. */
  41789. detachControl(element: Nullable<HTMLElement>): void;
  41790. /**
  41791. * Update the current camera state depending on the inputs that have been used this frame.
  41792. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41793. */
  41794. checkInputs(): void;
  41795. /**
  41796. * Gets the class name of the current intput.
  41797. * @returns the class name
  41798. */
  41799. getClassName(): string;
  41800. /**
  41801. * Get the friendly name associated with the input class.
  41802. * @returns the input friendly name
  41803. */
  41804. getSimpleName(): string;
  41805. }
  41806. }
  41807. declare module BABYLON {
  41808. /**
  41809. * Manage the gamepad inputs to control a free camera.
  41810. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41811. */
  41812. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41813. /**
  41814. * Define the camera the input is attached to.
  41815. */
  41816. camera: FreeCamera;
  41817. /**
  41818. * Define the Gamepad controlling the input
  41819. */
  41820. gamepad: Nullable<Gamepad>;
  41821. /**
  41822. * Defines the gamepad rotation sensiblity.
  41823. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41824. */
  41825. gamepadAngularSensibility: number;
  41826. /**
  41827. * Defines the gamepad move sensiblity.
  41828. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41829. */
  41830. gamepadMoveSensibility: number;
  41831. private _onGamepadConnectedObserver;
  41832. private _onGamepadDisconnectedObserver;
  41833. private _cameraTransform;
  41834. private _deltaTransform;
  41835. private _vector3;
  41836. private _vector2;
  41837. /**
  41838. * Attach the input controls to a specific dom element to get the input from.
  41839. * @param element Defines the element the controls should be listened from
  41840. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41841. */
  41842. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41843. /**
  41844. * Detach the current controls from the specified dom element.
  41845. * @param element Defines the element to stop listening the inputs from
  41846. */
  41847. detachControl(element: Nullable<HTMLElement>): void;
  41848. /**
  41849. * Update the current camera state depending on the inputs that have been used this frame.
  41850. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41851. */
  41852. checkInputs(): void;
  41853. /**
  41854. * Gets the class name of the current intput.
  41855. * @returns the class name
  41856. */
  41857. getClassName(): string;
  41858. /**
  41859. * Get the friendly name associated with the input class.
  41860. * @returns the input friendly name
  41861. */
  41862. getSimpleName(): string;
  41863. }
  41864. }
  41865. declare module BABYLON {
  41866. /**
  41867. * Manage the keyboard inputs to control the movement of a free camera.
  41868. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41869. */
  41870. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  41871. /**
  41872. * Defines the camera the input is attached to.
  41873. */
  41874. camera: FreeCamera;
  41875. /**
  41876. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  41877. */
  41878. keysUp: number[];
  41879. /**
  41880. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  41881. */
  41882. keysDown: number[];
  41883. /**
  41884. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  41885. */
  41886. keysLeft: number[];
  41887. /**
  41888. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  41889. */
  41890. keysRight: number[];
  41891. private _keys;
  41892. private _onCanvasBlurObserver;
  41893. private _onKeyboardObserver;
  41894. private _engine;
  41895. private _scene;
  41896. /**
  41897. * Attach the input controls to a specific dom element to get the input from.
  41898. * @param element Defines the element the controls should be listened from
  41899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41900. */
  41901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41902. /**
  41903. * Detach the current controls from the specified dom element.
  41904. * @param element Defines the element to stop listening the inputs from
  41905. */
  41906. detachControl(element: Nullable<HTMLElement>): void;
  41907. /**
  41908. * Update the current camera state depending on the inputs that have been used this frame.
  41909. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41910. */
  41911. checkInputs(): void;
  41912. /**
  41913. * Gets the class name of the current intput.
  41914. * @returns the class name
  41915. */
  41916. getClassName(): string;
  41917. /** @hidden */
  41918. _onLostFocus(e: FocusEvent): void;
  41919. /**
  41920. * Get the friendly name associated with the input class.
  41921. * @returns the input friendly name
  41922. */
  41923. getSimpleName(): string;
  41924. }
  41925. }
  41926. declare module BABYLON {
  41927. /**
  41928. * Manage the mouse inputs to control the movement of a free camera.
  41929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41930. */
  41931. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  41932. /**
  41933. * Define if touch is enabled in the mouse input
  41934. */
  41935. touchEnabled: boolean;
  41936. /**
  41937. * Defines the camera the input is attached to.
  41938. */
  41939. camera: FreeCamera;
  41940. /**
  41941. * Defines the buttons associated with the input to handle camera move.
  41942. */
  41943. buttons: number[];
  41944. /**
  41945. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  41946. */
  41947. angularSensibility: number;
  41948. private _pointerInput;
  41949. private _onMouseMove;
  41950. private _observer;
  41951. private previousPosition;
  41952. /**
  41953. * Manage the mouse inputs to control the movement of a free camera.
  41954. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41955. * @param touchEnabled Defines if touch is enabled or not
  41956. */
  41957. constructor(
  41958. /**
  41959. * Define if touch is enabled in the mouse input
  41960. */
  41961. touchEnabled?: boolean);
  41962. /**
  41963. * Attach the input controls to a specific dom element to get the input from.
  41964. * @param element Defines the element the controls should be listened from
  41965. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41966. */
  41967. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41968. /**
  41969. * Detach the current controls from the specified dom element.
  41970. * @param element Defines the element to stop listening the inputs from
  41971. */
  41972. detachControl(element: Nullable<HTMLElement>): void;
  41973. /**
  41974. * Gets the class name of the current intput.
  41975. * @returns the class name
  41976. */
  41977. getClassName(): string;
  41978. /**
  41979. * Get the friendly name associated with the input class.
  41980. * @returns the input friendly name
  41981. */
  41982. getSimpleName(): string;
  41983. }
  41984. }
  41985. declare module BABYLON {
  41986. /**
  41987. * Manage the touch inputs to control the movement of a free camera.
  41988. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41989. */
  41990. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  41991. /**
  41992. * Defines the camera the input is attached to.
  41993. */
  41994. camera: FreeCamera;
  41995. /**
  41996. * Defines the touch sensibility for rotation.
  41997. * The higher the faster.
  41998. */
  41999. touchAngularSensibility: number;
  42000. /**
  42001. * Defines the touch sensibility for move.
  42002. * The higher the faster.
  42003. */
  42004. touchMoveSensibility: number;
  42005. private _offsetX;
  42006. private _offsetY;
  42007. private _pointerPressed;
  42008. private _pointerInput;
  42009. private _observer;
  42010. private _onLostFocus;
  42011. /**
  42012. * Attach the input controls to a specific dom element to get the input from.
  42013. * @param element Defines the element the controls should be listened from
  42014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42015. */
  42016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42017. /**
  42018. * Detach the current controls from the specified dom element.
  42019. * @param element Defines the element to stop listening the inputs from
  42020. */
  42021. detachControl(element: Nullable<HTMLElement>): void;
  42022. /**
  42023. * Update the current camera state depending on the inputs that have been used this frame.
  42024. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42025. */
  42026. checkInputs(): void;
  42027. /**
  42028. * Gets the class name of the current intput.
  42029. * @returns the class name
  42030. */
  42031. getClassName(): string;
  42032. /**
  42033. * Get the friendly name associated with the input class.
  42034. * @returns the input friendly name
  42035. */
  42036. getSimpleName(): string;
  42037. }
  42038. }
  42039. declare module BABYLON {
  42040. /**
  42041. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42042. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42043. */
  42044. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42045. /**
  42046. * Defines the camera the input is attached to.
  42047. */
  42048. camera: FreeCamera;
  42049. private _leftjoystick;
  42050. private _rightjoystick;
  42051. /**
  42052. * Gets the left stick of the virtual joystick.
  42053. * @returns The virtual Joystick
  42054. */
  42055. getLeftJoystick(): VirtualJoystick;
  42056. /**
  42057. * Gets the right stick of the virtual joystick.
  42058. * @returns The virtual Joystick
  42059. */
  42060. getRightJoystick(): VirtualJoystick;
  42061. /**
  42062. * Update the current camera state depending on the inputs that have been used this frame.
  42063. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42064. */
  42065. checkInputs(): void;
  42066. /**
  42067. * Attach the input controls to a specific dom element to get the input from.
  42068. * @param element Defines the element the controls should be listened from
  42069. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42070. */
  42071. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42072. /**
  42073. * Detach the current controls from the specified dom element.
  42074. * @param element Defines the element to stop listening the inputs from
  42075. */
  42076. detachControl(element: Nullable<HTMLElement>): void;
  42077. /**
  42078. * Gets the class name of the current intput.
  42079. * @returns the class name
  42080. */
  42081. getClassName(): string;
  42082. /**
  42083. * Get the friendly name associated with the input class.
  42084. * @returns the input friendly name
  42085. */
  42086. getSimpleName(): string;
  42087. }
  42088. }
  42089. declare module BABYLON {
  42090. /**
  42091. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42092. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42093. */
  42094. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42095. /**
  42096. * Creates a new AnaglyphArcRotateCamera
  42097. * @param name defines camera name
  42098. * @param alpha defines alpha angle (in radians)
  42099. * @param beta defines beta angle (in radians)
  42100. * @param radius defines radius
  42101. * @param target defines camera target
  42102. * @param interaxialDistance defines distance between each color axis
  42103. * @param scene defines the hosting scene
  42104. */
  42105. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42106. /**
  42107. * Gets camera class name
  42108. * @returns AnaglyphArcRotateCamera
  42109. */
  42110. getClassName(): string;
  42111. }
  42112. }
  42113. declare module BABYLON {
  42114. /**
  42115. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42116. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42117. */
  42118. class AnaglyphFreeCamera extends FreeCamera {
  42119. /**
  42120. * Creates a new AnaglyphFreeCamera
  42121. * @param name defines camera name
  42122. * @param position defines initial position
  42123. * @param interaxialDistance defines distance between each color axis
  42124. * @param scene defines the hosting scene
  42125. */
  42126. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42127. /**
  42128. * Gets camera class name
  42129. * @returns AnaglyphFreeCamera
  42130. */
  42131. getClassName(): string;
  42132. }
  42133. }
  42134. declare module BABYLON {
  42135. /**
  42136. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42137. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42138. */
  42139. class AnaglyphGamepadCamera extends GamepadCamera {
  42140. /**
  42141. * Creates a new AnaglyphGamepadCamera
  42142. * @param name defines camera name
  42143. * @param position defines initial position
  42144. * @param interaxialDistance defines distance between each color axis
  42145. * @param scene defines the hosting scene
  42146. */
  42147. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42148. /**
  42149. * Gets camera class name
  42150. * @returns AnaglyphGamepadCamera
  42151. */
  42152. getClassName(): string;
  42153. }
  42154. }
  42155. declare module BABYLON {
  42156. /**
  42157. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42158. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42159. */
  42160. class AnaglyphUniversalCamera extends UniversalCamera {
  42161. /**
  42162. * Creates a new AnaglyphUniversalCamera
  42163. * @param name defines camera name
  42164. * @param position defines initial position
  42165. * @param interaxialDistance defines distance between each color axis
  42166. * @param scene defines the hosting scene
  42167. */
  42168. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42169. /**
  42170. * Gets camera class name
  42171. * @returns AnaglyphUniversalCamera
  42172. */
  42173. getClassName(): string;
  42174. }
  42175. }
  42176. declare module BABYLON {
  42177. /**
  42178. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42179. * @see http://doc.babylonjs.com/features/cameras
  42180. */
  42181. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42182. /**
  42183. * Creates a new StereoscopicArcRotateCamera
  42184. * @param name defines camera name
  42185. * @param alpha defines alpha angle (in radians)
  42186. * @param beta defines beta angle (in radians)
  42187. * @param radius defines radius
  42188. * @param target defines camera target
  42189. * @param interaxialDistance defines distance between each color axis
  42190. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42191. * @param scene defines the hosting scene
  42192. */
  42193. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42194. /**
  42195. * Gets camera class name
  42196. * @returns StereoscopicArcRotateCamera
  42197. */
  42198. getClassName(): string;
  42199. }
  42200. }
  42201. declare module BABYLON {
  42202. /**
  42203. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42204. * @see http://doc.babylonjs.com/features/cameras
  42205. */
  42206. class StereoscopicFreeCamera extends FreeCamera {
  42207. /**
  42208. * Creates a new StereoscopicFreeCamera
  42209. * @param name defines camera name
  42210. * @param position defines initial position
  42211. * @param interaxialDistance defines distance between each color axis
  42212. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42213. * @param scene defines the hosting scene
  42214. */
  42215. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42216. /**
  42217. * Gets camera class name
  42218. * @returns StereoscopicFreeCamera
  42219. */
  42220. getClassName(): string;
  42221. }
  42222. }
  42223. declare module BABYLON {
  42224. /**
  42225. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42226. * @see http://doc.babylonjs.com/features/cameras
  42227. */
  42228. class StereoscopicGamepadCamera extends GamepadCamera {
  42229. /**
  42230. * Creates a new StereoscopicGamepadCamera
  42231. * @param name defines camera name
  42232. * @param position defines initial position
  42233. * @param interaxialDistance defines distance between each color axis
  42234. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42235. * @param scene defines the hosting scene
  42236. */
  42237. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42238. /**
  42239. * Gets camera class name
  42240. * @returns StereoscopicGamepadCamera
  42241. */
  42242. getClassName(): string;
  42243. }
  42244. }
  42245. declare module BABYLON {
  42246. /**
  42247. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42248. * @see http://doc.babylonjs.com/features/cameras
  42249. */
  42250. class StereoscopicUniversalCamera extends UniversalCamera {
  42251. /**
  42252. * Creates a new StereoscopicUniversalCamera
  42253. * @param name defines camera name
  42254. * @param position defines initial position
  42255. * @param interaxialDistance defines distance between each color axis
  42256. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42257. * @param scene defines the hosting scene
  42258. */
  42259. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42260. /**
  42261. * Gets camera class name
  42262. * @returns StereoscopicUniversalCamera
  42263. */
  42264. getClassName(): string;
  42265. }
  42266. }
  42267. declare module BABYLON {
  42268. /**
  42269. * This represents all the required metrics to create a VR camera.
  42270. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42271. */
  42272. class VRCameraMetrics {
  42273. /**
  42274. * Define the horizontal resolution off the screen.
  42275. */
  42276. hResolution: number;
  42277. /**
  42278. * Define the vertical resolution off the screen.
  42279. */
  42280. vResolution: number;
  42281. /**
  42282. * Define the horizontal screen size.
  42283. */
  42284. hScreenSize: number;
  42285. /**
  42286. * Define the vertical screen size.
  42287. */
  42288. vScreenSize: number;
  42289. /**
  42290. * Define the vertical screen center position.
  42291. */
  42292. vScreenCenter: number;
  42293. /**
  42294. * Define the distance of the eyes to the screen.
  42295. */
  42296. eyeToScreenDistance: number;
  42297. /**
  42298. * Define the distance between both lenses
  42299. */
  42300. lensSeparationDistance: number;
  42301. /**
  42302. * Define the distance between both viewer's eyes.
  42303. */
  42304. interpupillaryDistance: number;
  42305. /**
  42306. * Define the distortion factor of the VR postprocess.
  42307. * Please, touch with care.
  42308. */
  42309. distortionK: number[];
  42310. /**
  42311. * Define the chromatic aberration correction factors for the VR post process.
  42312. */
  42313. chromaAbCorrection: number[];
  42314. /**
  42315. * Define the scale factor of the post process.
  42316. * The smaller the better but the slower.
  42317. */
  42318. postProcessScaleFactor: number;
  42319. /**
  42320. * Define an offset for the lens center.
  42321. */
  42322. lensCenterOffset: number;
  42323. /**
  42324. * Define if the current vr camera should compensate the distortion of the lense or not.
  42325. */
  42326. compensateDistortion: boolean;
  42327. /**
  42328. * Gets the rendering aspect ratio based on the provided resolutions.
  42329. */
  42330. readonly aspectRatio: number;
  42331. /**
  42332. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42333. */
  42334. readonly aspectRatioFov: number;
  42335. /**
  42336. * @hidden
  42337. */
  42338. readonly leftHMatrix: Matrix;
  42339. /**
  42340. * @hidden
  42341. */
  42342. readonly rightHMatrix: Matrix;
  42343. /**
  42344. * @hidden
  42345. */
  42346. readonly leftPreViewMatrix: Matrix;
  42347. /**
  42348. * @hidden
  42349. */
  42350. readonly rightPreViewMatrix: Matrix;
  42351. /**
  42352. * Get the default VRMetrics based on the most generic setup.
  42353. * @returns the default vr metrics
  42354. */
  42355. static GetDefault(): VRCameraMetrics;
  42356. }
  42357. }
  42358. declare module BABYLON {
  42359. /**
  42360. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42361. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42362. */
  42363. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42364. /**
  42365. * Creates a new VRDeviceOrientationArcRotateCamera
  42366. * @param name defines camera name
  42367. * @param alpha defines the camera rotation along the logitudinal axis
  42368. * @param beta defines the camera rotation along the latitudinal axis
  42369. * @param radius defines the camera distance from its target
  42370. * @param target defines the camera target
  42371. * @param scene defines the scene the camera belongs to
  42372. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42373. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42374. */
  42375. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42376. /**
  42377. * Gets camera class name
  42378. * @returns VRDeviceOrientationArcRotateCamera
  42379. */
  42380. getClassName(): string;
  42381. }
  42382. }
  42383. declare module BABYLON {
  42384. /**
  42385. * Camera used to simulate VR rendering (based on FreeCamera)
  42386. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42387. */
  42388. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42389. /**
  42390. * Creates a new VRDeviceOrientationFreeCamera
  42391. * @param name defines camera name
  42392. * @param position defines the start position of the camera
  42393. * @param scene defines the scene the camera belongs to
  42394. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42395. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42396. */
  42397. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42398. /**
  42399. * Gets camera class name
  42400. * @returns VRDeviceOrientationFreeCamera
  42401. */
  42402. getClassName(): string;
  42403. }
  42404. }
  42405. declare module BABYLON {
  42406. /**
  42407. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42408. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42409. */
  42410. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42411. /**
  42412. * Creates a new VRDeviceOrientationGamepadCamera
  42413. * @param name defines camera name
  42414. * @param position defines the start position of the camera
  42415. * @param scene defines the scene the camera belongs to
  42416. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42417. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42418. */
  42419. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42420. /**
  42421. * Gets camera class name
  42422. * @returns VRDeviceOrientationGamepadCamera
  42423. */
  42424. getClassName(): string;
  42425. }
  42426. }
  42427. declare module BABYLON {
  42428. /**
  42429. * Options to modify the vr teleportation behavior.
  42430. */
  42431. interface VRTeleportationOptions {
  42432. /**
  42433. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42434. */
  42435. floorMeshName?: string;
  42436. /**
  42437. * A list of meshes to be used as the teleportation floor. (default: empty)
  42438. */
  42439. floorMeshes?: Mesh[];
  42440. }
  42441. /**
  42442. * Options to modify the vr experience helper's behavior.
  42443. */
  42444. interface VRExperienceHelperOptions extends WebVROptions {
  42445. /**
  42446. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42447. */
  42448. createDeviceOrientationCamera?: boolean;
  42449. /**
  42450. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42451. */
  42452. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42453. /**
  42454. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42455. */
  42456. laserToggle?: boolean;
  42457. /**
  42458. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42459. */
  42460. floorMeshes?: Mesh[];
  42461. }
  42462. /**
  42463. * Helps to quickly add VR support to an existing scene.
  42464. * See http://doc.babylonjs.com/how_to/webvr_helper
  42465. */
  42466. class VRExperienceHelper {
  42467. /** Options to modify the vr experience helper's behavior. */
  42468. webVROptions: VRExperienceHelperOptions;
  42469. private _scene;
  42470. private _position;
  42471. private _btnVR;
  42472. private _btnVRDisplayed;
  42473. private _webVRsupported;
  42474. private _webVRready;
  42475. private _webVRrequesting;
  42476. private _webVRpresenting;
  42477. private _hasEnteredVR;
  42478. private _fullscreenVRpresenting;
  42479. private _canvas;
  42480. private _webVRCamera;
  42481. private _vrDeviceOrientationCamera;
  42482. private _deviceOrientationCamera;
  42483. private _existingCamera;
  42484. private _onKeyDown;
  42485. private _onVrDisplayPresentChange;
  42486. private _onVRDisplayChanged;
  42487. private _onVRRequestPresentStart;
  42488. private _onVRRequestPresentComplete;
  42489. /**
  42490. * Observable raised when entering VR.
  42491. */
  42492. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42493. /**
  42494. * Observable raised when exiting VR.
  42495. */
  42496. onExitingVRObservable: Observable<VRExperienceHelper>;
  42497. /**
  42498. * Observable raised when controller mesh is loaded.
  42499. */
  42500. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42501. /** Return this.onEnteringVRObservable
  42502. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42503. */
  42504. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42505. /** Return this.onExitingVRObservable
  42506. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42507. */
  42508. readonly onExitingVR: Observable<VRExperienceHelper>;
  42509. /** Return this.onControllerMeshLoadedObservable
  42510. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42511. */
  42512. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42513. private _rayLength;
  42514. private _useCustomVRButton;
  42515. private _teleportationRequested;
  42516. private _teleportActive;
  42517. private _floorMeshName;
  42518. private _floorMeshesCollection;
  42519. private _rotationAllowed;
  42520. private _teleportBackwardsVector;
  42521. private _teleportationTarget;
  42522. private _isDefaultTeleportationTarget;
  42523. private _postProcessMove;
  42524. private _teleportationFillColor;
  42525. private _teleportationBorderColor;
  42526. private _rotationAngle;
  42527. private _haloCenter;
  42528. private _cameraGazer;
  42529. private _padSensibilityUp;
  42530. private _padSensibilityDown;
  42531. private _leftController;
  42532. private _rightController;
  42533. /**
  42534. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42535. */
  42536. onNewMeshSelected: Observable<AbstractMesh>;
  42537. /**
  42538. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42539. */
  42540. onNewMeshPicked: Observable<PickingInfo>;
  42541. private _circleEase;
  42542. /**
  42543. * Observable raised before camera teleportation
  42544. */
  42545. onBeforeCameraTeleport: Observable<Vector3>;
  42546. /**
  42547. * Observable raised after camera teleportation
  42548. */
  42549. onAfterCameraTeleport: Observable<Vector3>;
  42550. /**
  42551. * Observable raised when current selected mesh gets unselected
  42552. */
  42553. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42554. private _raySelectionPredicate;
  42555. /**
  42556. * To be optionaly changed by user to define custom ray selection
  42557. */
  42558. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42559. /**
  42560. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42561. */
  42562. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42563. /**
  42564. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42565. */
  42566. teleportationEnabled: boolean;
  42567. private _defaultHeight;
  42568. private _teleportationInitialized;
  42569. private _interactionsEnabled;
  42570. private _interactionsRequested;
  42571. private _displayGaze;
  42572. private _displayLaserPointer;
  42573. /**
  42574. * The mesh used to display where the user is going to teleport.
  42575. */
  42576. /**
  42577. * Sets the mesh to be used to display where the user is going to teleport.
  42578. */
  42579. teleportationTarget: Mesh;
  42580. /**
  42581. * 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
  42582. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42583. * See http://doc.babylonjs.com/resources/baking_transformations
  42584. */
  42585. gazeTrackerMesh: Mesh;
  42586. /**
  42587. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42588. */
  42589. updateGazeTrackerScale: boolean;
  42590. /**
  42591. * The gaze tracking mesh corresponding to the left controller
  42592. */
  42593. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42594. /**
  42595. * The gaze tracking mesh corresponding to the right controller
  42596. */
  42597. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42598. /**
  42599. * If the ray of the gaze should be displayed.
  42600. */
  42601. /**
  42602. * Sets if the ray of the gaze should be displayed.
  42603. */
  42604. displayGaze: boolean;
  42605. /**
  42606. * If the ray of the LaserPointer should be displayed.
  42607. */
  42608. /**
  42609. * Sets if the ray of the LaserPointer should be displayed.
  42610. */
  42611. displayLaserPointer: boolean;
  42612. /**
  42613. * The deviceOrientationCamera used as the camera when not in VR.
  42614. */
  42615. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42616. /**
  42617. * Based on the current WebVR support, returns the current VR camera used.
  42618. */
  42619. readonly currentVRCamera: Nullable<Camera>;
  42620. /**
  42621. * The webVRCamera which is used when in VR.
  42622. */
  42623. readonly webVRCamera: WebVRFreeCamera;
  42624. /**
  42625. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42626. */
  42627. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42628. private readonly _teleportationRequestInitiated;
  42629. /**
  42630. * Instantiates a VRExperienceHelper.
  42631. * Helps to quickly add VR support to an existing scene.
  42632. * @param scene The scene the VRExperienceHelper belongs to.
  42633. * @param webVROptions Options to modify the vr experience helper's behavior.
  42634. */
  42635. constructor(scene: Scene,
  42636. /** Options to modify the vr experience helper's behavior. */
  42637. webVROptions?: VRExperienceHelperOptions);
  42638. private _onDefaultMeshLoaded;
  42639. private _onResize;
  42640. private _onFullscreenChange;
  42641. /**
  42642. * Gets a value indicating if we are currently in VR mode.
  42643. */
  42644. readonly isInVRMode: boolean;
  42645. private onVrDisplayPresentChange;
  42646. private onVRDisplayChanged;
  42647. private moveButtonToBottomRight;
  42648. private displayVRButton;
  42649. private updateButtonVisibility;
  42650. private _cachedAngularSensibility;
  42651. /**
  42652. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42653. * Otherwise, will use the fullscreen API.
  42654. */
  42655. enterVR(): void;
  42656. /**
  42657. * Attempt to exit VR, or fullscreen.
  42658. */
  42659. exitVR(): void;
  42660. /**
  42661. * The position of the vr experience helper.
  42662. */
  42663. /**
  42664. * Sets the position of the vr experience helper.
  42665. */
  42666. position: Vector3;
  42667. /**
  42668. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42669. */
  42670. enableInteractions(): void;
  42671. private readonly _noControllerIsActive;
  42672. private beforeRender;
  42673. private _isTeleportationFloor;
  42674. /**
  42675. * Adds a floor mesh to be used for teleportation.
  42676. * @param floorMesh the mesh to be used for teleportation.
  42677. */
  42678. addFloorMesh(floorMesh: Mesh): void;
  42679. /**
  42680. * Removes a floor mesh from being used for teleportation.
  42681. * @param floorMesh the mesh to be removed.
  42682. */
  42683. removeFloorMesh(floorMesh: Mesh): void;
  42684. /**
  42685. * Enables interactions and teleportation using the VR controllers and gaze.
  42686. * @param vrTeleportationOptions options to modify teleportation behavior.
  42687. */
  42688. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42689. private _onNewGamepadConnected;
  42690. private _tryEnableInteractionOnController;
  42691. private _onNewGamepadDisconnected;
  42692. private _enableInteractionOnController;
  42693. private _checkTeleportWithRay;
  42694. private _checkRotate;
  42695. private _checkTeleportBackwards;
  42696. private _enableTeleportationOnController;
  42697. private _createTeleportationCircles;
  42698. private _displayTeleportationTarget;
  42699. private _hideTeleportationTarget;
  42700. private _rotateCamera;
  42701. private _moveTeleportationSelectorTo;
  42702. private _workingVector;
  42703. private _workingQuaternion;
  42704. private _workingMatrix;
  42705. /**
  42706. * Teleports the users feet to the desired location
  42707. * @param location The location where the user's feet should be placed
  42708. */
  42709. teleportCamera(location: Vector3): void;
  42710. private _convertNormalToDirectionOfRay;
  42711. private _castRayAndSelectObject;
  42712. private _notifySelectedMeshUnselected;
  42713. /**
  42714. * Sets the color of the laser ray from the vr controllers.
  42715. * @param color new color for the ray.
  42716. */
  42717. changeLaserColor(color: Color3): void;
  42718. /**
  42719. * Sets the color of the ray from the vr headsets gaze.
  42720. * @param color new color for the ray.
  42721. */
  42722. changeGazeColor(color: Color3): void;
  42723. /**
  42724. * Exits VR and disposes of the vr experience helper
  42725. */
  42726. dispose(): void;
  42727. /**
  42728. * Gets the name of the VRExperienceHelper class
  42729. * @returns "VRExperienceHelper"
  42730. */
  42731. getClassName(): string;
  42732. }
  42733. }
  42734. declare module BABYLON {
  42735. /**
  42736. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  42737. * IMPORTANT!! The data is right-hand data.
  42738. * @export
  42739. * @interface DevicePose
  42740. */
  42741. interface DevicePose {
  42742. /**
  42743. * The position of the device, values in array are [x,y,z].
  42744. */
  42745. readonly position: Nullable<Float32Array>;
  42746. /**
  42747. * The linearVelocity of the device, values in array are [x,y,z].
  42748. */
  42749. readonly linearVelocity: Nullable<Float32Array>;
  42750. /**
  42751. * The linearAcceleration of the device, values in array are [x,y,z].
  42752. */
  42753. readonly linearAcceleration: Nullable<Float32Array>;
  42754. /**
  42755. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  42756. */
  42757. readonly orientation: Nullable<Float32Array>;
  42758. /**
  42759. * The angularVelocity of the device, values in array are [x,y,z].
  42760. */
  42761. readonly angularVelocity: Nullable<Float32Array>;
  42762. /**
  42763. * The angularAcceleration of the device, values in array are [x,y,z].
  42764. */
  42765. readonly angularAcceleration: Nullable<Float32Array>;
  42766. }
  42767. /**
  42768. * Interface representing a pose controlled object in Babylon.
  42769. * A pose controlled object has both regular pose values as well as pose values
  42770. * from an external device such as a VR head mounted display
  42771. */
  42772. interface PoseControlled {
  42773. /**
  42774. * The position of the object in babylon space.
  42775. */
  42776. position: Vector3;
  42777. /**
  42778. * The rotation quaternion of the object in babylon space.
  42779. */
  42780. rotationQuaternion: Quaternion;
  42781. /**
  42782. * The position of the device in babylon space.
  42783. */
  42784. devicePosition?: Vector3;
  42785. /**
  42786. * The rotation quaternion of the device in babylon space.
  42787. */
  42788. deviceRotationQuaternion: Quaternion;
  42789. /**
  42790. * The raw pose coming from the device.
  42791. */
  42792. rawPose: Nullable<DevicePose>;
  42793. /**
  42794. * The scale of the device to be used when translating from device space to babylon space.
  42795. */
  42796. deviceScaleFactor: number;
  42797. /**
  42798. * Updates the poseControlled values based on the input device pose.
  42799. * @param poseData the pose data to update the object with
  42800. */
  42801. updateFromDevice(poseData: DevicePose): void;
  42802. }
  42803. /**
  42804. * Set of options to customize the webVRCamera
  42805. */
  42806. interface WebVROptions {
  42807. /**
  42808. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  42809. */
  42810. trackPosition?: boolean;
  42811. /**
  42812. * Sets the scale of the vrDevice in babylon space. (default: 1)
  42813. */
  42814. positionScale?: number;
  42815. /**
  42816. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  42817. */
  42818. displayName?: string;
  42819. /**
  42820. * Should the native controller meshes be initialized. (default: true)
  42821. */
  42822. controllerMeshes?: boolean;
  42823. /**
  42824. * Creating a default HemiLight only on controllers. (default: true)
  42825. */
  42826. defaultLightingOnControllers?: boolean;
  42827. /**
  42828. * If you don't want to use the default VR button of the helper. (default: false)
  42829. */
  42830. useCustomVRButton?: boolean;
  42831. /**
  42832. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  42833. */
  42834. customVRButton?: HTMLButtonElement;
  42835. /**
  42836. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  42837. */
  42838. rayLength?: number;
  42839. /**
  42840. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  42841. */
  42842. defaultHeight?: number;
  42843. }
  42844. /**
  42845. * This represents a WebVR camera.
  42846. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  42847. * @example http://doc.babylonjs.com/how_to/webvr_camera
  42848. */
  42849. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  42850. private webVROptions;
  42851. /**
  42852. * @hidden
  42853. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  42854. */
  42855. _vrDevice: any;
  42856. /**
  42857. * The rawPose of the vrDevice.
  42858. */
  42859. rawPose: Nullable<DevicePose>;
  42860. private _onVREnabled;
  42861. private _specsVersion;
  42862. private _attached;
  42863. private _frameData;
  42864. protected _descendants: Array<Node>;
  42865. private _deviceRoomPosition;
  42866. /** @hidden */
  42867. _deviceRoomRotationQuaternion: Quaternion;
  42868. private _standingMatrix;
  42869. /**
  42870. * Represents device position in babylon space.
  42871. */
  42872. devicePosition: Vector3;
  42873. /**
  42874. * Represents device rotation in babylon space.
  42875. */
  42876. deviceRotationQuaternion: Quaternion;
  42877. /**
  42878. * The scale of the device to be used when translating from device space to babylon space.
  42879. */
  42880. deviceScaleFactor: number;
  42881. private _deviceToWorld;
  42882. private _worldToDevice;
  42883. /**
  42884. * References to the webVR controllers for the vrDevice.
  42885. */
  42886. controllers: Array<WebVRController>;
  42887. /**
  42888. * Emits an event when a controller is attached.
  42889. */
  42890. onControllersAttachedObservable: Observable<WebVRController[]>;
  42891. /**
  42892. * Emits an event when a controller's mesh has been loaded;
  42893. */
  42894. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42895. /**
  42896. * Emits an event when the HMD's pose has been updated.
  42897. */
  42898. onPoseUpdatedFromDeviceObservable: Observable<any>;
  42899. private _poseSet;
  42900. /**
  42901. * If the rig cameras be used as parent instead of this camera.
  42902. */
  42903. rigParenting: boolean;
  42904. private _lightOnControllers;
  42905. private _defaultHeight?;
  42906. /**
  42907. * Instantiates a WebVRFreeCamera.
  42908. * @param name The name of the WebVRFreeCamera
  42909. * @param position The starting anchor position for the camera
  42910. * @param scene The scene the camera belongs to
  42911. * @param webVROptions a set of customizable options for the webVRCamera
  42912. */
  42913. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  42914. /**
  42915. * Gets the device distance from the ground in meters.
  42916. * @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.
  42917. */
  42918. deviceDistanceToRoomGround(): number;
  42919. /**
  42920. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42921. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  42922. */
  42923. useStandingMatrix(callback?: (bool: boolean) => void): void;
  42924. /**
  42925. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42926. * @returns A promise with a boolean set to if the standing matrix is supported.
  42927. */
  42928. useStandingMatrixAsync(): Promise<boolean>;
  42929. /**
  42930. * Disposes the camera
  42931. */
  42932. dispose(): void;
  42933. /**
  42934. * Gets a vrController by name.
  42935. * @param name The name of the controller to retreive
  42936. * @returns the controller matching the name specified or null if not found
  42937. */
  42938. getControllerByName(name: string): Nullable<WebVRController>;
  42939. private _leftController;
  42940. /**
  42941. * The controller corrisponding to the users left hand.
  42942. */
  42943. readonly leftController: Nullable<WebVRController>;
  42944. private _rightController;
  42945. /**
  42946. * The controller corrisponding to the users right hand.
  42947. */
  42948. readonly rightController: Nullable<WebVRController>;
  42949. /**
  42950. * Casts a ray forward from the vrCamera's gaze.
  42951. * @param length Length of the ray (default: 100)
  42952. * @returns the ray corrisponding to the gaze
  42953. */
  42954. getForwardRay(length?: number): Ray;
  42955. /**
  42956. * @hidden
  42957. * Updates the camera based on device's frame data
  42958. */
  42959. _checkInputs(): void;
  42960. /**
  42961. * Updates the poseControlled values based on the input device pose.
  42962. * @param poseData Pose coming from the device
  42963. */
  42964. updateFromDevice(poseData: DevicePose): void;
  42965. private _htmlElementAttached;
  42966. private _detachIfAttached;
  42967. /**
  42968. * WebVR's attach control will start broadcasting frames to the device.
  42969. * Note that in certain browsers (chrome for example) this function must be called
  42970. * within a user-interaction callback. Example:
  42971. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  42972. *
  42973. * @param element html element to attach the vrDevice to
  42974. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  42975. */
  42976. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42977. /**
  42978. * Detaches the camera from the html element and disables VR
  42979. *
  42980. * @param element html element to detach from
  42981. */
  42982. detachControl(element: HTMLElement): void;
  42983. /**
  42984. * @returns the name of this class
  42985. */
  42986. getClassName(): string;
  42987. /**
  42988. * Calls resetPose on the vrDisplay
  42989. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  42990. */
  42991. resetToCurrentRotation(): void;
  42992. /**
  42993. * @hidden
  42994. * Updates the rig cameras (left and right eye)
  42995. */
  42996. _updateRigCameras(): void;
  42997. private _workingVector;
  42998. private _oneVector;
  42999. private _workingMatrix;
  43000. private updateCacheCalled;
  43001. private _correctPositionIfNotTrackPosition;
  43002. /**
  43003. * @hidden
  43004. * Updates the cached values of the camera
  43005. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  43006. */
  43007. _updateCache(ignoreParentClass?: boolean): void;
  43008. /**
  43009. * @hidden
  43010. * Get current device position in babylon world
  43011. */
  43012. _computeDevicePosition(): void;
  43013. /**
  43014. * Updates the current device position and rotation in the babylon world
  43015. */
  43016. update(): void;
  43017. /**
  43018. * @hidden
  43019. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  43020. * @returns an identity matrix
  43021. */
  43022. _getViewMatrix(): Matrix;
  43023. private _tmpMatrix;
  43024. /**
  43025. * This function is called by the two RIG cameras.
  43026. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  43027. */
  43028. protected _getWebVRViewMatrix(): Matrix;
  43029. protected _getWebVRProjectionMatrix(): Matrix;
  43030. private _onGamepadConnectedObserver;
  43031. private _onGamepadDisconnectedObserver;
  43032. private _updateCacheWhenTrackingDisabledObserver;
  43033. /**
  43034. * Initializes the controllers and their meshes
  43035. */
  43036. initControllers(): void;
  43037. }
  43038. }
  43039. declare module BABYLON {
  43040. /**
  43041. * WebXR Camera which holds the views for the xrSession
  43042. * @see https://doc.babylonjs.com/how_to/webxr
  43043. */
  43044. class WebXRCamera extends FreeCamera {
  43045. private static _TmpMatrix;
  43046. /**
  43047. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43048. * @param name the name of the camera
  43049. * @param scene the scene to add the camera to
  43050. */
  43051. constructor(name: string, scene: BABYLON.Scene);
  43052. private _updateNumberOfRigCameras;
  43053. /** @hidden */
  43054. _updateForDualEyeDebugging(pupilDistance?: number): void;
  43055. /**
  43056. * Updates the cameras position from the current pose information of the XR session
  43057. * @param xrSessionManager the session containing pose information
  43058. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43059. */
  43060. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43061. }
  43062. }
  43063. declare module BABYLON {
  43064. /**
  43065. * Button which can be used to enter a different mode of XR
  43066. */
  43067. class WebXREnterExitUIButton {
  43068. /** button element */
  43069. element: HTMLElement;
  43070. /** XR initialization options for the button */
  43071. initializationOptions: XRSessionCreationOptions;
  43072. /**
  43073. * Creates a WebXREnterExitUIButton
  43074. * @param element button element
  43075. * @param initializationOptions XR initialization options for the button
  43076. */
  43077. constructor(
  43078. /** button element */
  43079. element: HTMLElement,
  43080. /** XR initialization options for the button */
  43081. initializationOptions: XRSessionCreationOptions);
  43082. /**
  43083. * Overwritable function which can be used to update the button's visuals when the state changes
  43084. * @param activeButton the current active button in the UI
  43085. */
  43086. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43087. }
  43088. /**
  43089. * Options to create the webXR UI
  43090. */
  43091. class WebXREnterExitUIOptions {
  43092. /**
  43093. * Context to enter xr with
  43094. */
  43095. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  43096. /**
  43097. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43098. */
  43099. customButtons?: Array<WebXREnterExitUIButton>;
  43100. }
  43101. /**
  43102. * UI to allow the user to enter/exit XR mode
  43103. */
  43104. class WebXREnterExitUI implements IDisposable {
  43105. private scene;
  43106. private _overlay;
  43107. private _buttons;
  43108. private _activeButton;
  43109. /**
  43110. * Fired every time the active button is changed.
  43111. *
  43112. * When xr is entered via a button that launches xr that button will be the callback parameter
  43113. *
  43114. * When exiting xr the callback parameter will be null)
  43115. */
  43116. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43117. /**
  43118. * Creates UI to allow the user to enter/exit XR mode
  43119. * @param scene the scene to add the ui to
  43120. * @param helper the xr experience helper to enter/exit xr with
  43121. * @param options options to configure the UI
  43122. * @returns the created ui
  43123. */
  43124. static CreateAsync(scene: BABYLON.Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43125. private constructor();
  43126. private _updateButtons;
  43127. /**
  43128. * Disposes of the object
  43129. */
  43130. dispose(): void;
  43131. }
  43132. }
  43133. declare module BABYLON {
  43134. /**
  43135. * States of the webXR experience
  43136. */
  43137. enum WebXRState {
  43138. /**
  43139. * Transitioning to being in XR mode
  43140. */
  43141. ENTERING_XR = 0,
  43142. /**
  43143. * Transitioning to non XR mode
  43144. */
  43145. EXITING_XR = 1,
  43146. /**
  43147. * In XR mode and presenting
  43148. */
  43149. IN_XR = 2,
  43150. /**
  43151. * Not entered XR mode
  43152. */
  43153. NOT_IN_XR = 3
  43154. }
  43155. /**
  43156. * Helper class used to enable XR
  43157. * @see https://doc.babylonjs.com/how_to/webxr
  43158. */
  43159. class WebXRExperienceHelper implements IDisposable {
  43160. private scene;
  43161. /**
  43162. * 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
  43163. */
  43164. container: AbstractMesh;
  43165. /**
  43166. * Camera used to render xr content
  43167. */
  43168. camera: WebXRCamera;
  43169. /**
  43170. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43171. */
  43172. state: WebXRState;
  43173. private _setState;
  43174. private static _TmpVector;
  43175. /**
  43176. * Fires when the state of the experience helper has changed
  43177. */
  43178. onStateChangedObservable: Observable<WebXRState>;
  43179. /** @hidden */
  43180. _sessionManager: WebXRSessionManager;
  43181. private _nonVRCamera;
  43182. private _originalSceneAutoClear;
  43183. private _supported;
  43184. /**
  43185. * Creates the experience helper
  43186. * @param scene the scene to attach the experience helper to
  43187. * @returns a promise for the experience helper
  43188. */
  43189. static CreateAsync(scene: BABYLON.Scene): Promise<WebXRExperienceHelper>;
  43190. /**
  43191. * Creates a WebXRExperienceHelper
  43192. * @param scene The scene the helper should be created in
  43193. */
  43194. private constructor();
  43195. /**
  43196. * Exits XR mode and returns the scene to its original state
  43197. * @returns promise that resolves after xr mode has exited
  43198. */
  43199. exitXRAsync(): Promise<void>;
  43200. /**
  43201. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43202. * @param sessionCreationOptions options for the XR session
  43203. * @param frameOfReference frame of reference of the XR session
  43204. * @returns promise that resolves after xr mode has entered
  43205. */
  43206. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  43207. /**
  43208. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43209. * @param ray ray to cast into the environment
  43210. * @returns Promise which resolves with a collision point in the environment if it exists
  43211. */
  43212. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43213. /**
  43214. * Updates the global position of the camera by moving the camera's container
  43215. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43216. * @param position The desired global position of the camera
  43217. */
  43218. setPositionOfCameraUsingContainer(position: Vector3): void;
  43219. /**
  43220. * Rotates the xr camera by rotating the camera's container around the camera's position
  43221. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43222. * @param rotation the desired quaternion rotation to apply to the camera
  43223. */
  43224. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43225. /**
  43226. * Checks if the creation options are supported by the xr session
  43227. * @param options creation options
  43228. * @returns true if supported
  43229. */
  43230. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43231. /**
  43232. * Disposes of the experience helper
  43233. */
  43234. dispose(): void;
  43235. }
  43236. }
  43237. declare module BABYLON {
  43238. /**
  43239. * Represents an XR input
  43240. */
  43241. class WebXRController {
  43242. /**
  43243. * 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
  43244. */
  43245. grip?: BABYLON.AbstractMesh;
  43246. /**
  43247. * Pointer which can be used to select objects or attach a visible laser to
  43248. */
  43249. pointer: BABYLON.AbstractMesh;
  43250. /**
  43251. * Creates the controller
  43252. * @see https://doc.babylonjs.com/how_to/webxr
  43253. * @param scene the scene which the controller should be associated to
  43254. */
  43255. constructor(scene: BABYLON.Scene);
  43256. /**
  43257. * Disposes of the object
  43258. */
  43259. dispose(): void;
  43260. }
  43261. /**
  43262. * XR input used to track XR inputs such as controllers/rays
  43263. */
  43264. class WebXRInput implements IDisposable {
  43265. private helper;
  43266. /**
  43267. * XR controllers being tracked
  43268. */
  43269. controllers: Array<WebXRController>;
  43270. private _tmpMatrix;
  43271. private _frameObserver;
  43272. /**
  43273. * Initializes the WebXRInput
  43274. * @param helper experience helper which the input should be created for
  43275. */
  43276. constructor(helper: WebXRExperienceHelper);
  43277. /**
  43278. * Disposes of the object
  43279. */
  43280. dispose(): void;
  43281. }
  43282. }
  43283. declare module BABYLON {
  43284. /**
  43285. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43286. */
  43287. class WebXRManagedOutputCanvas implements IDisposable {
  43288. private _canvas;
  43289. /**
  43290. * xrpresent context of the canvas which can be used to display/mirror xr content
  43291. */
  43292. canvasContext: Nullable<WebGLRenderingContext>;
  43293. /**
  43294. * Initializes the canvas to be added/removed upon entering/exiting xr
  43295. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  43296. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43297. */
  43298. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  43299. /**
  43300. * Disposes of the object
  43301. */
  43302. dispose(): void;
  43303. private _setManagedOutputCanvas;
  43304. private _addCanvas;
  43305. private _removeCanvas;
  43306. }
  43307. }
  43308. declare module BABYLON {
  43309. /**
  43310. * Manages an XRSession
  43311. * @see https://doc.babylonjs.com/how_to/webxr
  43312. */
  43313. class WebXRSessionManager implements IDisposable {
  43314. private scene;
  43315. /**
  43316. * Fires every time a new xrFrame arrives which can be used to update the camera
  43317. */
  43318. onXRFrameObservable: Observable<any>;
  43319. /**
  43320. * Fires when the xr session is ended either by the device or manually done
  43321. */
  43322. onXRSessionEnded: Observable<any>;
  43323. /** @hidden */
  43324. _xrSession: XRSession;
  43325. /** @hidden */
  43326. _frameOfReference: XRFrameOfReference;
  43327. /** @hidden */
  43328. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  43329. /** @hidden */
  43330. _currentXRFrame: Nullable<XRFrame>;
  43331. private _xrNavigator;
  43332. private _xrDevice;
  43333. private _tmpMatrix;
  43334. /**
  43335. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43336. * @param scene The scene which the session should be created for
  43337. */
  43338. constructor(scene: BABYLON.Scene);
  43339. /**
  43340. * Initializes the manager
  43341. * After initialization enterXR can be called to start an XR session
  43342. * @returns Promise which resolves after it is initialized
  43343. */
  43344. initializeAsync(): Promise<void>;
  43345. /**
  43346. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  43347. * @param sessionCreationOptions xr options to create the session with
  43348. * @param frameOfReferenceType option to configure how the xr pose is expressed
  43349. * @returns Promise which resolves after it enters XR
  43350. */
  43351. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  43352. /**
  43353. * Stops the xrSession and restores the renderloop
  43354. * @returns Promise which resolves after it exits XR
  43355. */
  43356. exitXRAsync(): Promise<void>;
  43357. /**
  43358. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43359. * @param ray ray to cast into the environment
  43360. * @returns Promise which resolves with a collision point in the environment if it exists
  43361. */
  43362. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43363. /**
  43364. * Checks if a session would be supported for the creation options specified
  43365. * @param options creation options to check if they are supported
  43366. * @returns true if supported
  43367. */
  43368. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43369. /**
  43370. * @hidden
  43371. * Converts the render layer of xrSession to a render target
  43372. * @param session session to create render target for
  43373. * @param scene scene the new render target should be created for
  43374. */
  43375. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: BABYLON.Scene): RenderTargetTexture;
  43376. /**
  43377. * Disposes of the session manager
  43378. */
  43379. dispose(): void;
  43380. }
  43381. }
  43382. declare module BABYLON {
  43383. /**
  43384. * Contains an array of blocks representing the octree
  43385. */
  43386. interface IOctreeContainer<T> {
  43387. /**
  43388. * Blocks within the octree
  43389. */
  43390. blocks: Array<OctreeBlock<T>>;
  43391. }
  43392. /**
  43393. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43394. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43395. */
  43396. class Octree<T> {
  43397. /** 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.) */
  43398. maxDepth: number;
  43399. /**
  43400. * Blocks within the octree containing objects
  43401. */
  43402. blocks: Array<OctreeBlock<T>>;
  43403. /**
  43404. * Content stored in the octree
  43405. */
  43406. dynamicContent: T[];
  43407. private _maxBlockCapacity;
  43408. private _selectionContent;
  43409. private _creationFunc;
  43410. /**
  43411. * Creates a octree
  43412. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43413. * @param creationFunc function to be used to instatiate the octree
  43414. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43415. * @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.)
  43416. */
  43417. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43418. /** 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.) */
  43419. maxDepth?: number);
  43420. /**
  43421. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43422. * @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);
  43423. * @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);
  43424. * @param entries meshes to be added to the octree blocks
  43425. */
  43426. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43427. /**
  43428. * Adds a mesh to the octree
  43429. * @param entry Mesh to add to the octree
  43430. */
  43431. addMesh(entry: T): void;
  43432. /**
  43433. * Selects an array of meshes within the frustum
  43434. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43435. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43436. * @returns array of meshes within the frustum
  43437. */
  43438. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43439. /**
  43440. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43441. * @param sphereCenter defines the bounding sphere center
  43442. * @param sphereRadius defines the bounding sphere radius
  43443. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43444. * @returns an array of objects that intersect the sphere
  43445. */
  43446. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43447. /**
  43448. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43449. * @param ray defines the ray to test with
  43450. * @returns array of intersected objects
  43451. */
  43452. intersectsRay(ray: Ray): SmartArray<T>;
  43453. /**
  43454. * @hidden
  43455. */
  43456. 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;
  43457. /**
  43458. * Adds a mesh into the octree block if it intersects the block
  43459. */
  43460. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43461. /**
  43462. * Adds a submesh into the octree block if it intersects the block
  43463. */
  43464. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43465. }
  43466. }
  43467. declare module BABYLON {
  43468. /**
  43469. * Class used to store a cell in an octree
  43470. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43471. */
  43472. class OctreeBlock<T> {
  43473. /**
  43474. * Gets the content of the current block
  43475. */
  43476. entries: T[];
  43477. /**
  43478. * Gets the list of block children
  43479. */
  43480. blocks: Array<OctreeBlock<T>>;
  43481. private _depth;
  43482. private _maxDepth;
  43483. private _capacity;
  43484. private _minPoint;
  43485. private _maxPoint;
  43486. private _boundingVectors;
  43487. private _creationFunc;
  43488. /**
  43489. * Creates a new block
  43490. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43491. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43492. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43493. * @param depth defines the current depth of this block in the octree
  43494. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43495. * @param creationFunc defines a callback to call when an element is added to the block
  43496. */
  43497. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43498. /**
  43499. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43500. */
  43501. readonly capacity: number;
  43502. /**
  43503. * Gets the minimum vector (in world space) of the block's bounding box
  43504. */
  43505. readonly minPoint: Vector3;
  43506. /**
  43507. * Gets the maximum vector (in world space) of the block's bounding box
  43508. */
  43509. readonly maxPoint: Vector3;
  43510. /**
  43511. * Add a new element to this block
  43512. * @param entry defines the element to add
  43513. */
  43514. addEntry(entry: T): void;
  43515. /**
  43516. * Add an array of elements to this block
  43517. * @param entries defines the array of elements to add
  43518. */
  43519. addEntries(entries: T[]): void;
  43520. /**
  43521. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43522. * @param frustumPlanes defines the frustum planes to test
  43523. * @param selection defines the array to store current content if selection is positive
  43524. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43525. */
  43526. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43527. /**
  43528. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43529. * @param sphereCenter defines the bounding sphere center
  43530. * @param sphereRadius defines the bounding sphere radius
  43531. * @param selection defines the array to store current content if selection is positive
  43532. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43533. */
  43534. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43535. /**
  43536. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43537. * @param ray defines the ray to test with
  43538. * @param selection defines the array to store current content if selection is positive
  43539. */
  43540. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43541. /**
  43542. * Subdivide the content into child blocks (this block will then be empty)
  43543. */
  43544. createInnerBlocks(): void;
  43545. }
  43546. }
  43547. declare module BABYLON {
  43548. interface Scene {
  43549. /**
  43550. * @hidden
  43551. * Backing Filed
  43552. */
  43553. _selectionOctree: Octree<AbstractMesh>;
  43554. /**
  43555. * Gets the octree used to boost mesh selection (picking)
  43556. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43557. */
  43558. selectionOctree: Octree<AbstractMesh>;
  43559. /**
  43560. * Creates or updates the octree used to boost selection (picking)
  43561. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43562. * @param maxCapacity defines the maximum capacity per leaf
  43563. * @param maxDepth defines the maximum depth of the octree
  43564. * @returns an octree of AbstractMesh
  43565. */
  43566. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43567. }
  43568. interface AbstractMesh {
  43569. /**
  43570. * @hidden
  43571. * Backing Field
  43572. */
  43573. _submeshesOctree: Octree<SubMesh>;
  43574. /**
  43575. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43576. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43577. * @param maxCapacity defines the maximum size of each block (64 by default)
  43578. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43579. * @returns the new octree
  43580. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43581. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43582. */
  43583. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43584. }
  43585. /**
  43586. * Defines the octree scene component responsible to manage any octrees
  43587. * in a given scene.
  43588. */
  43589. class OctreeSceneComponent {
  43590. /**
  43591. * The component name helpfull to identify the component in the list of scene components.
  43592. */
  43593. readonly name: string;
  43594. /**
  43595. * The scene the component belongs to.
  43596. */
  43597. scene: Scene;
  43598. /**
  43599. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43600. */
  43601. readonly checksIsEnabled: boolean;
  43602. /**
  43603. * Creates a new instance of the component for the given scene
  43604. * @param scene Defines the scene to register the component in
  43605. */
  43606. constructor(scene: Scene);
  43607. /**
  43608. * Registers the component in a given scene
  43609. */
  43610. register(): void;
  43611. /**
  43612. * Return the list of active meshes
  43613. * @returns the list of active meshes
  43614. */
  43615. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43616. /**
  43617. * Return the list of active sub meshes
  43618. * @param mesh The mesh to get the candidates sub meshes from
  43619. * @returns the list of active sub meshes
  43620. */
  43621. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43622. private _tempRay;
  43623. /**
  43624. * Return the list of sub meshes intersecting with a given local ray
  43625. * @param mesh defines the mesh to find the submesh for
  43626. * @param localRay defines the ray in local space
  43627. * @returns the list of intersecting sub meshes
  43628. */
  43629. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43630. /**
  43631. * Return the list of sub meshes colliding with a collider
  43632. * @param mesh defines the mesh to find the submesh for
  43633. * @param collider defines the collider to evaluate the collision against
  43634. * @returns the list of colliding sub meshes
  43635. */
  43636. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43637. /**
  43638. * Rebuilds the elements related to this component in case of
  43639. * context lost for instance.
  43640. */
  43641. rebuild(): void;
  43642. /**
  43643. * Disposes the component and the associated ressources.
  43644. */
  43645. dispose(): void;
  43646. }
  43647. }
  43648. declare module BABYLON {
  43649. /** @hidden */
  43650. class _OcclusionDataStorage {
  43651. /** @hidden */
  43652. occlusionInternalRetryCounter: number;
  43653. /** @hidden */
  43654. isOcclusionQueryInProgress: boolean;
  43655. /** @hidden */
  43656. isOccluded: boolean;
  43657. /** @hidden */
  43658. occlusionRetryCount: number;
  43659. /** @hidden */
  43660. occlusionType: number;
  43661. /** @hidden */
  43662. occlusionQueryAlgorithmType: number;
  43663. }
  43664. interface Engine {
  43665. /**
  43666. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43667. * @return the new query
  43668. */
  43669. createQuery(): WebGLQuery;
  43670. /**
  43671. * Delete and release a webGL query
  43672. * @param query defines the query to delete
  43673. * @return the current engine
  43674. */
  43675. deleteQuery(query: WebGLQuery): Engine;
  43676. /**
  43677. * Check if a given query has resolved and got its value
  43678. * @param query defines the query to check
  43679. * @returns true if the query got its value
  43680. */
  43681. isQueryResultAvailable(query: WebGLQuery): boolean;
  43682. /**
  43683. * Gets the value of a given query
  43684. * @param query defines the query to check
  43685. * @returns the value of the query
  43686. */
  43687. getQueryResult(query: WebGLQuery): number;
  43688. /**
  43689. * Initiates an occlusion query
  43690. * @param algorithmType defines the algorithm to use
  43691. * @param query defines the query to use
  43692. * @returns the current engine
  43693. * @see http://doc.babylonjs.com/features/occlusionquery
  43694. */
  43695. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43696. /**
  43697. * Ends an occlusion query
  43698. * @see http://doc.babylonjs.com/features/occlusionquery
  43699. * @param algorithmType defines the algorithm to use
  43700. * @returns the current engine
  43701. */
  43702. endOcclusionQuery(algorithmType: number): Engine;
  43703. /**
  43704. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43705. * Please note that only one query can be issued at a time
  43706. * @returns a time token used to track the time span
  43707. */
  43708. startTimeQuery(): Nullable<_TimeToken>;
  43709. /**
  43710. * Ends a time query
  43711. * @param token defines the token used to measure the time span
  43712. * @returns the time spent (in ns)
  43713. */
  43714. endTimeQuery(token: _TimeToken): int;
  43715. /** @hidden */
  43716. _currentNonTimestampToken: Nullable<_TimeToken>;
  43717. /** @hidden */
  43718. _createTimeQuery(): WebGLQuery;
  43719. /** @hidden */
  43720. _deleteTimeQuery(query: WebGLQuery): void;
  43721. /** @hidden */
  43722. _getGlAlgorithmType(algorithmType: number): number;
  43723. /** @hidden */
  43724. _getTimeQueryResult(query: WebGLQuery): any;
  43725. /** @hidden */
  43726. _getTimeQueryAvailability(query: WebGLQuery): any;
  43727. }
  43728. interface AbstractMesh {
  43729. /**
  43730. * Backing filed
  43731. * @hidden
  43732. */
  43733. __occlusionDataStorage: _OcclusionDataStorage;
  43734. /**
  43735. * Access property
  43736. * @hidden
  43737. */
  43738. _occlusionDataStorage: _OcclusionDataStorage;
  43739. /**
  43740. * 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.
  43741. * The default value is -1 which means don't break the query and wait till the result
  43742. * @see http://doc.babylonjs.com/features/occlusionquery
  43743. */
  43744. occlusionRetryCount: number;
  43745. /**
  43746. * 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:
  43747. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43748. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43749. * * 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.
  43750. * @see http://doc.babylonjs.com/features/occlusionquery
  43751. */
  43752. occlusionType: number;
  43753. /**
  43754. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43755. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43756. * * 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.
  43757. * @see http://doc.babylonjs.com/features/occlusionquery
  43758. */
  43759. occlusionQueryAlgorithmType: number;
  43760. /**
  43761. * 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
  43762. * @see http://doc.babylonjs.com/features/occlusionquery
  43763. */
  43764. isOccluded: boolean;
  43765. /**
  43766. * Flag to check the progress status of the query
  43767. * @see http://doc.babylonjs.com/features/occlusionquery
  43768. */
  43769. isOcclusionQueryInProgress: boolean;
  43770. }
  43771. }
  43772. declare module BABYLON {
  43773. interface Engine {
  43774. /**
  43775. * Creates a webGL transform feedback object
  43776. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43777. * @returns the webGL transform feedback object
  43778. */
  43779. createTransformFeedback(): WebGLTransformFeedback;
  43780. /**
  43781. * Delete a webGL transform feedback object
  43782. * @param value defines the webGL transform feedback object to delete
  43783. */
  43784. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43785. /**
  43786. * Bind a webGL transform feedback object to the webgl context
  43787. * @param value defines the webGL transform feedback object to bind
  43788. */
  43789. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43790. /**
  43791. * Begins a transform feedback operation
  43792. * @param usePoints defines if points or triangles must be used
  43793. */
  43794. beginTransformFeedback(usePoints: boolean): void;
  43795. /**
  43796. * Ends a transform feedback operation
  43797. */
  43798. endTransformFeedback(): void;
  43799. /**
  43800. * Specify the varyings to use with transform feedback
  43801. * @param program defines the associated webGL program
  43802. * @param value defines the list of strings representing the varying names
  43803. */
  43804. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43805. /**
  43806. * Bind a webGL buffer for a transform feedback operation
  43807. * @param value defines the webGL buffer to bind
  43808. */
  43809. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43810. }
  43811. }
  43812. declare module BABYLON {
  43813. /**
  43814. * Google Daydream controller
  43815. */
  43816. class DaydreamController extends WebVRController {
  43817. /**
  43818. * Base Url for the controller model.
  43819. */
  43820. static MODEL_BASE_URL: string;
  43821. /**
  43822. * File name for the controller model.
  43823. */
  43824. static MODEL_FILENAME: string;
  43825. /**
  43826. * Gamepad Id prefix used to identify Daydream Controller.
  43827. */
  43828. static readonly GAMEPAD_ID_PREFIX: string;
  43829. /**
  43830. * Creates a new DaydreamController from a gamepad
  43831. * @param vrGamepad the gamepad that the controller should be created from
  43832. */
  43833. constructor(vrGamepad: any);
  43834. /**
  43835. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43836. * @param scene scene in which to add meshes
  43837. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43838. */
  43839. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43840. /**
  43841. * Called once for each button that changed state since the last frame
  43842. * @param buttonIdx Which button index changed
  43843. * @param state New state of the button
  43844. * @param changes Which properties on the state changed since last frame
  43845. */
  43846. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43847. }
  43848. }
  43849. declare module BABYLON {
  43850. /**
  43851. * Gear VR Controller
  43852. */
  43853. class GearVRController extends WebVRController {
  43854. /**
  43855. * Base Url for the controller model.
  43856. */
  43857. static MODEL_BASE_URL: string;
  43858. /**
  43859. * File name for the controller model.
  43860. */
  43861. static MODEL_FILENAME: string;
  43862. /**
  43863. * Gamepad Id prefix used to identify this controller.
  43864. */
  43865. static readonly GAMEPAD_ID_PREFIX: string;
  43866. private readonly _buttonIndexToObservableNameMap;
  43867. /**
  43868. * Creates a new GearVRController from a gamepad
  43869. * @param vrGamepad the gamepad that the controller should be created from
  43870. */
  43871. constructor(vrGamepad: any);
  43872. /**
  43873. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43874. * @param scene scene in which to add meshes
  43875. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43876. */
  43877. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43878. /**
  43879. * Called once for each button that changed state since the last frame
  43880. * @param buttonIdx Which button index changed
  43881. * @param state New state of the button
  43882. * @param changes Which properties on the state changed since last frame
  43883. */
  43884. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43885. }
  43886. }
  43887. declare module BABYLON {
  43888. /**
  43889. * Generic Controller
  43890. */
  43891. class GenericController extends WebVRController {
  43892. /**
  43893. * Base Url for the controller model.
  43894. */
  43895. static readonly MODEL_BASE_URL: string;
  43896. /**
  43897. * File name for the controller model.
  43898. */
  43899. static readonly MODEL_FILENAME: string;
  43900. /**
  43901. * Creates a new GenericController from a gamepad
  43902. * @param vrGamepad the gamepad that the controller should be created from
  43903. */
  43904. constructor(vrGamepad: any);
  43905. /**
  43906. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43907. * @param scene scene in which to add meshes
  43908. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43909. */
  43910. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43911. /**
  43912. * Called once for each button that changed state since the last frame
  43913. * @param buttonIdx Which button index changed
  43914. * @param state New state of the button
  43915. * @param changes Which properties on the state changed since last frame
  43916. */
  43917. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43918. }
  43919. }
  43920. declare module BABYLON {
  43921. /**
  43922. * Oculus Touch Controller
  43923. */
  43924. class OculusTouchController extends WebVRController {
  43925. /**
  43926. * Base Url for the controller model.
  43927. */
  43928. static MODEL_BASE_URL: string;
  43929. /**
  43930. * File name for the left controller model.
  43931. */
  43932. static MODEL_LEFT_FILENAME: string;
  43933. /**
  43934. * File name for the right controller model.
  43935. */
  43936. static MODEL_RIGHT_FILENAME: string;
  43937. /**
  43938. * Fired when the secondary trigger on this controller is modified
  43939. */
  43940. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43941. /**
  43942. * Fired when the thumb rest on this controller is modified
  43943. */
  43944. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43945. /**
  43946. * Creates a new OculusTouchController from a gamepad
  43947. * @param vrGamepad the gamepad that the controller should be created from
  43948. */
  43949. constructor(vrGamepad: any);
  43950. /**
  43951. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43952. * @param scene scene in which to add meshes
  43953. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43954. */
  43955. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43956. /**
  43957. * Fired when the A button on this controller is modified
  43958. */
  43959. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43960. /**
  43961. * Fired when the B button on this controller is modified
  43962. */
  43963. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43964. /**
  43965. * Fired when the X button on this controller is modified
  43966. */
  43967. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43968. /**
  43969. * Fired when the Y button on this controller is modified
  43970. */
  43971. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43972. /**
  43973. * Called once for each button that changed state since the last frame
  43974. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43975. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43976. * 2) secondary trigger (same)
  43977. * 3) A (right) X (left), touch, pressed = value
  43978. * 4) B / Y
  43979. * 5) thumb rest
  43980. * @param buttonIdx Which button index changed
  43981. * @param state New state of the button
  43982. * @param changes Which properties on the state changed since last frame
  43983. */
  43984. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43985. }
  43986. }
  43987. declare module BABYLON {
  43988. /**
  43989. * Defines the types of pose enabled controllers that are supported
  43990. */
  43991. enum PoseEnabledControllerType {
  43992. /**
  43993. * HTC Vive
  43994. */
  43995. VIVE = 0,
  43996. /**
  43997. * Oculus Rift
  43998. */
  43999. OCULUS = 1,
  44000. /**
  44001. * Windows mixed reality
  44002. */
  44003. WINDOWS = 2,
  44004. /**
  44005. * Samsung gear VR
  44006. */
  44007. GEAR_VR = 3,
  44008. /**
  44009. * Google Daydream
  44010. */
  44011. DAYDREAM = 4,
  44012. /**
  44013. * Generic
  44014. */
  44015. GENERIC = 5
  44016. }
  44017. /**
  44018. * Defines the MutableGamepadButton interface for the state of a gamepad button
  44019. */
  44020. interface MutableGamepadButton {
  44021. /**
  44022. * Value of the button/trigger
  44023. */
  44024. value: number;
  44025. /**
  44026. * If the button/trigger is currently touched
  44027. */
  44028. touched: boolean;
  44029. /**
  44030. * If the button/trigger is currently pressed
  44031. */
  44032. pressed: boolean;
  44033. }
  44034. /**
  44035. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  44036. * @hidden
  44037. */
  44038. interface ExtendedGamepadButton extends GamepadButton {
  44039. /**
  44040. * If the button/trigger is currently pressed
  44041. */
  44042. readonly pressed: boolean;
  44043. /**
  44044. * If the button/trigger is currently touched
  44045. */
  44046. readonly touched: boolean;
  44047. /**
  44048. * Value of the button/trigger
  44049. */
  44050. readonly value: number;
  44051. }
  44052. /**
  44053. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  44054. */
  44055. class PoseEnabledControllerHelper {
  44056. /**
  44057. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  44058. * @param vrGamepad the gamepad to initialized
  44059. * @returns a vr controller of the type the gamepad identified as
  44060. */
  44061. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  44062. }
  44063. /**
  44064. * Defines the PoseEnabledController object that contains state of a vr capable controller
  44065. */
  44066. class PoseEnabledController extends Gamepad implements PoseControlled {
  44067. private _deviceRoomPosition;
  44068. private _deviceRoomRotationQuaternion;
  44069. /**
  44070. * The device position in babylon space
  44071. */
  44072. devicePosition: Vector3;
  44073. /**
  44074. * The device rotation in babylon space
  44075. */
  44076. deviceRotationQuaternion: Quaternion;
  44077. /**
  44078. * The scale factor of the device in babylon space
  44079. */
  44080. deviceScaleFactor: number;
  44081. /**
  44082. * (Likely devicePosition should be used instead) The device position in its room space
  44083. */
  44084. position: Vector3;
  44085. /**
  44086. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  44087. */
  44088. rotationQuaternion: Quaternion;
  44089. /**
  44090. * The type of controller (Eg. Windows mixed reality)
  44091. */
  44092. controllerType: PoseEnabledControllerType;
  44093. protected _calculatedPosition: Vector3;
  44094. private _calculatedRotation;
  44095. /**
  44096. * The raw pose from the device
  44097. */
  44098. rawPose: DevicePose;
  44099. private _trackPosition;
  44100. private _maxRotationDistFromHeadset;
  44101. private _draggedRoomRotation;
  44102. /**
  44103. * @hidden
  44104. */
  44105. _disableTrackPosition(fixedPosition: Vector3): void;
  44106. /**
  44107. * Internal, the mesh attached to the controller
  44108. * @hidden
  44109. */
  44110. _mesh: Nullable<AbstractMesh>;
  44111. private _poseControlledCamera;
  44112. private _leftHandSystemQuaternion;
  44113. /**
  44114. * Internal, matrix used to convert room space to babylon space
  44115. * @hidden
  44116. */
  44117. _deviceToWorld: Matrix;
  44118. /**
  44119. * Node to be used when casting a ray from the controller
  44120. * @hidden
  44121. */
  44122. _pointingPoseNode: Nullable<TransformNode>;
  44123. /**
  44124. * Name of the child mesh that can be used to cast a ray from the controller
  44125. */
  44126. static readonly POINTING_POSE: string;
  44127. /**
  44128. * Creates a new PoseEnabledController from a gamepad
  44129. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  44130. */
  44131. constructor(browserGamepad: any);
  44132. private _workingMatrix;
  44133. /**
  44134. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  44135. */
  44136. update(): void;
  44137. /**
  44138. * Updates only the pose device and mesh without doing any button event checking
  44139. */
  44140. protected _updatePoseAndMesh(): void;
  44141. /**
  44142. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  44143. * @param poseData raw pose fromthe device
  44144. */
  44145. updateFromDevice(poseData: DevicePose): void;
  44146. /**
  44147. * @hidden
  44148. */
  44149. _meshAttachedObservable: Observable<AbstractMesh>;
  44150. /**
  44151. * Attaches a mesh to the controller
  44152. * @param mesh the mesh to be attached
  44153. */
  44154. attachToMesh(mesh: AbstractMesh): void;
  44155. /**
  44156. * Attaches the controllers mesh to a camera
  44157. * @param camera the camera the mesh should be attached to
  44158. */
  44159. attachToPoseControlledCamera(camera: TargetCamera): void;
  44160. /**
  44161. * Disposes of the controller
  44162. */
  44163. dispose(): void;
  44164. /**
  44165. * The mesh that is attached to the controller
  44166. */
  44167. readonly mesh: Nullable<AbstractMesh>;
  44168. /**
  44169. * Gets the ray of the controller in the direction the controller is pointing
  44170. * @param length the length the resulting ray should be
  44171. * @returns a ray in the direction the controller is pointing
  44172. */
  44173. getForwardRay(length?: number): Ray;
  44174. }
  44175. }
  44176. declare module BABYLON {
  44177. /**
  44178. * Vive Controller
  44179. */
  44180. class ViveController extends WebVRController {
  44181. /**
  44182. * Base Url for the controller model.
  44183. */
  44184. static MODEL_BASE_URL: string;
  44185. /**
  44186. * File name for the controller model.
  44187. */
  44188. static MODEL_FILENAME: string;
  44189. /**
  44190. * Creates a new ViveController from a gamepad
  44191. * @param vrGamepad the gamepad that the controller should be created from
  44192. */
  44193. constructor(vrGamepad: any);
  44194. /**
  44195. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44196. * @param scene scene in which to add meshes
  44197. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44198. */
  44199. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44200. /**
  44201. * Fired when the left button on this controller is modified
  44202. */
  44203. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44204. /**
  44205. * Fired when the right button on this controller is modified
  44206. */
  44207. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44208. /**
  44209. * Fired when the menu button on this controller is modified
  44210. */
  44211. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44212. /**
  44213. * Called once for each button that changed state since the last frame
  44214. * Vive mapping:
  44215. * 0: touchpad
  44216. * 1: trigger
  44217. * 2: left AND right buttons
  44218. * 3: menu button
  44219. * @param buttonIdx Which button index changed
  44220. * @param state New state of the button
  44221. * @param changes Which properties on the state changed since last frame
  44222. */
  44223. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44224. }
  44225. }
  44226. declare module BABYLON {
  44227. /**
  44228. * Defines the WebVRController object that represents controllers tracked in 3D space
  44229. */
  44230. abstract class WebVRController extends PoseEnabledController {
  44231. /**
  44232. * Internal, the default controller model for the controller
  44233. */
  44234. protected _defaultModel: AbstractMesh;
  44235. /**
  44236. * Fired when the trigger state has changed
  44237. */
  44238. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44239. /**
  44240. * Fired when the main button state has changed
  44241. */
  44242. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44243. /**
  44244. * Fired when the secondary button state has changed
  44245. */
  44246. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44247. /**
  44248. * Fired when the pad state has changed
  44249. */
  44250. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  44251. /**
  44252. * Fired when controllers stick values have changed
  44253. */
  44254. onPadValuesChangedObservable: Observable<StickValues>;
  44255. /**
  44256. * Array of button availible on the controller
  44257. */
  44258. protected _buttons: Array<MutableGamepadButton>;
  44259. private _onButtonStateChange;
  44260. /**
  44261. * Fired when a controller button's state has changed
  44262. * @param callback the callback containing the button that was modified
  44263. */
  44264. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  44265. /**
  44266. * X and Y axis corrisponding to the controllers joystick
  44267. */
  44268. pad: StickValues;
  44269. /**
  44270. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  44271. */
  44272. hand: string;
  44273. /**
  44274. * The default controller model for the controller
  44275. */
  44276. readonly defaultModel: AbstractMesh;
  44277. /**
  44278. * Creates a new WebVRController from a gamepad
  44279. * @param vrGamepad the gamepad that the WebVRController should be created from
  44280. */
  44281. constructor(vrGamepad: any);
  44282. /**
  44283. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  44284. */
  44285. update(): void;
  44286. /**
  44287. * Function to be called when a button is modified
  44288. */
  44289. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44290. /**
  44291. * Loads a mesh and attaches it to the controller
  44292. * @param scene the scene the mesh should be added to
  44293. * @param meshLoaded callback for when the mesh has been loaded
  44294. */
  44295. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44296. private _setButtonValue;
  44297. private _changes;
  44298. private _checkChanges;
  44299. /**
  44300. * Disposes of th webVRCOntroller
  44301. */
  44302. dispose(): void;
  44303. }
  44304. }
  44305. declare module BABYLON {
  44306. /**
  44307. * Defines the WindowsMotionController object that the state of the windows motion controller
  44308. */
  44309. class WindowsMotionController extends WebVRController {
  44310. /**
  44311. * The base url used to load the left and right controller models
  44312. */
  44313. static MODEL_BASE_URL: string;
  44314. /**
  44315. * The name of the left controller model file
  44316. */
  44317. static MODEL_LEFT_FILENAME: string;
  44318. /**
  44319. * The name of the right controller model file
  44320. */
  44321. static MODEL_RIGHT_FILENAME: string;
  44322. /**
  44323. * The controller name prefix for this controller type
  44324. */
  44325. static readonly GAMEPAD_ID_PREFIX: string;
  44326. /**
  44327. * The controller id pattern for this controller type
  44328. */
  44329. private static readonly GAMEPAD_ID_PATTERN;
  44330. private _loadedMeshInfo;
  44331. private readonly _mapping;
  44332. /**
  44333. * Fired when the trackpad on this controller is clicked
  44334. */
  44335. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44336. /**
  44337. * Fired when the trackpad on this controller is modified
  44338. */
  44339. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44340. /**
  44341. * The current x and y values of this controller's trackpad
  44342. */
  44343. trackpad: StickValues;
  44344. /**
  44345. * Creates a new WindowsMotionController from a gamepad
  44346. * @param vrGamepad the gamepad that the controller should be created from
  44347. */
  44348. constructor(vrGamepad: any);
  44349. /**
  44350. * Fired when the trigger on this controller is modified
  44351. */
  44352. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44353. /**
  44354. * Fired when the menu button on this controller is modified
  44355. */
  44356. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44357. /**
  44358. * Fired when the grip button on this controller is modified
  44359. */
  44360. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44361. /**
  44362. * Fired when the thumbstick button on this controller is modified
  44363. */
  44364. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44365. /**
  44366. * Fired when the touchpad button on this controller is modified
  44367. */
  44368. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44369. /**
  44370. * Fired when the touchpad values on this controller are modified
  44371. */
  44372. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44373. private _updateTrackpad;
  44374. /**
  44375. * Called once per frame by the engine.
  44376. */
  44377. update(): void;
  44378. /**
  44379. * Called once for each button that changed state since the last frame
  44380. * @param buttonIdx Which button index changed
  44381. * @param state New state of the button
  44382. * @param changes Which properties on the state changed since last frame
  44383. */
  44384. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44385. /**
  44386. * Moves the buttons on the controller mesh based on their current state
  44387. * @param buttonName the name of the button to move
  44388. * @param buttonValue the value of the button which determines the buttons new position
  44389. */
  44390. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44391. /**
  44392. * Moves the axis on the controller mesh based on its current state
  44393. * @param axis the index of the axis
  44394. * @param axisValue the value of the axis which determines the meshes new position
  44395. * @hidden
  44396. */
  44397. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44398. /**
  44399. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44400. * @param scene scene in which to add meshes
  44401. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44402. */
  44403. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44404. /**
  44405. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44406. * can be transformed by button presses and axes values, based on this._mapping.
  44407. *
  44408. * @param scene scene in which the meshes exist
  44409. * @param meshes list of meshes that make up the controller model to process
  44410. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44411. */
  44412. private processModel;
  44413. private createMeshInfo;
  44414. /**
  44415. * Gets the ray of the controller in the direction the controller is pointing
  44416. * @param length the length the resulting ray should be
  44417. * @returns a ray in the direction the controller is pointing
  44418. */
  44419. getForwardRay(length?: number): Ray;
  44420. /**
  44421. * Disposes of the controller
  44422. */
  44423. dispose(): void;
  44424. }
  44425. }
  44426. declare module BABYLON {
  44427. /**
  44428. * Interface to implement to create a shadow generator compatible with BJS.
  44429. */
  44430. interface IShadowGenerator {
  44431. /**
  44432. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44433. * @returns The render target texture if present otherwise, null
  44434. */
  44435. getShadowMap(): Nullable<RenderTargetTexture>;
  44436. /**
  44437. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44438. * @returns The render target texture if the shadow map is present otherwise, null
  44439. */
  44440. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44441. /**
  44442. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44443. * @param subMesh The submesh we want to render in the shadow map
  44444. * @param useInstances Defines wether will draw in the map using instances
  44445. * @returns true if ready otherwise, false
  44446. */
  44447. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44448. /**
  44449. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44450. * @param defines Defines of the material we want to update
  44451. * @param lightIndex Index of the light in the enabled light list of the material
  44452. */
  44453. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  44454. /**
  44455. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44456. * defined in the generator but impacting the effect).
  44457. * It implies the unifroms available on the materials are the standard BJS ones.
  44458. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44459. * @param effect The effect we are binfing the information for
  44460. */
  44461. bindShadowLight(lightIndex: string, effect: Effect): void;
  44462. /**
  44463. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44464. * (eq to shadow prjection matrix * light transform matrix)
  44465. * @returns The transform matrix used to create the shadow map
  44466. */
  44467. getTransformMatrix(): Matrix;
  44468. /**
  44469. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44470. * Cube and 2D textures for instance.
  44471. */
  44472. recreateShadowMap(): void;
  44473. /**
  44474. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44475. * @param onCompiled Callback triggered at the and of the effects compilation
  44476. * @param options Sets of optional options forcing the compilation with different modes
  44477. */
  44478. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44479. useInstances: boolean;
  44480. }>): void;
  44481. /**
  44482. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44483. * @param options Sets of optional options forcing the compilation with different modes
  44484. * @returns A promise that resolves when the compilation completes
  44485. */
  44486. forceCompilationAsync(options?: Partial<{
  44487. useInstances: boolean;
  44488. }>): Promise<void>;
  44489. /**
  44490. * Serializes the shadow generator setup to a json object.
  44491. * @returns The serialized JSON object
  44492. */
  44493. serialize(): any;
  44494. /**
  44495. * Disposes the Shadow map and related Textures and effects.
  44496. */
  44497. dispose(): void;
  44498. }
  44499. /**
  44500. * Default implementation IShadowGenerator.
  44501. * This is the main object responsible of generating shadows in the framework.
  44502. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44503. */
  44504. class ShadowGenerator implements IShadowGenerator {
  44505. /**
  44506. * Shadow generator mode None: no filtering applied.
  44507. */
  44508. static readonly FILTER_NONE: number;
  44509. /**
  44510. * Shadow generator mode ESM: Exponential Shadow Mapping.
  44511. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44512. */
  44513. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  44514. /**
  44515. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  44516. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  44517. */
  44518. static readonly FILTER_POISSONSAMPLING: number;
  44519. /**
  44520. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  44521. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44522. */
  44523. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  44524. /**
  44525. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  44526. * edge artifacts on steep falloff.
  44527. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44528. */
  44529. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  44530. /**
  44531. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  44532. * edge artifacts on steep falloff.
  44533. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44534. */
  44535. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  44536. /**
  44537. * Shadow generator mode PCF: Percentage Closer Filtering
  44538. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44539. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  44540. */
  44541. static readonly FILTER_PCF: number;
  44542. /**
  44543. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  44544. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44545. * Contact Hardening
  44546. */
  44547. static readonly FILTER_PCSS: number;
  44548. /**
  44549. * Reserved for PCF and PCSS
  44550. * Highest Quality.
  44551. *
  44552. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  44553. *
  44554. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  44555. */
  44556. static readonly QUALITY_HIGH: number;
  44557. /**
  44558. * Reserved for PCF and PCSS
  44559. * Good tradeoff for quality/perf cross devices
  44560. *
  44561. * Execute PCF on a 3*3 kernel.
  44562. *
  44563. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  44564. */
  44565. static readonly QUALITY_MEDIUM: number;
  44566. /**
  44567. * Reserved for PCF and PCSS
  44568. * The lowest quality but the fastest.
  44569. *
  44570. * Execute PCF on a 1*1 kernel.
  44571. *
  44572. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  44573. */
  44574. static readonly QUALITY_LOW: number;
  44575. private _bias;
  44576. /**
  44577. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44578. */
  44579. /**
  44580. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44581. */
  44582. bias: number;
  44583. private _normalBias;
  44584. /**
  44585. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44586. */
  44587. /**
  44588. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44589. */
  44590. normalBias: number;
  44591. private _blurBoxOffset;
  44592. /**
  44593. * Gets the blur box offset: offset applied during the blur pass.
  44594. * Only useful if useKernelBlur = false
  44595. */
  44596. /**
  44597. * Sets the blur box offset: offset applied during the blur pass.
  44598. * Only useful if useKernelBlur = false
  44599. */
  44600. blurBoxOffset: number;
  44601. private _blurScale;
  44602. /**
  44603. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44604. * 2 means half of the size.
  44605. */
  44606. /**
  44607. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44608. * 2 means half of the size.
  44609. */
  44610. blurScale: number;
  44611. private _blurKernel;
  44612. /**
  44613. * Gets the blur kernel: kernel size of the blur pass.
  44614. * Only useful if useKernelBlur = true
  44615. */
  44616. /**
  44617. * Sets the blur kernel: kernel size of the blur pass.
  44618. * Only useful if useKernelBlur = true
  44619. */
  44620. blurKernel: number;
  44621. private _useKernelBlur;
  44622. /**
  44623. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44624. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44625. */
  44626. /**
  44627. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44628. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44629. */
  44630. useKernelBlur: boolean;
  44631. private _depthScale;
  44632. /**
  44633. * Gets the depth scale used in ESM mode.
  44634. */
  44635. /**
  44636. * Sets the depth scale used in ESM mode.
  44637. * This can override the scale stored on the light.
  44638. */
  44639. depthScale: number;
  44640. private _filter;
  44641. /**
  44642. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44643. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44644. */
  44645. /**
  44646. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44647. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44648. */
  44649. filter: number;
  44650. /**
  44651. * Gets if the current filter is set to Poisson Sampling.
  44652. */
  44653. /**
  44654. * Sets the current filter to Poisson Sampling.
  44655. */
  44656. usePoissonSampling: boolean;
  44657. /**
  44658. * Gets if the current filter is set to ESM.
  44659. */
  44660. /**
  44661. * Sets the current filter is to ESM.
  44662. */
  44663. useExponentialShadowMap: boolean;
  44664. /**
  44665. * Gets if the current filter is set to filtered ESM.
  44666. */
  44667. /**
  44668. * Gets if the current filter is set to filtered ESM.
  44669. */
  44670. useBlurExponentialShadowMap: boolean;
  44671. /**
  44672. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44673. * exponential to prevent steep falloff artifacts).
  44674. */
  44675. /**
  44676. * Sets the current filter to "close ESM" (using the inverse of the
  44677. * exponential to prevent steep falloff artifacts).
  44678. */
  44679. useCloseExponentialShadowMap: boolean;
  44680. /**
  44681. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44682. * exponential to prevent steep falloff artifacts).
  44683. */
  44684. /**
  44685. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44686. * exponential to prevent steep falloff artifacts).
  44687. */
  44688. useBlurCloseExponentialShadowMap: boolean;
  44689. /**
  44690. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44691. */
  44692. /**
  44693. * Sets the current filter to "PCF" (percentage closer filtering).
  44694. */
  44695. usePercentageCloserFiltering: boolean;
  44696. private _filteringQuality;
  44697. /**
  44698. * Gets the PCF or PCSS Quality.
  44699. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44700. */
  44701. /**
  44702. * Sets the PCF or PCSS Quality.
  44703. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44704. */
  44705. filteringQuality: number;
  44706. /**
  44707. * Gets if the current filter is set to "PCSS" (contact hardening).
  44708. */
  44709. /**
  44710. * Sets the current filter to "PCSS" (contact hardening).
  44711. */
  44712. useContactHardeningShadow: boolean;
  44713. private _contactHardeningLightSizeUVRatio;
  44714. /**
  44715. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44716. * Using a ratio helps keeping shape stability independently of the map size.
  44717. *
  44718. * It does not account for the light projection as it was having too much
  44719. * instability during the light setup or during light position changes.
  44720. *
  44721. * Only valid if useContactHardeningShadow is true.
  44722. */
  44723. /**
  44724. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44725. * Using a ratio helps keeping shape stability independently of the map size.
  44726. *
  44727. * It does not account for the light projection as it was having too much
  44728. * instability during the light setup or during light position changes.
  44729. *
  44730. * Only valid if useContactHardeningShadow is true.
  44731. */
  44732. contactHardeningLightSizeUVRatio: number;
  44733. private _darkness;
  44734. /**
  44735. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44736. * 0 means strongest and 1 would means no shadow.
  44737. * @returns the darkness.
  44738. */
  44739. getDarkness(): number;
  44740. /**
  44741. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44742. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44743. * @returns the shadow generator allowing fluent coding.
  44744. */
  44745. setDarkness(darkness: number): ShadowGenerator;
  44746. private _transparencyShadow;
  44747. /**
  44748. * Sets the ability to have transparent shadow (boolean).
  44749. * @param transparent True if transparent else False
  44750. * @returns the shadow generator allowing fluent coding
  44751. */
  44752. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  44753. private _shadowMap;
  44754. private _shadowMap2;
  44755. /**
  44756. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44757. * @returns The render target texture if present otherwise, null
  44758. */
  44759. getShadowMap(): Nullable<RenderTargetTexture>;
  44760. /**
  44761. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44762. * @returns The render target texture if the shadow map is present otherwise, null
  44763. */
  44764. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44765. /**
  44766. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44767. * @param mesh Mesh to add
  44768. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44769. * @returns the Shadow Generator itself
  44770. */
  44771. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44772. /**
  44773. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44774. * @param mesh Mesh to remove
  44775. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44776. * @returns the Shadow Generator itself
  44777. */
  44778. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44779. /**
  44780. * Controls the extent to which the shadows fade out at the edge of the frustum
  44781. * Used only by directionals and spots
  44782. */
  44783. frustumEdgeFalloff: number;
  44784. private _light;
  44785. /**
  44786. * Returns the associated light object.
  44787. * @returns the light generating the shadow
  44788. */
  44789. getLight(): IShadowLight;
  44790. /**
  44791. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44792. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44793. * It might on the other hand introduce peter panning.
  44794. */
  44795. forceBackFacesOnly: boolean;
  44796. private _scene;
  44797. private _lightDirection;
  44798. private _effect;
  44799. private _viewMatrix;
  44800. private _projectionMatrix;
  44801. private _transformMatrix;
  44802. private _cachedPosition;
  44803. private _cachedDirection;
  44804. private _cachedDefines;
  44805. private _currentRenderID;
  44806. private _boxBlurPostprocess;
  44807. private _kernelBlurXPostprocess;
  44808. private _kernelBlurYPostprocess;
  44809. private _blurPostProcesses;
  44810. private _mapSize;
  44811. private _currentFaceIndex;
  44812. private _currentFaceIndexCache;
  44813. private _textureType;
  44814. private _defaultTextureMatrix;
  44815. /**
  44816. * Creates a ShadowGenerator object.
  44817. * A ShadowGenerator is the required tool to use the shadows.
  44818. * Each light casting shadows needs to use its own ShadowGenerator.
  44819. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  44820. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44821. * @param light The light object generating the shadows.
  44822. * @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.
  44823. */
  44824. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  44825. private _initializeGenerator;
  44826. private _initializeShadowMap;
  44827. private _initializeBlurRTTAndPostProcesses;
  44828. private _renderForShadowMap;
  44829. private _renderSubMeshForShadowMap;
  44830. private _applyFilterValues;
  44831. /**
  44832. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44833. * @param onCompiled Callback triggered at the and of the effects compilation
  44834. * @param options Sets of optional options forcing the compilation with different modes
  44835. */
  44836. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44837. useInstances: boolean;
  44838. }>): void;
  44839. /**
  44840. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44841. * @param options Sets of optional options forcing the compilation with different modes
  44842. * @returns A promise that resolves when the compilation completes
  44843. */
  44844. forceCompilationAsync(options?: Partial<{
  44845. useInstances: boolean;
  44846. }>): Promise<void>;
  44847. /**
  44848. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44849. * @param subMesh The submesh we want to render in the shadow map
  44850. * @param useInstances Defines wether will draw in the map using instances
  44851. * @returns true if ready otherwise, false
  44852. */
  44853. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44854. /**
  44855. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44856. * @param defines Defines of the material we want to update
  44857. * @param lightIndex Index of the light in the enabled light list of the material
  44858. */
  44859. prepareDefines(defines: any, lightIndex: number): void;
  44860. /**
  44861. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44862. * defined in the generator but impacting the effect).
  44863. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44864. * @param effect The effect we are binfing the information for
  44865. */
  44866. bindShadowLight(lightIndex: string, effect: Effect): void;
  44867. /**
  44868. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44869. * (eq to shadow prjection matrix * light transform matrix)
  44870. * @returns The transform matrix used to create the shadow map
  44871. */
  44872. getTransformMatrix(): Matrix;
  44873. /**
  44874. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44875. * Cube and 2D textures for instance.
  44876. */
  44877. recreateShadowMap(): void;
  44878. private _disposeBlurPostProcesses;
  44879. private _disposeRTTandPostProcesses;
  44880. /**
  44881. * Disposes the ShadowGenerator.
  44882. * Returns nothing.
  44883. */
  44884. dispose(): void;
  44885. /**
  44886. * Serializes the shadow generator setup to a json object.
  44887. * @returns The serialized JSON object
  44888. */
  44889. serialize(): any;
  44890. /**
  44891. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  44892. * @param parsedShadowGenerator The JSON object to parse
  44893. * @param scene The scene to create the shadow map for
  44894. * @returns The parsed shadow generator
  44895. */
  44896. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  44897. }
  44898. }
  44899. declare module BABYLON {
  44900. /**
  44901. * Defines the shadow generator component responsible to manage any shadow generators
  44902. * in a given scene.
  44903. */
  44904. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  44905. /**
  44906. * The component name helpfull to identify the component in the list of scene components.
  44907. */
  44908. readonly name: string;
  44909. /**
  44910. * The scene the component belongs to.
  44911. */
  44912. scene: Scene;
  44913. /**
  44914. * Creates a new instance of the component for the given scene
  44915. * @param scene Defines the scene to register the component in
  44916. */
  44917. constructor(scene: Scene);
  44918. /**
  44919. * Registers the component in a given scene
  44920. */
  44921. register(): void;
  44922. /**
  44923. * Rebuilds the elements related to this component in case of
  44924. * context lost for instance.
  44925. */
  44926. rebuild(): void;
  44927. /**
  44928. * Serializes the component data to the specified json object
  44929. * @param serializationObject The object to serialize to
  44930. */
  44931. serialize(serializationObject: any): void;
  44932. /**
  44933. * Adds all the element from the container to the scene
  44934. * @param container the container holding the elements
  44935. */
  44936. addFromContainer(container: AbstractScene): void;
  44937. /**
  44938. * Removes all the elements in the container from the scene
  44939. * @param container contains the elements to remove
  44940. */
  44941. removeFromContainer(container: AbstractScene): void;
  44942. /**
  44943. * Rebuilds the elements related to this component in case of
  44944. * context lost for instance.
  44945. */
  44946. dispose(): void;
  44947. private _gatherRenderTargets;
  44948. }
  44949. }
  44950. declare module BABYLON {
  44951. }
  44952. declare module BABYLON {
  44953. /**
  44954. * Background material used to create an efficient environement around your scene.
  44955. */
  44956. class BackgroundMaterial extends PushMaterial {
  44957. /**
  44958. * Standard reflectance value at parallel view angle.
  44959. */
  44960. static StandardReflectance0: number;
  44961. /**
  44962. * Standard reflectance value at grazing angle.
  44963. */
  44964. static StandardReflectance90: number;
  44965. protected _primaryColor: Color3;
  44966. /**
  44967. * Key light Color (multiply against the environement texture)
  44968. */
  44969. primaryColor: Color3;
  44970. protected __perceptualColor: Nullable<Color3>;
  44971. /**
  44972. * Experimental Internal Use Only.
  44973. *
  44974. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44975. * This acts as a helper to set the primary color to a more "human friendly" value.
  44976. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44977. * output color as close as possible from the chosen value.
  44978. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44979. * part of lighting setup.)
  44980. */
  44981. _perceptualColor: Nullable<Color3>;
  44982. protected _primaryColorShadowLevel: float;
  44983. /**
  44984. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44985. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44986. */
  44987. primaryColorShadowLevel: float;
  44988. protected _primaryColorHighlightLevel: float;
  44989. /**
  44990. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44991. * The primary color is used at the level chosen to define what the white area would look.
  44992. */
  44993. primaryColorHighlightLevel: float;
  44994. protected _reflectionTexture: Nullable<BaseTexture>;
  44995. /**
  44996. * Reflection Texture used in the material.
  44997. * Should be author in a specific way for the best result (refer to the documentation).
  44998. */
  44999. reflectionTexture: Nullable<BaseTexture>;
  45000. protected _reflectionBlur: float;
  45001. /**
  45002. * Reflection Texture level of blur.
  45003. *
  45004. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45005. * texture twice.
  45006. */
  45007. reflectionBlur: float;
  45008. protected _diffuseTexture: Nullable<BaseTexture>;
  45009. /**
  45010. * Diffuse Texture used in the material.
  45011. * Should be author in a specific way for the best result (refer to the documentation).
  45012. */
  45013. diffuseTexture: Nullable<BaseTexture>;
  45014. protected _shadowLights: Nullable<IShadowLight[]>;
  45015. /**
  45016. * Specify the list of lights casting shadow on the material.
  45017. * All scene shadow lights will be included if null.
  45018. */
  45019. shadowLights: Nullable<IShadowLight[]>;
  45020. protected _shadowLevel: float;
  45021. /**
  45022. * Helps adjusting the shadow to a softer level if required.
  45023. * 0 means black shadows and 1 means no shadows.
  45024. */
  45025. shadowLevel: float;
  45026. protected _sceneCenter: Vector3;
  45027. /**
  45028. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45029. * It is usually zero but might be interesting to modify according to your setup.
  45030. */
  45031. sceneCenter: Vector3;
  45032. protected _opacityFresnel: boolean;
  45033. /**
  45034. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45035. * This helps ensuring a nice transition when the camera goes under the ground.
  45036. */
  45037. opacityFresnel: boolean;
  45038. protected _reflectionFresnel: boolean;
  45039. /**
  45040. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45041. * This helps adding a mirror texture on the ground.
  45042. */
  45043. reflectionFresnel: boolean;
  45044. protected _reflectionFalloffDistance: number;
  45045. /**
  45046. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45047. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45048. */
  45049. reflectionFalloffDistance: number;
  45050. protected _reflectionAmount: number;
  45051. /**
  45052. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45053. */
  45054. reflectionAmount: number;
  45055. protected _reflectionReflectance0: number;
  45056. /**
  45057. * This specifies the weight of the reflection at grazing angle.
  45058. */
  45059. reflectionReflectance0: number;
  45060. protected _reflectionReflectance90: number;
  45061. /**
  45062. * This specifies the weight of the reflection at a perpendicular point of view.
  45063. */
  45064. reflectionReflectance90: number;
  45065. /**
  45066. * Sets the reflection reflectance fresnel values according to the default standard
  45067. * empirically know to work well :-)
  45068. */
  45069. reflectionStandardFresnelWeight: number;
  45070. protected _useRGBColor: boolean;
  45071. /**
  45072. * Helps to directly use the maps channels instead of their level.
  45073. */
  45074. useRGBColor: boolean;
  45075. protected _enableNoise: boolean;
  45076. /**
  45077. * This helps reducing the banding effect that could occur on the background.
  45078. */
  45079. enableNoise: boolean;
  45080. /**
  45081. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45082. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45083. * Recommended to be keep at 1.0 except for special cases.
  45084. */
  45085. fovMultiplier: number;
  45086. private _fovMultiplier;
  45087. /**
  45088. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45089. */
  45090. useEquirectangularFOV: boolean;
  45091. private _maxSimultaneousLights;
  45092. /**
  45093. * Number of Simultaneous lights allowed on the material.
  45094. */
  45095. maxSimultaneousLights: int;
  45096. /**
  45097. * Default configuration related to image processing available in the Background Material.
  45098. */
  45099. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45100. /**
  45101. * Keep track of the image processing observer to allow dispose and replace.
  45102. */
  45103. private _imageProcessingObserver;
  45104. /**
  45105. * Attaches a new image processing configuration to the PBR Material.
  45106. * @param configuration (if null the scene configuration will be use)
  45107. */
  45108. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45109. /**
  45110. * Gets the image processing configuration used either in this material.
  45111. */
  45112. /**
  45113. * Sets the Default image processing configuration used either in the this material.
  45114. *
  45115. * If sets to null, the scene one is in use.
  45116. */
  45117. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45118. /**
  45119. * Gets wether the color curves effect is enabled.
  45120. */
  45121. /**
  45122. * Sets wether the color curves effect is enabled.
  45123. */
  45124. cameraColorCurvesEnabled: boolean;
  45125. /**
  45126. * Gets wether the color grading effect is enabled.
  45127. */
  45128. /**
  45129. * Gets wether the color grading effect is enabled.
  45130. */
  45131. cameraColorGradingEnabled: boolean;
  45132. /**
  45133. * Gets wether tonemapping is enabled or not.
  45134. */
  45135. /**
  45136. * Sets wether tonemapping is enabled or not
  45137. */
  45138. cameraToneMappingEnabled: boolean;
  45139. /**
  45140. * The camera exposure used on this material.
  45141. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45142. * This corresponds to a photographic exposure.
  45143. */
  45144. /**
  45145. * The camera exposure used on this material.
  45146. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45147. * This corresponds to a photographic exposure.
  45148. */
  45149. cameraExposure: float;
  45150. /**
  45151. * Gets The camera contrast used on this material.
  45152. */
  45153. /**
  45154. * Sets The camera contrast used on this material.
  45155. */
  45156. cameraContrast: float;
  45157. /**
  45158. * Gets the Color Grading 2D Lookup Texture.
  45159. */
  45160. /**
  45161. * Sets the Color Grading 2D Lookup Texture.
  45162. */
  45163. cameraColorGradingTexture: Nullable<BaseTexture>;
  45164. /**
  45165. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45166. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45167. * 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;
  45168. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45169. */
  45170. /**
  45171. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45172. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45173. * 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;
  45174. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45175. */
  45176. cameraColorCurves: Nullable<ColorCurves>;
  45177. /**
  45178. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45179. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45180. */
  45181. switchToBGR: boolean;
  45182. private _renderTargets;
  45183. private _reflectionControls;
  45184. private _white;
  45185. private _primaryShadowColor;
  45186. private _primaryHighlightColor;
  45187. /**
  45188. * Instantiates a Background Material in the given scene
  45189. * @param name The friendly name of the material
  45190. * @param scene The scene to add the material to
  45191. */
  45192. constructor(name: string, scene: Scene);
  45193. /**
  45194. * Gets a boolean indicating that current material needs to register RTT
  45195. */
  45196. readonly hasRenderTargetTextures: boolean;
  45197. /**
  45198. * The entire material has been created in order to prevent overdraw.
  45199. * @returns false
  45200. */
  45201. needAlphaTesting(): boolean;
  45202. /**
  45203. * The entire material has been created in order to prevent overdraw.
  45204. * @returns true if blending is enable
  45205. */
  45206. needAlphaBlending(): boolean;
  45207. /**
  45208. * Checks wether the material is ready to be rendered for a given mesh.
  45209. * @param mesh The mesh to render
  45210. * @param subMesh The submesh to check against
  45211. * @param useInstances Specify wether or not the material is used with instances
  45212. * @returns true if all the dependencies are ready (Textures, Effects...)
  45213. */
  45214. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45215. /**
  45216. * Compute the primary color according to the chosen perceptual color.
  45217. */
  45218. private _computePrimaryColorFromPerceptualColor;
  45219. /**
  45220. * Compute the highlights and shadow colors according to their chosen levels.
  45221. */
  45222. private _computePrimaryColors;
  45223. /**
  45224. * Build the uniform buffer used in the material.
  45225. */
  45226. buildUniformLayout(): void;
  45227. /**
  45228. * Unbind the material.
  45229. */
  45230. unbind(): void;
  45231. /**
  45232. * Bind only the world matrix to the material.
  45233. * @param world The world matrix to bind.
  45234. */
  45235. bindOnlyWorldMatrix(world: Matrix): void;
  45236. /**
  45237. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45238. * @param world The world matrix to bind.
  45239. * @param subMesh The submesh to bind for.
  45240. */
  45241. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45242. /**
  45243. * Dispose the material.
  45244. * @param forceDisposeEffect Force disposal of the associated effect.
  45245. * @param forceDisposeTextures Force disposal of the associated textures.
  45246. */
  45247. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45248. /**
  45249. * Clones the material.
  45250. * @param name The cloned name.
  45251. * @returns The cloned material.
  45252. */
  45253. clone(name: string): BackgroundMaterial;
  45254. /**
  45255. * Serializes the current material to its JSON representation.
  45256. * @returns The JSON representation.
  45257. */
  45258. serialize(): any;
  45259. /**
  45260. * Gets the class name of the material
  45261. * @returns "BackgroundMaterial"
  45262. */
  45263. getClassName(): string;
  45264. /**
  45265. * Parse a JSON input to create back a background material.
  45266. * @param source The JSON data to parse
  45267. * @param scene The scene to create the parsed material in
  45268. * @param rootUrl The root url of the assets the material depends upon
  45269. * @returns the instantiated BackgroundMaterial.
  45270. */
  45271. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45272. }
  45273. }
  45274. declare module BABYLON {
  45275. /**
  45276. * The Physically based material base class of BJS.
  45277. *
  45278. * This offers the main features of a standard PBR material.
  45279. * For more information, please refer to the documentation :
  45280. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45281. */
  45282. abstract class PBRBaseMaterial extends PushMaterial {
  45283. /**
  45284. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45285. */
  45286. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45287. /**
  45288. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45289. * to enhance interoperability with other engines.
  45290. */
  45291. static readonly LIGHTFALLOFF_GLTF: number;
  45292. /**
  45293. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45294. * to enhance interoperability with other materials.
  45295. */
  45296. static readonly LIGHTFALLOFF_STANDARD: number;
  45297. /**
  45298. * Intensity of the direct lights e.g. the four lights available in your scene.
  45299. * This impacts both the direct diffuse and specular highlights.
  45300. */
  45301. protected _directIntensity: number;
  45302. /**
  45303. * Intensity of the emissive part of the material.
  45304. * This helps controlling the emissive effect without modifying the emissive color.
  45305. */
  45306. protected _emissiveIntensity: number;
  45307. /**
  45308. * Intensity of the environment e.g. how much the environment will light the object
  45309. * either through harmonics for rough material or through the refelction for shiny ones.
  45310. */
  45311. protected _environmentIntensity: number;
  45312. /**
  45313. * This is a special control allowing the reduction of the specular highlights coming from the
  45314. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45315. */
  45316. protected _specularIntensity: number;
  45317. /**
  45318. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45319. */
  45320. private _lightingInfos;
  45321. /**
  45322. * Debug Control allowing disabling the bump map on this material.
  45323. */
  45324. protected _disableBumpMap: boolean;
  45325. /**
  45326. * AKA Diffuse Texture in standard nomenclature.
  45327. */
  45328. protected _albedoTexture: BaseTexture;
  45329. /**
  45330. * AKA Occlusion Texture in other nomenclature.
  45331. */
  45332. protected _ambientTexture: BaseTexture;
  45333. /**
  45334. * AKA Occlusion Texture Intensity in other nomenclature.
  45335. */
  45336. protected _ambientTextureStrength: number;
  45337. /**
  45338. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45339. * 1 means it completely occludes it
  45340. * 0 mean it has no impact
  45341. */
  45342. protected _ambientTextureImpactOnAnalyticalLights: number;
  45343. /**
  45344. * Stores the alpha values in a texture.
  45345. */
  45346. protected _opacityTexture: BaseTexture;
  45347. /**
  45348. * Stores the reflection values in a texture.
  45349. */
  45350. protected _reflectionTexture: BaseTexture;
  45351. /**
  45352. * Stores the refraction values in a texture.
  45353. */
  45354. protected _refractionTexture: BaseTexture;
  45355. /**
  45356. * Stores the emissive values in a texture.
  45357. */
  45358. protected _emissiveTexture: BaseTexture;
  45359. /**
  45360. * AKA Specular texture in other nomenclature.
  45361. */
  45362. protected _reflectivityTexture: BaseTexture;
  45363. /**
  45364. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45365. */
  45366. protected _metallicTexture: BaseTexture;
  45367. /**
  45368. * Specifies the metallic scalar of the metallic/roughness workflow.
  45369. * Can also be used to scale the metalness values of the metallic texture.
  45370. */
  45371. protected _metallic: Nullable<number>;
  45372. /**
  45373. * Specifies the roughness scalar of the metallic/roughness workflow.
  45374. * Can also be used to scale the roughness values of the metallic texture.
  45375. */
  45376. protected _roughness: Nullable<number>;
  45377. /**
  45378. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45379. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45380. */
  45381. protected _microSurfaceTexture: BaseTexture;
  45382. /**
  45383. * Stores surface normal data used to displace a mesh in a texture.
  45384. */
  45385. protected _bumpTexture: BaseTexture;
  45386. /**
  45387. * Stores the pre-calculated light information of a mesh in a texture.
  45388. */
  45389. protected _lightmapTexture: BaseTexture;
  45390. /**
  45391. * The color of a material in ambient lighting.
  45392. */
  45393. protected _ambientColor: Color3;
  45394. /**
  45395. * AKA Diffuse Color in other nomenclature.
  45396. */
  45397. protected _albedoColor: Color3;
  45398. /**
  45399. * AKA Specular Color in other nomenclature.
  45400. */
  45401. protected _reflectivityColor: Color3;
  45402. /**
  45403. * The color applied when light is reflected from a material.
  45404. */
  45405. protected _reflectionColor: Color3;
  45406. /**
  45407. * The color applied when light is emitted from a material.
  45408. */
  45409. protected _emissiveColor: Color3;
  45410. /**
  45411. * AKA Glossiness in other nomenclature.
  45412. */
  45413. protected _microSurface: number;
  45414. /**
  45415. * source material index of refraction (IOR)' / 'destination material IOR.
  45416. */
  45417. protected _indexOfRefraction: number;
  45418. /**
  45419. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45420. */
  45421. protected _invertRefractionY: boolean;
  45422. /**
  45423. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45424. * Materials half opaque for instance using refraction could benefit from this control.
  45425. */
  45426. protected _linkRefractionWithTransparency: boolean;
  45427. /**
  45428. * Specifies that the material will use the light map as a show map.
  45429. */
  45430. protected _useLightmapAsShadowmap: boolean;
  45431. /**
  45432. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45433. * makes the reflect vector face the model (under horizon).
  45434. */
  45435. protected _useHorizonOcclusion: boolean;
  45436. /**
  45437. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45438. * too much the area relying on ambient texture to define their ambient occlusion.
  45439. */
  45440. protected _useRadianceOcclusion: boolean;
  45441. /**
  45442. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45443. */
  45444. protected _useAlphaFromAlbedoTexture: boolean;
  45445. /**
  45446. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45447. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45448. */
  45449. protected _useSpecularOverAlpha: boolean;
  45450. /**
  45451. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45452. */
  45453. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45454. /**
  45455. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45456. */
  45457. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45458. /**
  45459. * Specifies if the metallic texture contains the roughness information in its green channel.
  45460. */
  45461. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45462. /**
  45463. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45464. */
  45465. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45466. /**
  45467. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45468. */
  45469. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45470. /**
  45471. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45472. */
  45473. protected _useAmbientInGrayScale: boolean;
  45474. /**
  45475. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45476. * The material will try to infer what glossiness each pixel should be.
  45477. */
  45478. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45479. /**
  45480. * Defines the falloff type used in this material.
  45481. * It by default is Physical.
  45482. */
  45483. protected _lightFalloff: number;
  45484. /**
  45485. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45486. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45487. */
  45488. protected _useRadianceOverAlpha: boolean;
  45489. /**
  45490. * Allows using an object space normal map (instead of tangent space).
  45491. */
  45492. protected _useObjectSpaceNormalMap: boolean;
  45493. /**
  45494. * Allows using the bump map in parallax mode.
  45495. */
  45496. protected _useParallax: boolean;
  45497. /**
  45498. * Allows using the bump map in parallax occlusion mode.
  45499. */
  45500. protected _useParallaxOcclusion: boolean;
  45501. /**
  45502. * Controls the scale bias of the parallax mode.
  45503. */
  45504. protected _parallaxScaleBias: number;
  45505. /**
  45506. * If sets to true, disables all the lights affecting the material.
  45507. */
  45508. protected _disableLighting: boolean;
  45509. /**
  45510. * Number of Simultaneous lights allowed on the material.
  45511. */
  45512. protected _maxSimultaneousLights: number;
  45513. /**
  45514. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45515. */
  45516. protected _invertNormalMapX: boolean;
  45517. /**
  45518. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45519. */
  45520. protected _invertNormalMapY: boolean;
  45521. /**
  45522. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45523. */
  45524. protected _twoSidedLighting: boolean;
  45525. /**
  45526. * Defines the alpha limits in alpha test mode.
  45527. */
  45528. protected _alphaCutOff: number;
  45529. /**
  45530. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45531. */
  45532. protected _forceAlphaTest: boolean;
  45533. /**
  45534. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45535. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45536. */
  45537. protected _useAlphaFresnel: boolean;
  45538. /**
  45539. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45540. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45541. */
  45542. protected _useLinearAlphaFresnel: boolean;
  45543. /**
  45544. * The transparency mode of the material.
  45545. */
  45546. protected _transparencyMode: Nullable<number>;
  45547. /**
  45548. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45549. * from cos thetav and roughness:
  45550. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45551. */
  45552. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45553. /**
  45554. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45555. */
  45556. protected _forceIrradianceInFragment: boolean;
  45557. /**
  45558. * Force normal to face away from face.
  45559. */
  45560. protected _forceNormalForward: boolean;
  45561. /**
  45562. * Enables specular anti aliasing in the PBR shader.
  45563. * It will both interacts on the Geometry for analytical and IBL lighting.
  45564. * It also prefilter the roughness map based on the bump values.
  45565. */
  45566. protected _enableSpecularAntiAliasing: boolean;
  45567. /**
  45568. * Default configuration related to image processing available in the PBR Material.
  45569. */
  45570. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45571. /**
  45572. * Keep track of the image processing observer to allow dispose and replace.
  45573. */
  45574. private _imageProcessingObserver;
  45575. /**
  45576. * Attaches a new image processing configuration to the PBR Material.
  45577. * @param configuration
  45578. */
  45579. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45580. /**
  45581. * Stores the available render targets.
  45582. */
  45583. private _renderTargets;
  45584. /**
  45585. * Sets the global ambient color for the material used in lighting calculations.
  45586. */
  45587. private _globalAmbientColor;
  45588. /**
  45589. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45590. */
  45591. private _useLogarithmicDepth;
  45592. /**
  45593. * If set to true, no lighting calculations will be applied.
  45594. */
  45595. private _unlit;
  45596. /**
  45597. * Instantiates a new PBRMaterial instance.
  45598. *
  45599. * @param name The material name
  45600. * @param scene The scene the material will be use in.
  45601. */
  45602. constructor(name: string, scene: Scene);
  45603. /**
  45604. * Gets a boolean indicating that current material needs to register RTT
  45605. */
  45606. readonly hasRenderTargetTextures: boolean;
  45607. /**
  45608. * Gets the name of the material class.
  45609. */
  45610. getClassName(): string;
  45611. /**
  45612. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45613. */
  45614. /**
  45615. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45616. */
  45617. useLogarithmicDepth: boolean;
  45618. /**
  45619. * Gets the current transparency mode.
  45620. */
  45621. /**
  45622. * Sets the transparency mode of the material.
  45623. *
  45624. * | Value | Type | Description |
  45625. * | ----- | ----------------------------------- | ----------- |
  45626. * | 0 | OPAQUE | |
  45627. * | 1 | ALPHATEST | |
  45628. * | 2 | ALPHABLEND | |
  45629. * | 3 | ALPHATESTANDBLEND | |
  45630. *
  45631. */
  45632. transparencyMode: Nullable<number>;
  45633. /**
  45634. * Returns true if alpha blending should be disabled.
  45635. */
  45636. private readonly _disableAlphaBlending;
  45637. /**
  45638. * Specifies whether or not this material should be rendered in alpha blend mode.
  45639. */
  45640. needAlphaBlending(): boolean;
  45641. /**
  45642. * Specifies if the mesh will require alpha blending.
  45643. * @param mesh - BJS mesh.
  45644. */
  45645. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45646. /**
  45647. * Specifies whether or not this material should be rendered in alpha test mode.
  45648. */
  45649. needAlphaTesting(): boolean;
  45650. /**
  45651. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45652. */
  45653. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45654. /**
  45655. * Gets the texture used for the alpha test.
  45656. */
  45657. getAlphaTestTexture(): BaseTexture;
  45658. /**
  45659. * Stores the reflectivity values based on metallic roughness workflow.
  45660. */
  45661. private static _scaledReflectivity;
  45662. /**
  45663. * Specifies that the submesh is ready to be used.
  45664. * @param mesh - BJS mesh.
  45665. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45666. * @param useInstances - Specifies that instances should be used.
  45667. * @returns - boolean indicating that the submesh is ready or not.
  45668. */
  45669. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45670. /**
  45671. * Specifies if the material uses metallic roughness workflow.
  45672. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45673. */
  45674. isMetallicWorkflow(): boolean;
  45675. private _prepareEffect;
  45676. private _prepareDefines;
  45677. /**
  45678. * Force shader compilation
  45679. */
  45680. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45681. clipPlane: boolean;
  45682. }>): void;
  45683. /**
  45684. * Initializes the uniform buffer layout for the shader.
  45685. */
  45686. buildUniformLayout(): void;
  45687. /**
  45688. * Unbinds the textures.
  45689. */
  45690. unbind(): void;
  45691. /**
  45692. * Binds the submesh data.
  45693. * @param world - The world matrix.
  45694. * @param mesh - The BJS mesh.
  45695. * @param subMesh - A submesh of the BJS mesh.
  45696. */
  45697. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45698. /**
  45699. * Returns the animatable textures.
  45700. * @returns - Array of animatable textures.
  45701. */
  45702. getAnimatables(): IAnimatable[];
  45703. /**
  45704. * Returns the texture used for reflections.
  45705. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45706. */
  45707. private _getReflectionTexture;
  45708. /**
  45709. * Returns the texture used for refraction or null if none is used.
  45710. * @returns - Refection texture if present. If no refraction texture and refraction
  45711. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45712. */
  45713. private _getRefractionTexture;
  45714. /**
  45715. * Disposes the resources of the material.
  45716. * @param forceDisposeEffect - Forces the disposal of effects.
  45717. * @param forceDisposeTextures - Forces the disposal of all textures.
  45718. */
  45719. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45720. }
  45721. }
  45722. declare module BABYLON {
  45723. /**
  45724. * The Physically based simple base material of BJS.
  45725. *
  45726. * This enables better naming and convention enforcements on top of the pbrMaterial.
  45727. * It is used as the base class for both the specGloss and metalRough conventions.
  45728. */
  45729. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  45730. /**
  45731. * Number of Simultaneous lights allowed on the material.
  45732. */
  45733. maxSimultaneousLights: number;
  45734. /**
  45735. * If sets to true, disables all the lights affecting the material.
  45736. */
  45737. disableLighting: boolean;
  45738. /**
  45739. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  45740. */
  45741. environmentTexture: BaseTexture;
  45742. /**
  45743. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45744. */
  45745. invertNormalMapX: boolean;
  45746. /**
  45747. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45748. */
  45749. invertNormalMapY: boolean;
  45750. /**
  45751. * Normal map used in the model.
  45752. */
  45753. normalTexture: BaseTexture;
  45754. /**
  45755. * Emissivie color used to self-illuminate the model.
  45756. */
  45757. emissiveColor: Color3;
  45758. /**
  45759. * Emissivie texture used to self-illuminate the model.
  45760. */
  45761. emissiveTexture: BaseTexture;
  45762. /**
  45763. * Occlusion Channel Strenght.
  45764. */
  45765. occlusionStrength: number;
  45766. /**
  45767. * Occlusion Texture of the material (adding extra occlusion effects).
  45768. */
  45769. occlusionTexture: BaseTexture;
  45770. /**
  45771. * Defines the alpha limits in alpha test mode.
  45772. */
  45773. alphaCutOff: number;
  45774. /**
  45775. * Gets the current double sided mode.
  45776. */
  45777. /**
  45778. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45779. */
  45780. doubleSided: boolean;
  45781. /**
  45782. * Stores the pre-calculated light information of a mesh in a texture.
  45783. */
  45784. lightmapTexture: BaseTexture;
  45785. /**
  45786. * If true, the light map contains occlusion information instead of lighting info.
  45787. */
  45788. useLightmapAsShadowmap: boolean;
  45789. /**
  45790. * Return the active textures of the material.
  45791. */
  45792. getActiveTextures(): BaseTexture[];
  45793. hasTexture(texture: BaseTexture): boolean;
  45794. /**
  45795. * Instantiates a new PBRMaterial instance.
  45796. *
  45797. * @param name The material name
  45798. * @param scene The scene the material will be use in.
  45799. */
  45800. constructor(name: string, scene: Scene);
  45801. getClassName(): string;
  45802. }
  45803. }
  45804. declare module BABYLON {
  45805. /**
  45806. * The Physically based material of BJS.
  45807. *
  45808. * This offers the main features of a standard PBR material.
  45809. * For more information, please refer to the documentation :
  45810. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45811. */
  45812. class PBRMaterial extends PBRBaseMaterial {
  45813. /**
  45814. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45815. */
  45816. static readonly PBRMATERIAL_OPAQUE: number;
  45817. /**
  45818. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45819. */
  45820. static readonly PBRMATERIAL_ALPHATEST: number;
  45821. /**
  45822. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45823. */
  45824. static readonly PBRMATERIAL_ALPHABLEND: number;
  45825. /**
  45826. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45827. * They are also discarded below the alpha cutoff threshold to improve performances.
  45828. */
  45829. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45830. /**
  45831. * Defines the default value of how much AO map is occluding the analytical lights
  45832. * (point spot...).
  45833. */
  45834. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45835. /**
  45836. * Intensity of the direct lights e.g. the four lights available in your scene.
  45837. * This impacts both the direct diffuse and specular highlights.
  45838. */
  45839. directIntensity: number;
  45840. /**
  45841. * Intensity of the emissive part of the material.
  45842. * This helps controlling the emissive effect without modifying the emissive color.
  45843. */
  45844. emissiveIntensity: number;
  45845. /**
  45846. * Intensity of the environment e.g. how much the environment will light the object
  45847. * either through harmonics for rough material or through the refelction for shiny ones.
  45848. */
  45849. environmentIntensity: number;
  45850. /**
  45851. * This is a special control allowing the reduction of the specular highlights coming from the
  45852. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45853. */
  45854. specularIntensity: number;
  45855. /**
  45856. * Debug Control allowing disabling the bump map on this material.
  45857. */
  45858. disableBumpMap: boolean;
  45859. /**
  45860. * AKA Diffuse Texture in standard nomenclature.
  45861. */
  45862. albedoTexture: BaseTexture;
  45863. /**
  45864. * AKA Occlusion Texture in other nomenclature.
  45865. */
  45866. ambientTexture: BaseTexture;
  45867. /**
  45868. * AKA Occlusion Texture Intensity in other nomenclature.
  45869. */
  45870. ambientTextureStrength: number;
  45871. /**
  45872. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45873. * 1 means it completely occludes it
  45874. * 0 mean it has no impact
  45875. */
  45876. ambientTextureImpactOnAnalyticalLights: number;
  45877. /**
  45878. * Stores the alpha values in a texture.
  45879. */
  45880. opacityTexture: BaseTexture;
  45881. /**
  45882. * Stores the reflection values in a texture.
  45883. */
  45884. reflectionTexture: Nullable<BaseTexture>;
  45885. /**
  45886. * Stores the emissive values in a texture.
  45887. */
  45888. emissiveTexture: BaseTexture;
  45889. /**
  45890. * AKA Specular texture in other nomenclature.
  45891. */
  45892. reflectivityTexture: BaseTexture;
  45893. /**
  45894. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45895. */
  45896. metallicTexture: BaseTexture;
  45897. /**
  45898. * Specifies the metallic scalar of the metallic/roughness workflow.
  45899. * Can also be used to scale the metalness values of the metallic texture.
  45900. */
  45901. metallic: Nullable<number>;
  45902. /**
  45903. * Specifies the roughness scalar of the metallic/roughness workflow.
  45904. * Can also be used to scale the roughness values of the metallic texture.
  45905. */
  45906. roughness: Nullable<number>;
  45907. /**
  45908. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45909. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45910. */
  45911. microSurfaceTexture: BaseTexture;
  45912. /**
  45913. * Stores surface normal data used to displace a mesh in a texture.
  45914. */
  45915. bumpTexture: BaseTexture;
  45916. /**
  45917. * Stores the pre-calculated light information of a mesh in a texture.
  45918. */
  45919. lightmapTexture: BaseTexture;
  45920. /**
  45921. * Stores the refracted light information in a texture.
  45922. */
  45923. refractionTexture: BaseTexture;
  45924. /**
  45925. * The color of a material in ambient lighting.
  45926. */
  45927. ambientColor: Color3;
  45928. /**
  45929. * AKA Diffuse Color in other nomenclature.
  45930. */
  45931. albedoColor: Color3;
  45932. /**
  45933. * AKA Specular Color in other nomenclature.
  45934. */
  45935. reflectivityColor: Color3;
  45936. /**
  45937. * The color reflected from the material.
  45938. */
  45939. reflectionColor: Color3;
  45940. /**
  45941. * The color emitted from the material.
  45942. */
  45943. emissiveColor: Color3;
  45944. /**
  45945. * AKA Glossiness in other nomenclature.
  45946. */
  45947. microSurface: number;
  45948. /**
  45949. * source material index of refraction (IOR)' / 'destination material IOR.
  45950. */
  45951. indexOfRefraction: number;
  45952. /**
  45953. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45954. */
  45955. invertRefractionY: boolean;
  45956. /**
  45957. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45958. * Materials half opaque for instance using refraction could benefit from this control.
  45959. */
  45960. linkRefractionWithTransparency: boolean;
  45961. /**
  45962. * If true, the light map contains occlusion information instead of lighting info.
  45963. */
  45964. useLightmapAsShadowmap: boolean;
  45965. /**
  45966. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45967. */
  45968. useAlphaFromAlbedoTexture: boolean;
  45969. /**
  45970. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45971. */
  45972. forceAlphaTest: boolean;
  45973. /**
  45974. * Defines the alpha limits in alpha test mode.
  45975. */
  45976. alphaCutOff: number;
  45977. /**
  45978. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45979. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45980. */
  45981. useSpecularOverAlpha: boolean;
  45982. /**
  45983. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45984. */
  45985. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45986. /**
  45987. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45988. */
  45989. useRoughnessFromMetallicTextureAlpha: boolean;
  45990. /**
  45991. * Specifies if the metallic texture contains the roughness information in its green channel.
  45992. */
  45993. useRoughnessFromMetallicTextureGreen: boolean;
  45994. /**
  45995. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45996. */
  45997. useMetallnessFromMetallicTextureBlue: boolean;
  45998. /**
  45999. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46000. */
  46001. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46002. /**
  46003. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46004. */
  46005. useAmbientInGrayScale: boolean;
  46006. /**
  46007. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46008. * The material will try to infer what glossiness each pixel should be.
  46009. */
  46010. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46011. /**
  46012. * BJS is using an harcoded light falloff based on a manually sets up range.
  46013. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46014. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46015. */
  46016. /**
  46017. * BJS is using an harcoded light falloff based on a manually sets up range.
  46018. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46019. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46020. */
  46021. usePhysicalLightFalloff: boolean;
  46022. /**
  46023. * In order to support the falloff compatibility with gltf, a special mode has been added
  46024. * to reproduce the gltf light falloff.
  46025. */
  46026. /**
  46027. * In order to support the falloff compatibility with gltf, a special mode has been added
  46028. * to reproduce the gltf light falloff.
  46029. */
  46030. useGLTFLightFalloff: boolean;
  46031. /**
  46032. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46033. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46034. */
  46035. useRadianceOverAlpha: boolean;
  46036. /**
  46037. * Allows using an object space normal map (instead of tangent space).
  46038. */
  46039. useObjectSpaceNormalMap: boolean;
  46040. /**
  46041. * Allows using the bump map in parallax mode.
  46042. */
  46043. useParallax: boolean;
  46044. /**
  46045. * Allows using the bump map in parallax occlusion mode.
  46046. */
  46047. useParallaxOcclusion: boolean;
  46048. /**
  46049. * Controls the scale bias of the parallax mode.
  46050. */
  46051. parallaxScaleBias: number;
  46052. /**
  46053. * If sets to true, disables all the lights affecting the material.
  46054. */
  46055. disableLighting: boolean;
  46056. /**
  46057. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46058. */
  46059. forceIrradianceInFragment: boolean;
  46060. /**
  46061. * Number of Simultaneous lights allowed on the material.
  46062. */
  46063. maxSimultaneousLights: number;
  46064. /**
  46065. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46066. */
  46067. invertNormalMapX: boolean;
  46068. /**
  46069. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46070. */
  46071. invertNormalMapY: boolean;
  46072. /**
  46073. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46074. */
  46075. twoSidedLighting: boolean;
  46076. /**
  46077. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46078. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46079. */
  46080. useAlphaFresnel: boolean;
  46081. /**
  46082. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46083. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46084. */
  46085. useLinearAlphaFresnel: boolean;
  46086. /**
  46087. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46088. * And/Or occlude the blended part.
  46089. */
  46090. environmentBRDFTexture: Nullable<BaseTexture>;
  46091. /**
  46092. * Force normal to face away from face.
  46093. */
  46094. forceNormalForward: boolean;
  46095. /**
  46096. * Enables specular anti aliasing in the PBR shader.
  46097. * It will both interacts on the Geometry for analytical and IBL lighting.
  46098. * It also prefilter the roughness map based on the bump values.
  46099. */
  46100. enableSpecularAntiAliasing: boolean;
  46101. /**
  46102. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46103. * makes the reflect vector face the model (under horizon).
  46104. */
  46105. useHorizonOcclusion: boolean;
  46106. /**
  46107. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46108. * too much the area relying on ambient texture to define their ambient occlusion.
  46109. */
  46110. useRadianceOcclusion: boolean;
  46111. /**
  46112. * If set to true, no lighting calculations will be applied.
  46113. */
  46114. unlit: boolean;
  46115. /**
  46116. * Gets the image processing configuration used either in this material.
  46117. */
  46118. /**
  46119. * Sets the Default image processing configuration used either in the this material.
  46120. *
  46121. * If sets to null, the scene one is in use.
  46122. */
  46123. imageProcessingConfiguration: ImageProcessingConfiguration;
  46124. /**
  46125. * Gets wether the color curves effect is enabled.
  46126. */
  46127. /**
  46128. * Sets wether the color curves effect is enabled.
  46129. */
  46130. cameraColorCurvesEnabled: boolean;
  46131. /**
  46132. * Gets wether the color grading effect is enabled.
  46133. */
  46134. /**
  46135. * Gets wether the color grading effect is enabled.
  46136. */
  46137. cameraColorGradingEnabled: boolean;
  46138. /**
  46139. * Gets wether tonemapping is enabled or not.
  46140. */
  46141. /**
  46142. * Sets wether tonemapping is enabled or not
  46143. */
  46144. cameraToneMappingEnabled: boolean;
  46145. /**
  46146. * The camera exposure used on this material.
  46147. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46148. * This corresponds to a photographic exposure.
  46149. */
  46150. /**
  46151. * The camera exposure used on this material.
  46152. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46153. * This corresponds to a photographic exposure.
  46154. */
  46155. cameraExposure: number;
  46156. /**
  46157. * Gets The camera contrast used on this material.
  46158. */
  46159. /**
  46160. * Sets The camera contrast used on this material.
  46161. */
  46162. cameraContrast: number;
  46163. /**
  46164. * Gets the Color Grading 2D Lookup Texture.
  46165. */
  46166. /**
  46167. * Sets the Color Grading 2D Lookup Texture.
  46168. */
  46169. cameraColorGradingTexture: Nullable<BaseTexture>;
  46170. /**
  46171. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46172. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46173. * 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;
  46174. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46175. */
  46176. /**
  46177. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46178. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46179. * 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;
  46180. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46181. */
  46182. cameraColorCurves: Nullable<ColorCurves>;
  46183. /**
  46184. * Instantiates a new PBRMaterial instance.
  46185. *
  46186. * @param name The material name
  46187. * @param scene The scene the material will be use in.
  46188. */
  46189. constructor(name: string, scene: Scene);
  46190. /**
  46191. * Returns the name of this material class.
  46192. */
  46193. getClassName(): string;
  46194. /**
  46195. * Returns an array of the actively used textures.
  46196. * @returns - Array of BaseTextures
  46197. */
  46198. getActiveTextures(): BaseTexture[];
  46199. /**
  46200. * Checks to see if a texture is used in the material.
  46201. * @param texture - Base texture to use.
  46202. * @returns - Boolean specifying if a texture is used in the material.
  46203. */
  46204. hasTexture(texture: BaseTexture): boolean;
  46205. /**
  46206. * Makes a duplicate of the current material.
  46207. * @param name - name to use for the new material.
  46208. */
  46209. clone(name: string): PBRMaterial;
  46210. /**
  46211. * Serializes this PBR Material.
  46212. * @returns - An object with the serialized material.
  46213. */
  46214. serialize(): any;
  46215. /**
  46216. * Parses a PBR Material from a serialized object.
  46217. * @param source - Serialized object.
  46218. * @param scene - BJS scene instance.
  46219. * @param rootUrl - url for the scene object
  46220. * @returns - PBRMaterial
  46221. */
  46222. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46223. }
  46224. }
  46225. declare module BABYLON {
  46226. /**
  46227. * The PBR material of BJS following the metal roughness convention.
  46228. *
  46229. * This fits to the PBR convention in the GLTF definition:
  46230. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  46231. */
  46232. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  46233. /**
  46234. * The base color has two different interpretations depending on the value of metalness.
  46235. * When the material is a metal, the base color is the specific measured reflectance value
  46236. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  46237. * of the material.
  46238. */
  46239. baseColor: Color3;
  46240. /**
  46241. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  46242. * well as opacity information in the alpha channel.
  46243. */
  46244. baseTexture: BaseTexture;
  46245. /**
  46246. * Specifies the metallic scalar value of the material.
  46247. * Can also be used to scale the metalness values of the metallic texture.
  46248. */
  46249. metallic: number;
  46250. /**
  46251. * Specifies the roughness scalar value of the material.
  46252. * Can also be used to scale the roughness values of the metallic texture.
  46253. */
  46254. roughness: number;
  46255. /**
  46256. * Texture containing both the metallic value in the B channel and the
  46257. * roughness value in the G channel to keep better precision.
  46258. */
  46259. metallicRoughnessTexture: BaseTexture;
  46260. /**
  46261. * Instantiates a new PBRMetalRoughnessMaterial instance.
  46262. *
  46263. * @param name The material name
  46264. * @param scene The scene the material will be use in.
  46265. */
  46266. constructor(name: string, scene: Scene);
  46267. /**
  46268. * Return the currrent class name of the material.
  46269. */
  46270. getClassName(): string;
  46271. /**
  46272. * Return the active textures of the material.
  46273. */
  46274. getActiveTextures(): BaseTexture[];
  46275. /**
  46276. * Checks to see if a texture is used in the material.
  46277. * @param texture - Base texture to use.
  46278. * @returns - Boolean specifying if a texture is used in the material.
  46279. */
  46280. hasTexture(texture: BaseTexture): boolean;
  46281. /**
  46282. * Makes a duplicate of the current material.
  46283. * @param name - name to use for the new material.
  46284. */
  46285. clone(name: string): PBRMetallicRoughnessMaterial;
  46286. /**
  46287. * Serialize the material to a parsable JSON object.
  46288. */
  46289. serialize(): any;
  46290. /**
  46291. * Parses a JSON object correponding to the serialize function.
  46292. */
  46293. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  46294. }
  46295. }
  46296. declare module BABYLON {
  46297. /**
  46298. * The PBR material of BJS following the specular glossiness convention.
  46299. *
  46300. * This fits to the PBR convention in the GLTF definition:
  46301. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  46302. */
  46303. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  46304. /**
  46305. * Specifies the diffuse color of the material.
  46306. */
  46307. diffuseColor: Color3;
  46308. /**
  46309. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  46310. * channel.
  46311. */
  46312. diffuseTexture: BaseTexture;
  46313. /**
  46314. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  46315. */
  46316. specularColor: Color3;
  46317. /**
  46318. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  46319. */
  46320. glossiness: number;
  46321. /**
  46322. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  46323. */
  46324. specularGlossinessTexture: BaseTexture;
  46325. /**
  46326. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  46327. *
  46328. * @param name The material name
  46329. * @param scene The scene the material will be use in.
  46330. */
  46331. constructor(name: string, scene: Scene);
  46332. /**
  46333. * Return the currrent class name of the material.
  46334. */
  46335. getClassName(): string;
  46336. /**
  46337. * Return the active textures of the material.
  46338. */
  46339. getActiveTextures(): BaseTexture[];
  46340. /**
  46341. * Checks to see if a texture is used in the material.
  46342. * @param texture - Base texture to use.
  46343. * @returns - Boolean specifying if a texture is used in the material.
  46344. */
  46345. hasTexture(texture: BaseTexture): boolean;
  46346. /**
  46347. * Makes a duplicate of the current material.
  46348. * @param name - name to use for the new material.
  46349. */
  46350. clone(name: string): PBRSpecularGlossinessMaterial;
  46351. /**
  46352. * Serialize the material to a parsable JSON object.
  46353. */
  46354. serialize(): any;
  46355. /**
  46356. * Parses a JSON object correponding to the serialize function.
  46357. */
  46358. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  46359. }
  46360. }
  46361. declare module BABYLON {
  46362. /**
  46363. * Base class of all the textures in babylon.
  46364. * It groups all the common properties the materials, post process, lights... might need
  46365. * in order to make a correct use of the texture.
  46366. */
  46367. class BaseTexture {
  46368. /**
  46369. * Default anisotropic filtering level for the application.
  46370. * It is set to 4 as a good tradeoff between perf and quality.
  46371. */
  46372. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  46373. /**
  46374. * Gets or sets the unique id of the texture
  46375. */
  46376. uniqueId: number;
  46377. /**
  46378. * Define the name of the texture.
  46379. */
  46380. name: string;
  46381. /**
  46382. * Gets or sets an object used to store user defined information.
  46383. */
  46384. metadata: any;
  46385. /**
  46386. * For internal use only. Please do not use.
  46387. */
  46388. reservedDataStore: any;
  46389. private _hasAlpha;
  46390. /**
  46391. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  46392. */
  46393. hasAlpha: boolean;
  46394. /**
  46395. * Defines if the alpha value should be determined via the rgb values.
  46396. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  46397. */
  46398. getAlphaFromRGB: boolean;
  46399. /**
  46400. * Intensity or strength of the texture.
  46401. * It is commonly used by materials to fine tune the intensity of the texture
  46402. */
  46403. level: number;
  46404. /**
  46405. * Define the UV chanel to use starting from 0 and defaulting to 0.
  46406. * This is part of the texture as textures usually maps to one uv set.
  46407. */
  46408. coordinatesIndex: number;
  46409. private _coordinatesMode;
  46410. /**
  46411. * How a texture is mapped.
  46412. *
  46413. * | Value | Type | Description |
  46414. * | ----- | ----------------------------------- | ----------- |
  46415. * | 0 | EXPLICIT_MODE | |
  46416. * | 1 | SPHERICAL_MODE | |
  46417. * | 2 | PLANAR_MODE | |
  46418. * | 3 | CUBIC_MODE | |
  46419. * | 4 | PROJECTION_MODE | |
  46420. * | 5 | SKYBOX_MODE | |
  46421. * | 6 | INVCUBIC_MODE | |
  46422. * | 7 | EQUIRECTANGULAR_MODE | |
  46423. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  46424. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  46425. */
  46426. coordinatesMode: number;
  46427. /**
  46428. * | Value | Type | Description |
  46429. * | ----- | ------------------ | ----------- |
  46430. * | 0 | CLAMP_ADDRESSMODE | |
  46431. * | 1 | WRAP_ADDRESSMODE | |
  46432. * | 2 | MIRROR_ADDRESSMODE | |
  46433. */
  46434. wrapU: number;
  46435. /**
  46436. * | Value | Type | Description |
  46437. * | ----- | ------------------ | ----------- |
  46438. * | 0 | CLAMP_ADDRESSMODE | |
  46439. * | 1 | WRAP_ADDRESSMODE | |
  46440. * | 2 | MIRROR_ADDRESSMODE | |
  46441. */
  46442. wrapV: number;
  46443. /**
  46444. * | Value | Type | Description |
  46445. * | ----- | ------------------ | ----------- |
  46446. * | 0 | CLAMP_ADDRESSMODE | |
  46447. * | 1 | WRAP_ADDRESSMODE | |
  46448. * | 2 | MIRROR_ADDRESSMODE | |
  46449. */
  46450. wrapR: number;
  46451. /**
  46452. * With compliant hardware and browser (supporting anisotropic filtering)
  46453. * this defines the level of anisotropic filtering in the texture.
  46454. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  46455. */
  46456. anisotropicFilteringLevel: number;
  46457. /**
  46458. * Define if the texture is a cube texture or if false a 2d texture.
  46459. */
  46460. isCube: boolean;
  46461. /**
  46462. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  46463. */
  46464. is3D: boolean;
  46465. /**
  46466. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  46467. * HDR texture are usually stored in linear space.
  46468. * This only impacts the PBR and Background materials
  46469. */
  46470. gammaSpace: boolean;
  46471. /**
  46472. * Gets whether or not the texture contains RGBD data.
  46473. */
  46474. readonly isRGBD: boolean;
  46475. /**
  46476. * Is Z inverted in the texture (useful in a cube texture).
  46477. */
  46478. invertZ: boolean;
  46479. /**
  46480. * Are mip maps generated for this texture or not.
  46481. */
  46482. readonly noMipmap: boolean;
  46483. /**
  46484. * @hidden
  46485. */
  46486. lodLevelInAlpha: boolean;
  46487. /**
  46488. * With prefiltered texture, defined the offset used during the prefiltering steps.
  46489. */
  46490. lodGenerationOffset: number;
  46491. /**
  46492. * With prefiltered texture, defined the scale used during the prefiltering steps.
  46493. */
  46494. lodGenerationScale: number;
  46495. /**
  46496. * Define if the texture is a render target.
  46497. */
  46498. isRenderTarget: boolean;
  46499. /**
  46500. * Define the unique id of the texture in the scene.
  46501. */
  46502. readonly uid: string;
  46503. /**
  46504. * Return a string representation of the texture.
  46505. * @returns the texture as a string
  46506. */
  46507. toString(): string;
  46508. /**
  46509. * Get the class name of the texture.
  46510. * @returns "BaseTexture"
  46511. */
  46512. getClassName(): string;
  46513. /**
  46514. * Define the list of animation attached to the texture.
  46515. */
  46516. animations: Animation[];
  46517. /**
  46518. * An event triggered when the texture is disposed.
  46519. */
  46520. onDisposeObservable: Observable<BaseTexture>;
  46521. private _onDisposeObserver;
  46522. /**
  46523. * Callback triggered when the texture has been disposed.
  46524. * Kept for back compatibility, you can use the onDisposeObservable instead.
  46525. */
  46526. onDispose: () => void;
  46527. /**
  46528. * Define the current state of the loading sequence when in delayed load mode.
  46529. */
  46530. delayLoadState: number;
  46531. private _scene;
  46532. /** @hidden */
  46533. _samplingMode: number;
  46534. /** @hidden */
  46535. _texture: Nullable<InternalTexture>;
  46536. private _uid;
  46537. /**
  46538. * Define if the texture is preventinga material to render or not.
  46539. * If not and the texture is not ready, the engine will use a default black texture instead.
  46540. */
  46541. readonly isBlocking: boolean;
  46542. /**
  46543. * Instantiates a new BaseTexture.
  46544. * Base class of all the textures in babylon.
  46545. * It groups all the common properties the materials, post process, lights... might need
  46546. * in order to make a correct use of the texture.
  46547. * @param scene Define the scene the texture blongs to
  46548. */
  46549. constructor(scene: Nullable<Scene>);
  46550. /**
  46551. * Get the scene the texture belongs to.
  46552. * @returns the scene or null if undefined
  46553. */
  46554. getScene(): Nullable<Scene>;
  46555. /**
  46556. * Get the texture transform matrix used to offset tile the texture for istance.
  46557. * @returns the transformation matrix
  46558. */
  46559. getTextureMatrix(): Matrix;
  46560. /**
  46561. * Get the texture reflection matrix used to rotate/transform the reflection.
  46562. * @returns the reflection matrix
  46563. */
  46564. getReflectionTextureMatrix(): Matrix;
  46565. /**
  46566. * Get the underlying lower level texture from Babylon.
  46567. * @returns the insternal texture
  46568. */
  46569. getInternalTexture(): Nullable<InternalTexture>;
  46570. /**
  46571. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  46572. * @returns true if ready or not blocking
  46573. */
  46574. isReadyOrNotBlocking(): boolean;
  46575. /**
  46576. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  46577. * @returns true if fully ready
  46578. */
  46579. isReady(): boolean;
  46580. private _cachedSize;
  46581. /**
  46582. * Get the size of the texture.
  46583. * @returns the texture size.
  46584. */
  46585. getSize(): ISize;
  46586. /**
  46587. * Get the base size of the texture.
  46588. * It can be different from the size if the texture has been resized for POT for instance
  46589. * @returns the base size
  46590. */
  46591. getBaseSize(): ISize;
  46592. /**
  46593. * Update the sampling mode of the texture.
  46594. * Default is Trilinear mode.
  46595. *
  46596. * | Value | Type | Description |
  46597. * | ----- | ------------------ | ----------- |
  46598. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  46599. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  46600. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  46601. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  46602. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  46603. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  46604. * | 7 | NEAREST_LINEAR | |
  46605. * | 8 | NEAREST_NEAREST | |
  46606. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  46607. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  46608. * | 11 | LINEAR_LINEAR | |
  46609. * | 12 | LINEAR_NEAREST | |
  46610. *
  46611. * > _mag_: magnification filter (close to the viewer)
  46612. * > _min_: minification filter (far from the viewer)
  46613. * > _mip_: filter used between mip map levels
  46614. *@param samplingMode Define the new sampling mode of the texture
  46615. */
  46616. updateSamplingMode(samplingMode: number): void;
  46617. /**
  46618. * Scales the texture if is `canRescale()`
  46619. * @param ratio the resize factor we want to use to rescale
  46620. */
  46621. scale(ratio: number): void;
  46622. /**
  46623. * Get if the texture can rescale.
  46624. */
  46625. readonly canRescale: boolean;
  46626. /** @hidden */
  46627. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  46628. /** @hidden */
  46629. _rebuild(): void;
  46630. /**
  46631. * Triggers the load sequence in delayed load mode.
  46632. */
  46633. delayLoad(): void;
  46634. /**
  46635. * Clones the texture.
  46636. * @returns the cloned texture
  46637. */
  46638. clone(): Nullable<BaseTexture>;
  46639. /**
  46640. * Get the texture underlying type (INT, FLOAT...)
  46641. */
  46642. readonly textureType: number;
  46643. /**
  46644. * Get the texture underlying format (RGB, RGBA...)
  46645. */
  46646. readonly textureFormat: number;
  46647. /**
  46648. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  46649. * This will returns an RGBA array buffer containing either in values (0-255) or
  46650. * float values (0-1) depending of the underlying buffer type.
  46651. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  46652. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  46653. * @param buffer defines a user defined buffer to fill with data (can be null)
  46654. * @returns The Array buffer containing the pixels data.
  46655. */
  46656. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  46657. /**
  46658. * Release and destroy the underlying lower level texture aka internalTexture.
  46659. */
  46660. releaseInternalTexture(): void;
  46661. /**
  46662. * Get the polynomial representation of the texture data.
  46663. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46664. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46665. */
  46666. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46667. /** @hidden */
  46668. readonly _lodTextureHigh: Nullable<BaseTexture>;
  46669. /** @hidden */
  46670. readonly _lodTextureMid: Nullable<BaseTexture>;
  46671. /** @hidden */
  46672. readonly _lodTextureLow: Nullable<BaseTexture>;
  46673. /**
  46674. * Dispose the texture and release its associated resources.
  46675. */
  46676. dispose(): void;
  46677. /**
  46678. * Serialize the texture into a JSON representation that can be parsed later on.
  46679. * @returns the JSON representation of the texture
  46680. */
  46681. serialize(): any;
  46682. /**
  46683. * Helper function to be called back once a list of texture contains only ready textures.
  46684. * @param textures Define the list of textures to wait for
  46685. * @param callback Define the callback triggered once the entire list will be ready
  46686. */
  46687. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  46688. }
  46689. }
  46690. declare module BABYLON {
  46691. /**
  46692. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  46693. * It can help converting any input color in a desired output one. This can then be used to create effects
  46694. * from sepia, black and white to sixties or futuristic rendering...
  46695. *
  46696. * The only supported format is currently 3dl.
  46697. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  46698. */
  46699. class ColorGradingTexture extends BaseTexture {
  46700. /**
  46701. * The current texture matrix. (will always be identity in color grading texture)
  46702. */
  46703. private _textureMatrix;
  46704. /**
  46705. * The texture URL.
  46706. */
  46707. url: string;
  46708. /**
  46709. * Empty line regex stored for GC.
  46710. */
  46711. private static _noneEmptyLineRegex;
  46712. private _engine;
  46713. /**
  46714. * Instantiates a ColorGradingTexture from the following parameters.
  46715. *
  46716. * @param url The location of the color gradind data (currently only supporting 3dl)
  46717. * @param scene The scene the texture will be used in
  46718. */
  46719. constructor(url: string, scene: Scene);
  46720. /**
  46721. * Returns the texture matrix used in most of the material.
  46722. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  46723. */
  46724. getTextureMatrix(): Matrix;
  46725. /**
  46726. * Occurs when the file being loaded is a .3dl LUT file.
  46727. */
  46728. private load3dlTexture;
  46729. /**
  46730. * Starts the loading process of the texture.
  46731. */
  46732. private loadTexture;
  46733. /**
  46734. * Clones the color gradind texture.
  46735. */
  46736. clone(): ColorGradingTexture;
  46737. /**
  46738. * Called during delayed load for textures.
  46739. */
  46740. delayLoad(): void;
  46741. /**
  46742. * Parses a color grading texture serialized by Babylon.
  46743. * @param parsedTexture The texture information being parsedTexture
  46744. * @param scene The scene to load the texture in
  46745. * @param rootUrl The root url of the data assets to load
  46746. * @return A color gradind texture
  46747. */
  46748. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  46749. /**
  46750. * Serializes the LUT texture to json format.
  46751. */
  46752. serialize(): any;
  46753. }
  46754. }
  46755. declare module BABYLON {
  46756. /**
  46757. * Class for creating a cube texture
  46758. */
  46759. class CubeTexture extends BaseTexture {
  46760. private _delayedOnLoad;
  46761. /**
  46762. * The url of the texture
  46763. */
  46764. url: string;
  46765. /**
  46766. * Gets or sets the center of the bounding box associated with the cube texture.
  46767. * It must define where the camera used to render the texture was set
  46768. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46769. */
  46770. boundingBoxPosition: Vector3;
  46771. private _boundingBoxSize;
  46772. /**
  46773. * Gets or sets the size of the bounding box associated with the cube texture
  46774. * When defined, the cubemap will switch to local mode
  46775. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46776. * @example https://www.babylonjs-playground.com/#RNASML
  46777. */
  46778. /**
  46779. * Returns the bounding box size
  46780. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46781. */
  46782. boundingBoxSize: Vector3;
  46783. protected _rotationY: number;
  46784. /**
  46785. * Sets texture matrix rotation angle around Y axis in radians.
  46786. */
  46787. /**
  46788. * Gets texture matrix rotation angle around Y axis radians.
  46789. */
  46790. rotationY: number;
  46791. /**
  46792. * Are mip maps generated for this texture or not.
  46793. */
  46794. readonly noMipmap: boolean;
  46795. private _noMipmap;
  46796. private _files;
  46797. private _extensions;
  46798. private _textureMatrix;
  46799. private _format;
  46800. private _createPolynomials;
  46801. /** @hidden */
  46802. _prefiltered: boolean;
  46803. /**
  46804. * Creates a cube texture from an array of image urls
  46805. * @param files defines an array of image urls
  46806. * @param scene defines the hosting scene
  46807. * @param noMipmap specifies if mip maps are not used
  46808. * @returns a cube texture
  46809. */
  46810. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  46811. /**
  46812. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  46813. * @param url defines the url of the prefiltered texture
  46814. * @param scene defines the scene the texture is attached to
  46815. * @param forcedExtension defines the extension of the file if different from the url
  46816. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46817. * @return the prefiltered texture
  46818. */
  46819. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  46820. /**
  46821. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  46822. * as prefiltered data.
  46823. * @param rootUrl defines the url of the texture or the root name of the six images
  46824. * @param scene defines the scene the texture is attached to
  46825. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  46826. * @param noMipmap defines if mipmaps should be created or not
  46827. * @param files defines the six files to load for the different faces
  46828. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  46829. * @param onError defines a callback triggered in case of error during load
  46830. * @param format defines the internal format to use for the texture once loaded
  46831. * @param prefiltered defines whether or not the texture is created from prefiltered data
  46832. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  46833. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46834. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46835. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46836. * @return the cube texture
  46837. */
  46838. 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);
  46839. /**
  46840. * Get the current class name of the texture useful for serialization or dynamic coding.
  46841. * @returns "CubeTexture"
  46842. */
  46843. getClassName(): string;
  46844. /**
  46845. * Update the url (and optional buffer) of this texture if url was null during construction.
  46846. * @param url the url of the texture
  46847. * @param forcedExtension defines the extension to use
  46848. * @param onLoad callback called when the texture is loaded (defaults to null)
  46849. */
  46850. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  46851. /**
  46852. * Delays loading of the cube texture
  46853. * @param forcedExtension defines the extension to use
  46854. */
  46855. delayLoad(forcedExtension?: string): void;
  46856. /**
  46857. * Returns the reflection texture matrix
  46858. * @returns the reflection texture matrix
  46859. */
  46860. getReflectionTextureMatrix(): Matrix;
  46861. /**
  46862. * Sets the reflection texture matrix
  46863. * @param value Reflection texture matrix
  46864. */
  46865. setReflectionTextureMatrix(value: Matrix): void;
  46866. /**
  46867. * Parses text to create a cube texture
  46868. * @param parsedTexture define the serialized text to read from
  46869. * @param scene defines the hosting scene
  46870. * @param rootUrl defines the root url of the cube texture
  46871. * @returns a cube texture
  46872. */
  46873. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  46874. /**
  46875. * Makes a clone, or deep copy, of the cube texture
  46876. * @returns a new cube texture
  46877. */
  46878. clone(): CubeTexture;
  46879. }
  46880. }
  46881. declare module BABYLON {
  46882. /**
  46883. * A class extending Texture allowing drawing on a texture
  46884. * @see http://doc.babylonjs.com/how_to/dynamictexture
  46885. */
  46886. class DynamicTexture extends Texture {
  46887. private _generateMipMaps;
  46888. private _canvas;
  46889. private _context;
  46890. private _engine;
  46891. /**
  46892. * Creates a DynamicTexture
  46893. * @param name defines the name of the texture
  46894. * @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
  46895. * @param scene defines the scene where you want the texture
  46896. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46897. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46898. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  46899. */
  46900. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46901. /**
  46902. * Get the current class name of the texture useful for serialization or dynamic coding.
  46903. * @returns "DynamicTexture"
  46904. */
  46905. getClassName(): string;
  46906. /**
  46907. * Gets the current state of canRescale
  46908. */
  46909. readonly canRescale: boolean;
  46910. private _recreate;
  46911. /**
  46912. * Scales the texture
  46913. * @param ratio the scale factor to apply to both width and height
  46914. */
  46915. scale(ratio: number): void;
  46916. /**
  46917. * Resizes the texture
  46918. * @param width the new width
  46919. * @param height the new height
  46920. */
  46921. scaleTo(width: number, height: number): void;
  46922. /**
  46923. * Gets the context of the canvas used by the texture
  46924. * @returns the canvas context of the dynamic texture
  46925. */
  46926. getContext(): CanvasRenderingContext2D;
  46927. /**
  46928. * Clears the texture
  46929. */
  46930. clear(): void;
  46931. /**
  46932. * Updates the texture
  46933. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46934. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46935. */
  46936. update(invertY?: boolean, premulAlpha?: boolean): void;
  46937. /**
  46938. * Draws text onto the texture
  46939. * @param text defines the text to be drawn
  46940. * @param x defines the placement of the text from the left
  46941. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46942. * @param font defines the font to be used with font-style, font-size, font-name
  46943. * @param color defines the color used for the text
  46944. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46945. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46946. * @param update defines whether texture is immediately update (default is true)
  46947. */
  46948. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  46949. /**
  46950. * Clones the texture
  46951. * @returns the clone of the texture.
  46952. */
  46953. clone(): DynamicTexture;
  46954. /**
  46955. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46956. * @returns a serialized dynamic texture object
  46957. */
  46958. serialize(): any;
  46959. /** @hidden */
  46960. _rebuild(): void;
  46961. }
  46962. }
  46963. declare module BABYLON {
  46964. /**
  46965. * This represents a texture coming from an HDR input.
  46966. *
  46967. * The only supported format is currently panorama picture stored in RGBE format.
  46968. * Example of such files can be found on HDRLib: http://hdrlib.com/
  46969. */
  46970. class HDRCubeTexture extends BaseTexture {
  46971. private static _facesMapping;
  46972. private _generateHarmonics;
  46973. private _noMipmap;
  46974. private _textureMatrix;
  46975. private _size;
  46976. private _onLoad;
  46977. private _onError;
  46978. /**
  46979. * The texture URL.
  46980. */
  46981. url: string;
  46982. /**
  46983. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  46984. */
  46985. coordinatesMode: number;
  46986. protected _isBlocking: boolean;
  46987. /**
  46988. * Sets wether or not the texture is blocking during loading.
  46989. */
  46990. /**
  46991. * Gets wether or not the texture is blocking during loading.
  46992. */
  46993. isBlocking: boolean;
  46994. protected _rotationY: number;
  46995. /**
  46996. * Sets texture matrix rotation angle around Y axis in radians.
  46997. */
  46998. /**
  46999. * Gets texture matrix rotation angle around Y axis radians.
  47000. */
  47001. rotationY: number;
  47002. /**
  47003. * Gets or sets the center of the bounding box associated with the cube texture
  47004. * It must define where the camera used to render the texture was set
  47005. */
  47006. boundingBoxPosition: Vector3;
  47007. private _boundingBoxSize;
  47008. /**
  47009. * Gets or sets the size of the bounding box associated with the cube texture
  47010. * When defined, the cubemap will switch to local mode
  47011. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47012. * @example https://www.babylonjs-playground.com/#RNASML
  47013. */
  47014. boundingBoxSize: Vector3;
  47015. /**
  47016. * Instantiates an HDRTexture from the following parameters.
  47017. *
  47018. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47019. * @param scene The scene the texture will be used in
  47020. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47021. * @param noMipmap Forces to not generate the mipmap if true
  47022. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47023. * @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)
  47024. * @param reserved Reserved flag for internal use.
  47025. */
  47026. 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>);
  47027. /**
  47028. * Get the current class name of the texture useful for serialization or dynamic coding.
  47029. * @returns "HDRCubeTexture"
  47030. */
  47031. getClassName(): string;
  47032. /**
  47033. * Occurs when the file is raw .hdr file.
  47034. */
  47035. private loadTexture;
  47036. clone(): HDRCubeTexture;
  47037. delayLoad(): void;
  47038. /**
  47039. * Get the texture reflection matrix used to rotate/transform the reflection.
  47040. * @returns the reflection matrix
  47041. */
  47042. getReflectionTextureMatrix(): Matrix;
  47043. /**
  47044. * Set the texture reflection matrix used to rotate/transform the reflection.
  47045. * @param value Define the reflection matrix to set
  47046. */
  47047. setReflectionTextureMatrix(value: Matrix): void;
  47048. /**
  47049. * Parses a JSON representation of an HDR Texture in order to create the texture
  47050. * @param parsedTexture Define the JSON representation
  47051. * @param scene Define the scene the texture should be created in
  47052. * @param rootUrl Define the root url in case we need to load relative dependencies
  47053. * @returns the newly created texture after parsing
  47054. */
  47055. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47056. serialize(): any;
  47057. }
  47058. }
  47059. declare module BABYLON {
  47060. /**
  47061. * Class used to store data associated with WebGL texture data for the engine
  47062. * This class should not be used directly
  47063. */
  47064. class InternalTexture implements IInternalTextureTracker {
  47065. /**
  47066. * The source of the texture data is unknown
  47067. */
  47068. static DATASOURCE_UNKNOWN: number;
  47069. /**
  47070. * Texture data comes from an URL
  47071. */
  47072. static DATASOURCE_URL: number;
  47073. /**
  47074. * Texture data is only used for temporary storage
  47075. */
  47076. static DATASOURCE_TEMP: number;
  47077. /**
  47078. * Texture data comes from raw data (ArrayBuffer)
  47079. */
  47080. static DATASOURCE_RAW: number;
  47081. /**
  47082. * Texture content is dynamic (video or dynamic texture)
  47083. */
  47084. static DATASOURCE_DYNAMIC: number;
  47085. /**
  47086. * Texture content is generated by rendering to it
  47087. */
  47088. static DATASOURCE_RENDERTARGET: number;
  47089. /**
  47090. * Texture content is part of a multi render target process
  47091. */
  47092. static DATASOURCE_MULTIRENDERTARGET: number;
  47093. /**
  47094. * Texture data comes from a cube data file
  47095. */
  47096. static DATASOURCE_CUBE: number;
  47097. /**
  47098. * Texture data comes from a raw cube data
  47099. */
  47100. static DATASOURCE_CUBERAW: number;
  47101. /**
  47102. * Texture data come from a prefiltered cube data file
  47103. */
  47104. static DATASOURCE_CUBEPREFILTERED: number;
  47105. /**
  47106. * Texture content is raw 3D data
  47107. */
  47108. static DATASOURCE_RAW3D: number;
  47109. /**
  47110. * Texture content is a depth texture
  47111. */
  47112. static DATASOURCE_DEPTHTEXTURE: number;
  47113. /**
  47114. * Texture data comes from a raw cube data encoded with RGBD
  47115. */
  47116. static DATASOURCE_CUBERAW_RGBD: number;
  47117. /**
  47118. * Defines if the texture is ready
  47119. */
  47120. isReady: boolean;
  47121. /**
  47122. * Defines if the texture is a cube texture
  47123. */
  47124. isCube: boolean;
  47125. /**
  47126. * Defines if the texture contains 3D data
  47127. */
  47128. is3D: boolean;
  47129. /**
  47130. * Gets the URL used to load this texture
  47131. */
  47132. url: string;
  47133. /**
  47134. * Gets the sampling mode of the texture
  47135. */
  47136. samplingMode: number;
  47137. /**
  47138. * Gets a boolean indicating if the texture needs mipmaps generation
  47139. */
  47140. generateMipMaps: boolean;
  47141. /**
  47142. * Gets the number of samples used by the texture (WebGL2+ only)
  47143. */
  47144. samples: number;
  47145. /**
  47146. * Gets the type of the texture (int, float...)
  47147. */
  47148. type: number;
  47149. /**
  47150. * Gets the format of the texture (RGB, RGBA...)
  47151. */
  47152. format: number;
  47153. /**
  47154. * Observable called when the texture is loaded
  47155. */
  47156. onLoadedObservable: Observable<InternalTexture>;
  47157. /**
  47158. * Gets the width of the texture
  47159. */
  47160. width: number;
  47161. /**
  47162. * Gets the height of the texture
  47163. */
  47164. height: number;
  47165. /**
  47166. * Gets the depth of the texture
  47167. */
  47168. depth: number;
  47169. /**
  47170. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  47171. */
  47172. baseWidth: number;
  47173. /**
  47174. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  47175. */
  47176. baseHeight: number;
  47177. /**
  47178. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  47179. */
  47180. baseDepth: number;
  47181. /**
  47182. * Gets a boolean indicating if the texture is inverted on Y axis
  47183. */
  47184. invertY: boolean;
  47185. /**
  47186. * Gets or set the previous tracker in the list
  47187. */
  47188. previous: Nullable<IInternalTextureTracker>;
  47189. /**
  47190. * Gets or set the next tracker in the list
  47191. */
  47192. next: Nullable<IInternalTextureTracker>;
  47193. /** @hidden */
  47194. _invertVScale: boolean;
  47195. /** @hidden */
  47196. _initialSlot: number;
  47197. /** @hidden */
  47198. _designatedSlot: number;
  47199. /** @hidden */
  47200. _dataSource: number;
  47201. /** @hidden */
  47202. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  47203. /** @hidden */
  47204. _bufferView: Nullable<ArrayBufferView>;
  47205. /** @hidden */
  47206. _bufferViewArray: Nullable<ArrayBufferView[]>;
  47207. /** @hidden */
  47208. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  47209. /** @hidden */
  47210. _size: number;
  47211. /** @hidden */
  47212. _extension: string;
  47213. /** @hidden */
  47214. _files: Nullable<string[]>;
  47215. /** @hidden */
  47216. _workingCanvas: HTMLCanvasElement;
  47217. /** @hidden */
  47218. _workingContext: CanvasRenderingContext2D;
  47219. /** @hidden */
  47220. _framebuffer: Nullable<WebGLFramebuffer>;
  47221. /** @hidden */
  47222. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  47223. /** @hidden */
  47224. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  47225. /** @hidden */
  47226. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  47227. /** @hidden */
  47228. _attachments: Nullable<number[]>;
  47229. /** @hidden */
  47230. _cachedCoordinatesMode: Nullable<number>;
  47231. /** @hidden */
  47232. _cachedWrapU: Nullable<number>;
  47233. /** @hidden */
  47234. _cachedWrapV: Nullable<number>;
  47235. /** @hidden */
  47236. _cachedWrapR: Nullable<number>;
  47237. /** @hidden */
  47238. _cachedAnisotropicFilteringLevel: Nullable<number>;
  47239. /** @hidden */
  47240. _isDisabled: boolean;
  47241. /** @hidden */
  47242. _compression: Nullable<string>;
  47243. /** @hidden */
  47244. _generateStencilBuffer: boolean;
  47245. /** @hidden */
  47246. _generateDepthBuffer: boolean;
  47247. /** @hidden */
  47248. _comparisonFunction: number;
  47249. /** @hidden */
  47250. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  47251. /** @hidden */
  47252. _lodGenerationScale: number;
  47253. /** @hidden */
  47254. _lodGenerationOffset: number;
  47255. /** @hidden */
  47256. _lodTextureHigh: BaseTexture;
  47257. /** @hidden */
  47258. _lodTextureMid: BaseTexture;
  47259. /** @hidden */
  47260. _lodTextureLow: BaseTexture;
  47261. /** @hidden */
  47262. _isRGBD: boolean;
  47263. /** @hidden */
  47264. _webGLTexture: Nullable<WebGLTexture>;
  47265. /** @hidden */
  47266. _references: number;
  47267. private _engine;
  47268. /**
  47269. * Gets the Engine the texture belongs to.
  47270. * @returns The babylon engine
  47271. */
  47272. getEngine(): Engine;
  47273. /**
  47274. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  47275. */
  47276. readonly dataSource: number;
  47277. /**
  47278. * Creates a new InternalTexture
  47279. * @param engine defines the engine to use
  47280. * @param dataSource defines the type of data that will be used
  47281. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47282. */
  47283. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  47284. /**
  47285. * Increments the number of references (ie. the number of Texture that point to it)
  47286. */
  47287. incrementReferences(): void;
  47288. /**
  47289. * Change the size of the texture (not the size of the content)
  47290. * @param width defines the new width
  47291. * @param height defines the new height
  47292. * @param depth defines the new depth (1 by default)
  47293. */
  47294. updateSize(width: int, height: int, depth?: int): void;
  47295. /** @hidden */
  47296. _rebuild(): void;
  47297. /** @hidden */
  47298. _swapAndDie(target: InternalTexture): void;
  47299. /**
  47300. * Dispose the current allocated resources
  47301. */
  47302. dispose(): void;
  47303. }
  47304. }
  47305. declare module BABYLON {
  47306. /**
  47307. * This represents the required contract to create a new type of texture loader.
  47308. */
  47309. interface IInternalTextureLoader {
  47310. /**
  47311. * Defines wether the loader supports cascade loading the different faces.
  47312. */
  47313. supportCascades: boolean;
  47314. /**
  47315. * This returns if the loader support the current file information.
  47316. * @param extension defines the file extension of the file being loaded
  47317. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47318. * @param fallback defines the fallback internal texture if any
  47319. * @param isBase64 defines whether the texture is encoded as a base64
  47320. * @param isBuffer defines whether the texture data are stored as a buffer
  47321. * @returns true if the loader can load the specified file
  47322. */
  47323. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47324. /**
  47325. * Transform the url before loading if required.
  47326. * @param rootUrl the url of the texture
  47327. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47328. * @returns the transformed texture
  47329. */
  47330. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47331. /**
  47332. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47333. * @param rootUrl the url of the texture
  47334. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47335. * @returns the fallback texture
  47336. */
  47337. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47338. /**
  47339. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47340. * @param data contains the texture data
  47341. * @param texture defines the BabylonJS internal texture
  47342. * @param createPolynomials will be true if polynomials have been requested
  47343. * @param onLoad defines the callback to trigger once the texture is ready
  47344. * @param onError defines the callback to trigger in case of error
  47345. */
  47346. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47347. /**
  47348. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47349. * @param data contains the texture data
  47350. * @param texture defines the BabylonJS internal texture
  47351. * @param callback defines the method to call once ready to upload
  47352. */
  47353. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  47354. }
  47355. }
  47356. declare module BABYLON {
  47357. /**
  47358. * Internal interface used to track InternalTexture already bound to the GL context
  47359. */
  47360. interface IInternalTextureTracker {
  47361. /**
  47362. * Gets or set the previous tracker in the list
  47363. */
  47364. previous: Nullable<IInternalTextureTracker>;
  47365. /**
  47366. * Gets or set the next tracker in the list
  47367. */
  47368. next: Nullable<IInternalTextureTracker>;
  47369. }
  47370. /**
  47371. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  47372. */
  47373. class DummyInternalTextureTracker {
  47374. /**
  47375. * Gets or set the previous tracker in the list
  47376. */
  47377. previous: Nullable<IInternalTextureTracker>;
  47378. /**
  47379. * Gets or set the next tracker in the list
  47380. */
  47381. next: Nullable<IInternalTextureTracker>;
  47382. }
  47383. }
  47384. declare module BABYLON {
  47385. /**
  47386. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47387. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47388. * You can then easily use it as a reflectionTexture on a flat surface.
  47389. * In case the surface is not a plane, please consider relying on reflection probes.
  47390. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47391. */
  47392. class MirrorTexture extends RenderTargetTexture {
  47393. private scene;
  47394. /**
  47395. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  47396. * It is possible to directly set the mirrorPlane by directly using a BABYLON.Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  47397. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47398. */
  47399. mirrorPlane: Plane;
  47400. /**
  47401. * Define the blur ratio used to blur the reflection if needed.
  47402. */
  47403. blurRatio: number;
  47404. /**
  47405. * Define the adaptive blur kernel used to blur the reflection if needed.
  47406. * This will autocompute the closest best match for the `blurKernel`
  47407. */
  47408. adaptiveBlurKernel: number;
  47409. /**
  47410. * Define the blur kernel used to blur the reflection if needed.
  47411. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47412. */
  47413. blurKernel: number;
  47414. /**
  47415. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  47416. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47417. */
  47418. blurKernelX: number;
  47419. /**
  47420. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  47421. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47422. */
  47423. blurKernelY: number;
  47424. private _autoComputeBlurKernel;
  47425. protected _onRatioRescale(): void;
  47426. private _updateGammaSpace;
  47427. private _imageProcessingConfigChangeObserver;
  47428. private _transformMatrix;
  47429. private _mirrorMatrix;
  47430. private _savedViewMatrix;
  47431. private _blurX;
  47432. private _blurY;
  47433. private _adaptiveBlurKernel;
  47434. private _blurKernelX;
  47435. private _blurKernelY;
  47436. private _blurRatio;
  47437. /**
  47438. * Instantiates a Mirror Texture.
  47439. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47440. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47441. * You can then easily use it as a reflectionTexture on a flat surface.
  47442. * In case the surface is not a plane, please consider relying on reflection probes.
  47443. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47444. * @param name
  47445. * @param size
  47446. * @param scene
  47447. * @param generateMipMaps
  47448. * @param type
  47449. * @param samplingMode
  47450. * @param generateDepthBuffer
  47451. */
  47452. constructor(name: string, size: number | {
  47453. width: number;
  47454. height: number;
  47455. } | {
  47456. ratio: number;
  47457. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  47458. private _preparePostProcesses;
  47459. /**
  47460. * Clone the mirror texture.
  47461. * @returns the cloned texture
  47462. */
  47463. clone(): MirrorTexture;
  47464. /**
  47465. * Serialize the texture to a JSON representation you could use in Parse later on
  47466. * @returns the serialized JSON representation
  47467. */
  47468. serialize(): any;
  47469. /**
  47470. * Dispose the texture and release its associated resources.
  47471. */
  47472. dispose(): void;
  47473. }
  47474. }
  47475. declare module BABYLON {
  47476. /**
  47477. * Creation options of the multi render target texture.
  47478. */
  47479. interface IMultiRenderTargetOptions {
  47480. /**
  47481. * Define if the texture needs to create mip maps after render.
  47482. */
  47483. generateMipMaps?: boolean;
  47484. /**
  47485. * Define the types of all the draw buffers we want to create
  47486. */
  47487. types?: number[];
  47488. /**
  47489. * Define the sampling modes of all the draw buffers we want to create
  47490. */
  47491. samplingModes?: number[];
  47492. /**
  47493. * Define if a depth buffer is required
  47494. */
  47495. generateDepthBuffer?: boolean;
  47496. /**
  47497. * Define if a stencil buffer is required
  47498. */
  47499. generateStencilBuffer?: boolean;
  47500. /**
  47501. * Define if a depth texture is required instead of a depth buffer
  47502. */
  47503. generateDepthTexture?: boolean;
  47504. /**
  47505. * Define the number of desired draw buffers
  47506. */
  47507. textureCount?: number;
  47508. /**
  47509. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47510. */
  47511. doNotChangeAspectRatio?: boolean;
  47512. /**
  47513. * Define the default type of the buffers we are creating
  47514. */
  47515. defaultType?: number;
  47516. }
  47517. /**
  47518. * A multi render target, like a render target provides the ability to render to a texture.
  47519. * Unlike the render target, it can render to several draw buffers in one draw.
  47520. * This is specially interesting in deferred rendering or for any effects requiring more than
  47521. * just one color from a single pass.
  47522. */
  47523. class MultiRenderTarget extends RenderTargetTexture {
  47524. private _internalTextures;
  47525. private _textures;
  47526. private _multiRenderTargetOptions;
  47527. /**
  47528. * Get if draw buffers are currently supported by the used hardware and browser.
  47529. */
  47530. readonly isSupported: boolean;
  47531. /**
  47532. * Get the list of textures generated by the multi render target.
  47533. */
  47534. readonly textures: Texture[];
  47535. /**
  47536. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47537. */
  47538. readonly depthTexture: Texture;
  47539. /**
  47540. * Set the wrapping mode on U of all the textures we are rendering to.
  47541. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47542. */
  47543. wrapU: number;
  47544. /**
  47545. * Set the wrapping mode on V of all the textures we are rendering to.
  47546. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47547. */
  47548. wrapV: number;
  47549. /**
  47550. * Instantiate a new multi render target texture.
  47551. * A multi render target, like a render target provides the ability to render to a texture.
  47552. * Unlike the render target, it can render to several draw buffers in one draw.
  47553. * This is specially interesting in deferred rendering or for any effects requiring more than
  47554. * just one color from a single pass.
  47555. * @param name Define the name of the texture
  47556. * @param size Define the size of the buffers to render to
  47557. * @param count Define the number of target we are rendering into
  47558. * @param scene Define the scene the texture belongs to
  47559. * @param options Define the options used to create the multi render target
  47560. */
  47561. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47562. /** @hidden */
  47563. _rebuild(): void;
  47564. private _createInternalTextures;
  47565. private _createTextures;
  47566. /**
  47567. * Define the number of samples used if MSAA is enabled.
  47568. */
  47569. samples: number;
  47570. /**
  47571. * Resize all the textures in the multi render target.
  47572. * Be carrefull as it will recreate all the data in the new texture.
  47573. * @param size Define the new size
  47574. */
  47575. resize(size: any): void;
  47576. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47577. /**
  47578. * Dispose the render targets and their associated resources
  47579. */
  47580. dispose(): void;
  47581. /**
  47582. * Release all the underlying texture used as draw buffers.
  47583. */
  47584. releaseInternalTextures(): void;
  47585. }
  47586. }
  47587. declare module BABYLON {
  47588. /**
  47589. * Raw cube texture where the raw buffers are passed in
  47590. */
  47591. class RawCubeTexture extends CubeTexture {
  47592. /**
  47593. * Creates a cube texture where the raw buffers are passed in.
  47594. * @param scene defines the scene the texture is attached to
  47595. * @param data defines the array of data to use to create each face
  47596. * @param size defines the size of the textures
  47597. * @param format defines the format of the data
  47598. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  47599. * @param generateMipMaps defines if the engine should generate the mip levels
  47600. * @param invertY defines if data must be stored with Y axis inverted
  47601. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  47602. * @param compression defines the compression used (null by default)
  47603. */
  47604. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  47605. /**
  47606. * Updates the raw cube texture.
  47607. * @param data defines the data to store
  47608. * @param format defines the data format
  47609. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47610. * @param invertY defines if data must be stored with Y axis inverted
  47611. * @param compression defines the compression used (null by default)
  47612. * @param level defines which level of the texture to update
  47613. */
  47614. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  47615. /**
  47616. * Updates a raw cube texture with RGBD encoded data.
  47617. * @param data defines the array of data [mipmap][face] to use to create each face
  47618. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  47619. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47620. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47621. * @returns a promsie that resolves when the operation is complete
  47622. */
  47623. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  47624. /**
  47625. * Clones the raw cube texture.
  47626. * @return a new cube texture
  47627. */
  47628. clone(): CubeTexture;
  47629. /** @hidden */
  47630. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47631. }
  47632. }
  47633. declare module BABYLON {
  47634. /**
  47635. * Raw texture can help creating a texture directly from an array of data.
  47636. * This can be super useful if you either get the data from an uncompressed source or
  47637. * if you wish to create your texture pixel by pixel.
  47638. */
  47639. class RawTexture extends Texture {
  47640. /**
  47641. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47642. */
  47643. format: number;
  47644. private _engine;
  47645. /**
  47646. * Instantiates a new RawTexture.
  47647. * Raw texture can help creating a texture directly from an array of data.
  47648. * This can be super useful if you either get the data from an uncompressed source or
  47649. * if you wish to create your texture pixel by pixel.
  47650. * @param data define the array of data to use to create the texture
  47651. * @param width define the width of the texture
  47652. * @param height define the height of the texture
  47653. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47654. * @param scene define the scene the texture belongs to
  47655. * @param generateMipMaps define whether mip maps should be generated or not
  47656. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47657. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47658. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47659. */
  47660. constructor(data: ArrayBufferView, width: number, height: number,
  47661. /**
  47662. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47663. */
  47664. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  47665. /**
  47666. * Updates the texture underlying data.
  47667. * @param data Define the new data of the texture
  47668. */
  47669. update(data: ArrayBufferView): void;
  47670. /**
  47671. * Creates a luminance texture from some data.
  47672. * @param data Define the texture data
  47673. * @param width Define the width of the texture
  47674. * @param height Define the height of the texture
  47675. * @param scene Define the scene the texture belongs to
  47676. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47677. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47678. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47679. * @returns the luminance texture
  47680. */
  47681. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47682. /**
  47683. * Creates a luminance alpha texture from some data.
  47684. * @param data Define the texture data
  47685. * @param width Define the width of the texture
  47686. * @param height Define the height of the texture
  47687. * @param scene Define the scene the texture belongs to
  47688. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47689. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47690. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47691. * @returns the luminance alpha texture
  47692. */
  47693. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47694. /**
  47695. * Creates an alpha texture from some data.
  47696. * @param data Define the texture data
  47697. * @param width Define the width of the texture
  47698. * @param height Define the height of the texture
  47699. * @param scene Define the scene the texture belongs to
  47700. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47701. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47702. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47703. * @returns the alpha texture
  47704. */
  47705. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47706. /**
  47707. * Creates a RGB texture from some data.
  47708. * @param data Define the texture data
  47709. * @param width Define the width of the texture
  47710. * @param height Define the height of the texture
  47711. * @param scene Define the scene the texture belongs to
  47712. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47713. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47714. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47715. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47716. * @returns the RGB alpha texture
  47717. */
  47718. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47719. /**
  47720. * Creates a RGBA texture from some data.
  47721. * @param data Define the texture data
  47722. * @param width Define the width of the texture
  47723. * @param height Define the height of the texture
  47724. * @param scene Define the scene the texture belongs to
  47725. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47726. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47727. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47728. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47729. * @returns the RGBA texture
  47730. */
  47731. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47732. /**
  47733. * Creates a R texture from some data.
  47734. * @param data Define the texture data
  47735. * @param width Define the width of the texture
  47736. * @param height Define the height of the texture
  47737. * @param scene Define the scene the texture belongs to
  47738. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47739. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47740. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47741. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47742. * @returns the R texture
  47743. */
  47744. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47745. }
  47746. }
  47747. declare module BABYLON {
  47748. /**
  47749. * Class used to store 3D textures containing user data
  47750. */
  47751. class RawTexture3D extends Texture {
  47752. /** Gets or sets the texture format to use */
  47753. format: number;
  47754. private _engine;
  47755. /**
  47756. * Create a new RawTexture3D
  47757. * @param data defines the data of the texture
  47758. * @param width defines the width of the texture
  47759. * @param height defines the height of the texture
  47760. * @param depth defines the depth of the texture
  47761. * @param format defines the texture format to use
  47762. * @param scene defines the hosting scene
  47763. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  47764. * @param invertY defines if texture must be stored with Y axis inverted
  47765. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  47766. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47767. */
  47768. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  47769. /** Gets or sets the texture format to use */
  47770. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  47771. /**
  47772. * Update the texture with new data
  47773. * @param data defines the data to store in the texture
  47774. */
  47775. update(data: ArrayBufferView): void;
  47776. }
  47777. }
  47778. declare module BABYLON {
  47779. /**
  47780. * Creates a refraction texture used by refraction channel of the standard material.
  47781. * It is like a mirror but to see through a material.
  47782. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47783. */
  47784. class RefractionTexture extends RenderTargetTexture {
  47785. /**
  47786. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  47787. * It is possible to directly set the refractionPlane by directly using a BABYLON.Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the refractionPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the refractor as stated in the doc.
  47788. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47789. */
  47790. refractionPlane: Plane;
  47791. /**
  47792. * Define how deep under the surface we should see.
  47793. */
  47794. depth: number;
  47795. /**
  47796. * Creates a refraction texture used by refraction channel of the standard material.
  47797. * It is like a mirror but to see through a material.
  47798. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47799. * @param name Define the texture name
  47800. * @param size Define the size of the underlying texture
  47801. * @param scene Define the scene the refraction belongs to
  47802. * @param generateMipMaps Define if we need to generate mips level for the refraction
  47803. */
  47804. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  47805. /**
  47806. * Clone the refraction texture.
  47807. * @returns the cloned texture
  47808. */
  47809. clone(): RefractionTexture;
  47810. /**
  47811. * Serialize the texture to a JSON representation you could use in Parse later on
  47812. * @returns the serialized JSON representation
  47813. */
  47814. serialize(): any;
  47815. }
  47816. }
  47817. declare module BABYLON {
  47818. /**
  47819. * This Helps creating a texture that will be created from a camera in your scene.
  47820. * It is basically a dynamic texture that could be used to create special effects for instance.
  47821. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  47822. */
  47823. class RenderTargetTexture extends Texture {
  47824. isCube: boolean;
  47825. /**
  47826. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  47827. */
  47828. static readonly REFRESHRATE_RENDER_ONCE: number;
  47829. /**
  47830. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  47831. */
  47832. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  47833. /**
  47834. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  47835. * the central point of your effect and can save a lot of performances.
  47836. */
  47837. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  47838. /**
  47839. * Use this predicate to dynamically define the list of mesh you want to render.
  47840. * If set, the renderList property will be overwritten.
  47841. */
  47842. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  47843. private _renderList;
  47844. /**
  47845. * Use this list to define the list of mesh you want to render.
  47846. */
  47847. renderList: Nullable<Array<AbstractMesh>>;
  47848. private _hookArray;
  47849. /**
  47850. * Define if particles should be rendered in your texture.
  47851. */
  47852. renderParticles: boolean;
  47853. /**
  47854. * Define if sprites should be rendered in your texture.
  47855. */
  47856. renderSprites: boolean;
  47857. /**
  47858. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  47859. */
  47860. coordinatesMode: number;
  47861. /**
  47862. * Define the camera used to render the texture.
  47863. */
  47864. activeCamera: Nullable<Camera>;
  47865. /**
  47866. * Override the render function of the texture with your own one.
  47867. */
  47868. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  47869. /**
  47870. * Define if camera post processes should be use while rendering the texture.
  47871. */
  47872. useCameraPostProcesses: boolean;
  47873. /**
  47874. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  47875. */
  47876. ignoreCameraViewport: boolean;
  47877. private _postProcessManager;
  47878. private _postProcesses;
  47879. private _resizeObserver;
  47880. /**
  47881. * An event triggered when the texture is unbind.
  47882. */
  47883. onBeforeBindObservable: Observable<RenderTargetTexture>;
  47884. /**
  47885. * An event triggered when the texture is unbind.
  47886. */
  47887. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  47888. private _onAfterUnbindObserver;
  47889. /**
  47890. * Set a after unbind callback in the texture.
  47891. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  47892. */
  47893. onAfterUnbind: () => void;
  47894. /**
  47895. * An event triggered before rendering the texture
  47896. */
  47897. onBeforeRenderObservable: Observable<number>;
  47898. private _onBeforeRenderObserver;
  47899. /**
  47900. * Set a before render callback in the texture.
  47901. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  47902. */
  47903. onBeforeRender: (faceIndex: number) => void;
  47904. /**
  47905. * An event triggered after rendering the texture
  47906. */
  47907. onAfterRenderObservable: Observable<number>;
  47908. private _onAfterRenderObserver;
  47909. /**
  47910. * Set a after render callback in the texture.
  47911. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  47912. */
  47913. onAfterRender: (faceIndex: number) => void;
  47914. /**
  47915. * An event triggered after the texture clear
  47916. */
  47917. onClearObservable: Observable<Engine>;
  47918. private _onClearObserver;
  47919. /**
  47920. * Set a clear callback in the texture.
  47921. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  47922. */
  47923. onClear: (Engine: Engine) => void;
  47924. /**
  47925. * Define the clear color of the Render Target if it should be different from the scene.
  47926. */
  47927. clearColor: Color4;
  47928. protected _size: number | {
  47929. width: number;
  47930. height: number;
  47931. };
  47932. protected _initialSizeParameter: number | {
  47933. width: number;
  47934. height: number;
  47935. } | {
  47936. ratio: number;
  47937. };
  47938. protected _sizeRatio: Nullable<number>;
  47939. /** @hidden */
  47940. _generateMipMaps: boolean;
  47941. protected _renderingManager: RenderingManager;
  47942. /** @hidden */
  47943. _waitingRenderList: string[];
  47944. protected _doNotChangeAspectRatio: boolean;
  47945. protected _currentRefreshId: number;
  47946. protected _refreshRate: number;
  47947. protected _textureMatrix: Matrix;
  47948. protected _samples: number;
  47949. protected _renderTargetOptions: RenderTargetCreationOptions;
  47950. /**
  47951. * Gets render target creation options that were used.
  47952. */
  47953. readonly renderTargetOptions: RenderTargetCreationOptions;
  47954. protected _engine: Engine;
  47955. protected _onRatioRescale(): void;
  47956. /**
  47957. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  47958. * It must define where the camera used to render the texture is set
  47959. */
  47960. boundingBoxPosition: Vector3;
  47961. private _boundingBoxSize;
  47962. /**
  47963. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  47964. * When defined, the cubemap will switch to local mode
  47965. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47966. * @example https://www.babylonjs-playground.com/#RNASML
  47967. */
  47968. boundingBoxSize: Vector3;
  47969. /**
  47970. * In case the RTT has been created with a depth texture, get the associated
  47971. * depth texture.
  47972. * Otherwise, return null.
  47973. */
  47974. depthStencilTexture: Nullable<InternalTexture>;
  47975. /**
  47976. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  47977. * or used a shadow, depth texture...
  47978. * @param name The friendly name of the texture
  47979. * @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)
  47980. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  47981. * @param generateMipMaps True if mip maps need to be generated after render.
  47982. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  47983. * @param type The type of the buffer in the RTT (int, half float, float...)
  47984. * @param isCube True if a cube texture needs to be created
  47985. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  47986. * @param generateDepthBuffer True to generate a depth buffer
  47987. * @param generateStencilBuffer True to generate a stencil buffer
  47988. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  47989. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  47990. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47991. */
  47992. constructor(name: string, size: number | {
  47993. width: number;
  47994. height: number;
  47995. } | {
  47996. ratio: number;
  47997. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  47998. /**
  47999. * Creates a depth stencil texture.
  48000. * This is only available in WebGL 2 or with the depth texture extension available.
  48001. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  48002. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  48003. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  48004. */
  48005. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  48006. private _processSizeParameter;
  48007. /**
  48008. * Define the number of samples to use in case of MSAA.
  48009. * It defaults to one meaning no MSAA has been enabled.
  48010. */
  48011. samples: number;
  48012. /**
  48013. * Resets the refresh counter of the texture and start bak from scratch.
  48014. * Could be useful to regenerate the texture if it is setup to render only once.
  48015. */
  48016. resetRefreshCounter(): void;
  48017. /**
  48018. * Define the refresh rate of the texture or the rendering frequency.
  48019. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  48020. */
  48021. refreshRate: number;
  48022. /**
  48023. * Adds a post process to the render target rendering passes.
  48024. * @param postProcess define the post process to add
  48025. */
  48026. addPostProcess(postProcess: PostProcess): void;
  48027. /**
  48028. * Clear all the post processes attached to the render target
  48029. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  48030. */
  48031. clearPostProcesses(dispose?: boolean): void;
  48032. /**
  48033. * Remove one of the post process from the list of attached post processes to the texture
  48034. * @param postProcess define the post process to remove from the list
  48035. */
  48036. removePostProcess(postProcess: PostProcess): void;
  48037. /** @hidden */
  48038. _shouldRender(): boolean;
  48039. /**
  48040. * Gets the actual render size of the texture.
  48041. * @returns the width of the render size
  48042. */
  48043. getRenderSize(): number;
  48044. /**
  48045. * Gets the actual render width of the texture.
  48046. * @returns the width of the render size
  48047. */
  48048. getRenderWidth(): number;
  48049. /**
  48050. * Gets the actual render height of the texture.
  48051. * @returns the height of the render size
  48052. */
  48053. getRenderHeight(): number;
  48054. /**
  48055. * Get if the texture can be rescaled or not.
  48056. */
  48057. readonly canRescale: boolean;
  48058. /**
  48059. * Resize the texture using a ratio.
  48060. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  48061. */
  48062. scale(ratio: number): void;
  48063. /**
  48064. * Get the texture reflection matrix used to rotate/transform the reflection.
  48065. * @returns the reflection matrix
  48066. */
  48067. getReflectionTextureMatrix(): Matrix;
  48068. /**
  48069. * Resize the texture to a new desired size.
  48070. * Be carrefull as it will recreate all the data in the new texture.
  48071. * @param size Define the new size. It can be:
  48072. * - a number for squared texture,
  48073. * - an object containing { width: number, height: number }
  48074. * - or an object containing a ratio { ratio: number }
  48075. */
  48076. resize(size: number | {
  48077. width: number;
  48078. height: number;
  48079. } | {
  48080. ratio: number;
  48081. }): void;
  48082. /**
  48083. * Renders all the objects from the render list into the texture.
  48084. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  48085. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  48086. */
  48087. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  48088. private _bestReflectionRenderTargetDimension;
  48089. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48090. private renderToTarget;
  48091. /**
  48092. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  48093. * This allowed control for front to back rendering or reversly depending of the special needs.
  48094. *
  48095. * @param renderingGroupId The rendering group id corresponding to its index
  48096. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  48097. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  48098. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  48099. */
  48100. 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;
  48101. /**
  48102. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  48103. *
  48104. * @param renderingGroupId The rendering group id corresponding to its index
  48105. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48106. */
  48107. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48108. /**
  48109. * Clones the texture.
  48110. * @returns the cloned texture
  48111. */
  48112. clone(): RenderTargetTexture;
  48113. /**
  48114. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48115. * @returns The JSON representation of the texture
  48116. */
  48117. serialize(): any;
  48118. /**
  48119. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  48120. */
  48121. disposeFramebufferObjects(): void;
  48122. /**
  48123. * Dispose the texture and release its associated resources.
  48124. */
  48125. dispose(): void;
  48126. /** @hidden */
  48127. _rebuild(): void;
  48128. /**
  48129. * Clear the info related to rendering groups preventing retention point in material dispose.
  48130. */
  48131. freeRenderingGroups(): void;
  48132. }
  48133. }
  48134. declare module BABYLON {
  48135. /**
  48136. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48137. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48138. */
  48139. class Texture extends BaseTexture {
  48140. /** nearest is mag = nearest and min = nearest and mip = linear */
  48141. static readonly NEAREST_SAMPLINGMODE: number;
  48142. /** nearest is mag = nearest and min = nearest and mip = linear */
  48143. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  48144. /** Bilinear is mag = linear and min = linear and mip = nearest */
  48145. static readonly BILINEAR_SAMPLINGMODE: number;
  48146. /** Bilinear is mag = linear and min = linear and mip = nearest */
  48147. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  48148. /** Trilinear is mag = linear and min = linear and mip = linear */
  48149. static readonly TRILINEAR_SAMPLINGMODE: number;
  48150. /** Trilinear is mag = linear and min = linear and mip = linear */
  48151. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  48152. /** mag = nearest and min = nearest and mip = nearest */
  48153. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  48154. /** mag = nearest and min = linear and mip = nearest */
  48155. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  48156. /** mag = nearest and min = linear and mip = linear */
  48157. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  48158. /** mag = nearest and min = linear and mip = none */
  48159. static readonly NEAREST_LINEAR: number;
  48160. /** mag = nearest and min = nearest and mip = none */
  48161. static readonly NEAREST_NEAREST: number;
  48162. /** mag = linear and min = nearest and mip = nearest */
  48163. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  48164. /** mag = linear and min = nearest and mip = linear */
  48165. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  48166. /** mag = linear and min = linear and mip = none */
  48167. static readonly LINEAR_LINEAR: number;
  48168. /** mag = linear and min = nearest and mip = none */
  48169. static readonly LINEAR_NEAREST: number;
  48170. /** Explicit coordinates mode */
  48171. static readonly EXPLICIT_MODE: number;
  48172. /** Spherical coordinates mode */
  48173. static readonly SPHERICAL_MODE: number;
  48174. /** Planar coordinates mode */
  48175. static readonly PLANAR_MODE: number;
  48176. /** Cubic coordinates mode */
  48177. static readonly CUBIC_MODE: number;
  48178. /** Projection coordinates mode */
  48179. static readonly PROJECTION_MODE: number;
  48180. /** Inverse Cubic coordinates mode */
  48181. static readonly SKYBOX_MODE: number;
  48182. /** Inverse Cubic coordinates mode */
  48183. static readonly INVCUBIC_MODE: number;
  48184. /** Equirectangular coordinates mode */
  48185. static readonly EQUIRECTANGULAR_MODE: number;
  48186. /** Equirectangular Fixed coordinates mode */
  48187. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  48188. /** Equirectangular Fixed Mirrored coordinates mode */
  48189. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  48190. /** Texture is not repeating outside of 0..1 UVs */
  48191. static readonly CLAMP_ADDRESSMODE: number;
  48192. /** Texture is repeating outside of 0..1 UVs */
  48193. static readonly WRAP_ADDRESSMODE: number;
  48194. /** Texture is repeating and mirrored */
  48195. static readonly MIRROR_ADDRESSMODE: number;
  48196. /**
  48197. * 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
  48198. */
  48199. static UseSerializedUrlIfAny: boolean;
  48200. /**
  48201. * Define the url of the texture.
  48202. */
  48203. url: Nullable<string>;
  48204. /**
  48205. * Define an offset on the texture to offset the u coordinates of the UVs
  48206. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48207. */
  48208. uOffset: number;
  48209. /**
  48210. * Define an offset on the texture to offset the v coordinates of the UVs
  48211. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  48212. */
  48213. vOffset: number;
  48214. /**
  48215. * Define an offset on the texture to scale the u coordinates of the UVs
  48216. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48217. */
  48218. uScale: number;
  48219. /**
  48220. * Define an offset on the texture to scale the v coordinates of the UVs
  48221. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  48222. */
  48223. vScale: number;
  48224. /**
  48225. * Define an offset on the texture to rotate around the u coordinates of the UVs
  48226. * @see http://doc.babylonjs.com/how_to/more_materials
  48227. */
  48228. uAng: number;
  48229. /**
  48230. * Define an offset on the texture to rotate around the v coordinates of the UVs
  48231. * @see http://doc.babylonjs.com/how_to/more_materials
  48232. */
  48233. vAng: number;
  48234. /**
  48235. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  48236. * @see http://doc.babylonjs.com/how_to/more_materials
  48237. */
  48238. wAng: number;
  48239. /**
  48240. * Defines the center of rotation (U)
  48241. */
  48242. uRotationCenter: number;
  48243. /**
  48244. * Defines the center of rotation (V)
  48245. */
  48246. vRotationCenter: number;
  48247. /**
  48248. * Defines the center of rotation (W)
  48249. */
  48250. wRotationCenter: number;
  48251. /**
  48252. * Are mip maps generated for this texture or not.
  48253. */
  48254. readonly noMipmap: boolean;
  48255. private _noMipmap;
  48256. /** @hidden */
  48257. _invertY: boolean;
  48258. private _rowGenerationMatrix;
  48259. private _cachedTextureMatrix;
  48260. private _projectionModeMatrix;
  48261. private _t0;
  48262. private _t1;
  48263. private _t2;
  48264. private _cachedUOffset;
  48265. private _cachedVOffset;
  48266. private _cachedUScale;
  48267. private _cachedVScale;
  48268. private _cachedUAng;
  48269. private _cachedVAng;
  48270. private _cachedWAng;
  48271. private _cachedProjectionMatrixId;
  48272. private _cachedCoordinatesMode;
  48273. /** @hidden */
  48274. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  48275. private _deleteBuffer;
  48276. protected _format: Nullable<number>;
  48277. private _delayedOnLoad;
  48278. private _delayedOnError;
  48279. /**
  48280. * Observable triggered once the texture has been loaded.
  48281. */
  48282. onLoadObservable: Observable<Texture>;
  48283. protected _isBlocking: boolean;
  48284. /**
  48285. * Is the texture preventing material to render while loading.
  48286. * If false, a default texture will be used instead of the loading one during the preparation step.
  48287. */
  48288. isBlocking: boolean;
  48289. /**
  48290. * Get the current sampling mode associated with the texture.
  48291. */
  48292. readonly samplingMode: number;
  48293. /**
  48294. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  48295. */
  48296. readonly invertY: boolean;
  48297. /**
  48298. * Instantiates a new texture.
  48299. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48300. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48301. * @param url define the url of the picture to load as a texture
  48302. * @param scene define the scene the texture will belong to
  48303. * @param noMipmap define if the texture will require mip maps or not
  48304. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48305. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48306. * @param onLoad define a callback triggered when the texture has been loaded
  48307. * @param onError define a callback triggered when an error occurred during the loading session
  48308. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48309. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48310. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48311. */
  48312. 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);
  48313. /**
  48314. * Update the url (and optional buffer) of this texture if url was null during construction.
  48315. * @param url the url of the texture
  48316. * @param buffer the buffer of the texture (defaults to null)
  48317. * @param onLoad callback called when the texture is loaded (defaults to null)
  48318. */
  48319. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  48320. /**
  48321. * Finish the loading sequence of a texture flagged as delayed load.
  48322. * @hidden
  48323. */
  48324. delayLoad(): void;
  48325. private _prepareRowForTextureGeneration;
  48326. /**
  48327. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  48328. * @returns the transform matrix of the texture.
  48329. */
  48330. getTextureMatrix(): Matrix;
  48331. /**
  48332. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  48333. * @returns The reflection texture transform
  48334. */
  48335. getReflectionTextureMatrix(): Matrix;
  48336. /**
  48337. * Clones the texture.
  48338. * @returns the cloned texture
  48339. */
  48340. clone(): Texture;
  48341. /**
  48342. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48343. * @returns The JSON representation of the texture
  48344. */
  48345. serialize(): any;
  48346. /**
  48347. * Get the current class name of the texture useful for serialization or dynamic coding.
  48348. * @returns "Texture"
  48349. */
  48350. getClassName(): string;
  48351. /**
  48352. * Dispose the texture and release its associated resources.
  48353. */
  48354. dispose(): void;
  48355. /**
  48356. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  48357. * @param parsedTexture Define the JSON representation of the texture
  48358. * @param scene Define the scene the parsed texture should be instantiated in
  48359. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48360. * @returns The parsed texture if successful
  48361. */
  48362. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  48363. /**
  48364. * Creates a texture from its base 64 representation.
  48365. * @param data Define the base64 payload without the data: prefix
  48366. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48367. * @param scene Define the scene the texture should belong to
  48368. * @param noMipmap Forces the texture to not create mip map information if true
  48369. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48370. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48371. * @param onLoad define a callback triggered when the texture has been loaded
  48372. * @param onError define a callback triggered when an error occurred during the loading session
  48373. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48374. * @returns the created texture
  48375. */
  48376. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  48377. /**
  48378. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  48379. * @param data Define the base64 payload without the data: prefix
  48380. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48381. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48382. * @param scene Define the scene the texture should belong to
  48383. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48384. * @param noMipmap Forces the texture to not create mip map information if true
  48385. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48386. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48387. * @param onLoad define a callback triggered when the texture has been loaded
  48388. * @param onError define a callback triggered when an error occurred during the loading session
  48389. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48390. * @returns the created texture
  48391. */
  48392. 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;
  48393. }
  48394. }
  48395. declare module BABYLON {
  48396. /**
  48397. * Settings for finer control over video usage
  48398. */
  48399. interface VideoTextureSettings {
  48400. /**
  48401. * Applies `autoplay` to video, if specified
  48402. */
  48403. autoPlay?: boolean;
  48404. /**
  48405. * Applies `loop` to video, if specified
  48406. */
  48407. loop?: boolean;
  48408. /**
  48409. * Automatically updates internal texture from video at every frame in the render loop
  48410. */
  48411. autoUpdateTexture: boolean;
  48412. /**
  48413. * Image src displayed during the video loading or until the user interacts with the video.
  48414. */
  48415. poster?: string;
  48416. }
  48417. /**
  48418. * If you want to display a video in your scene, this is the special texture for that.
  48419. * This special texture works similar to other textures, with the exception of a few parameters.
  48420. * @see https://doc.babylonjs.com/how_to/video_texture
  48421. */
  48422. class VideoTexture extends Texture {
  48423. /**
  48424. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  48425. */
  48426. readonly autoUpdateTexture: boolean;
  48427. /**
  48428. * The video instance used by the texture internally
  48429. */
  48430. readonly video: HTMLVideoElement;
  48431. private _onUserActionRequestedObservable;
  48432. /**
  48433. * Event triggerd when a dom action is required by the user to play the video.
  48434. * This happens due to recent changes in browser policies preventing video to auto start.
  48435. */
  48436. readonly onUserActionRequestedObservable: Observable<Texture>;
  48437. private _generateMipMaps;
  48438. private _engine;
  48439. private _stillImageCaptured;
  48440. private _displayingPosterTexture;
  48441. private _settings;
  48442. private _createInternalTextureOnEvent;
  48443. /**
  48444. * Creates a video texture.
  48445. * If you want to display a video in your scene, this is the special texture for that.
  48446. * This special texture works similar to other textures, with the exception of a few parameters.
  48447. * @see https://doc.babylonjs.com/how_to/video_texture
  48448. * @param name optional name, will detect from video source, if not defined
  48449. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  48450. * @param scene is obviously the current scene.
  48451. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  48452. * @param invertY is false by default but can be used to invert video on Y axis
  48453. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  48454. * @param settings allows finer control over video usage
  48455. */
  48456. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  48457. private _getName;
  48458. private _getVideo;
  48459. private _createInternalTexture;
  48460. private reset;
  48461. /**
  48462. * @hidden Internal method to initiate `update`.
  48463. */
  48464. _rebuild(): void;
  48465. /**
  48466. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  48467. */
  48468. update(): void;
  48469. /**
  48470. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  48471. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  48472. */
  48473. updateTexture(isVisible: boolean): void;
  48474. protected _updateInternalTexture: (e?: Event | undefined) => void;
  48475. /**
  48476. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  48477. * @param url New url.
  48478. */
  48479. updateURL(url: string): void;
  48480. /**
  48481. * Dispose the texture and release its associated resources.
  48482. */
  48483. dispose(): void;
  48484. /**
  48485. * Creates a video texture straight from your WebCam video feed.
  48486. * @param scene Define the scene the texture should be created in
  48487. * @param onReady Define a callback to triggered once the texture will be ready
  48488. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  48489. */
  48490. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  48491. minWidth: number;
  48492. maxWidth: number;
  48493. minHeight: number;
  48494. maxHeight: number;
  48495. deviceId: string;
  48496. }): void;
  48497. }
  48498. }
  48499. declare var DracoDecoderModule: any;
  48500. declare var WebAssembly: any;
  48501. declare module BABYLON {
  48502. /**
  48503. * Configuration for Draco compression
  48504. */
  48505. interface IDracoCompressionConfiguration {
  48506. /**
  48507. * Configuration for the decoder.
  48508. */
  48509. decoder?: {
  48510. /**
  48511. * The url to the WebAssembly module.
  48512. */
  48513. wasmUrl?: string;
  48514. /**
  48515. * The url to the WebAssembly binary.
  48516. */
  48517. wasmBinaryUrl?: string;
  48518. /**
  48519. * The url to the fallback JavaScript module.
  48520. */
  48521. fallbackUrl?: string;
  48522. };
  48523. }
  48524. /**
  48525. * Draco compression (https://google.github.io/draco/)
  48526. *
  48527. * This class wraps the Draco module.
  48528. *
  48529. * **Encoder**
  48530. *
  48531. * The encoder is not currently implemented.
  48532. *
  48533. * **Decoder**
  48534. *
  48535. * 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.
  48536. *
  48537. * To update the configuration, use the following code:
  48538. * ```javascript
  48539. * BABYLON.DracoCompression.Configuration = {
  48540. * decoder: {
  48541. * wasmUrl: "<url to the WebAssembly library>",
  48542. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48543. * fallbackUrl: "<url to the fallback JavaScript library>",
  48544. * }
  48545. * };
  48546. * ```
  48547. *
  48548. * 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.
  48549. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48550. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48551. *
  48552. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48553. * ```javascript
  48554. * var dracoCompression = new BABYLON.DracoCompression();
  48555. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48556. * [BABYLON.VertexBuffer.PositionKind]: 0
  48557. * });
  48558. * ```
  48559. *
  48560. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48561. */
  48562. class DracoCompression implements IDisposable {
  48563. private static _DecoderModulePromise;
  48564. /**
  48565. * The configuration. Defaults to the following urls:
  48566. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48567. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48568. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48569. */
  48570. static Configuration: IDracoCompressionConfiguration;
  48571. /**
  48572. * Returns true if the decoder is available.
  48573. */
  48574. static readonly DecoderAvailable: boolean;
  48575. /**
  48576. * Constructor
  48577. */
  48578. constructor();
  48579. /**
  48580. * Stop all async operations and release resources.
  48581. */
  48582. dispose(): void;
  48583. /**
  48584. * Decode Draco compressed mesh data to vertex data.
  48585. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48586. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48587. * @returns A promise that resolves with the decoded vertex data
  48588. */
  48589. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48590. [kind: string]: number;
  48591. }): Promise<VertexData>;
  48592. private static _GetDecoderModule;
  48593. private static _LoadScriptAsync;
  48594. private static _LoadFileAsync;
  48595. }
  48596. }
  48597. declare module BABYLON {
  48598. /**
  48599. * Particle emitter emitting particles from the inside of a box.
  48600. * It emits the particles randomly between 2 given directions.
  48601. */
  48602. class BoxParticleEmitter implements IParticleEmitterType {
  48603. /**
  48604. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48605. */
  48606. direction1: Vector3;
  48607. /**
  48608. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48609. */
  48610. direction2: Vector3;
  48611. /**
  48612. * 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.
  48613. */
  48614. minEmitBox: Vector3;
  48615. /**
  48616. * 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.
  48617. */
  48618. maxEmitBox: Vector3;
  48619. /**
  48620. * Creates a new instance BoxParticleEmitter
  48621. */
  48622. constructor();
  48623. /**
  48624. * Called by the particle System when the direction is computed for the created particle.
  48625. * @param worldMatrix is the world matrix of the particle system
  48626. * @param directionToUpdate is the direction vector to update with the result
  48627. * @param particle is the particle we are computed the direction for
  48628. */
  48629. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48630. /**
  48631. * Called by the particle System when the position is computed for the created particle.
  48632. * @param worldMatrix is the world matrix of the particle system
  48633. * @param positionToUpdate is the position vector to update with the result
  48634. * @param particle is the particle we are computed the position for
  48635. */
  48636. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48637. /**
  48638. * Clones the current emitter and returns a copy of it
  48639. * @returns the new emitter
  48640. */
  48641. clone(): BoxParticleEmitter;
  48642. /**
  48643. * Called by the GPUParticleSystem to setup the update shader
  48644. * @param effect defines the update shader
  48645. */
  48646. applyToShader(effect: Effect): void;
  48647. /**
  48648. * Returns a string to use to update the GPU particles update shader
  48649. * @returns a string containng the defines string
  48650. */
  48651. getEffectDefines(): string;
  48652. /**
  48653. * Returns the string "BoxParticleEmitter"
  48654. * @returns a string containing the class name
  48655. */
  48656. getClassName(): string;
  48657. /**
  48658. * Serializes the particle system to a JSON object.
  48659. * @returns the JSON object
  48660. */
  48661. serialize(): any;
  48662. /**
  48663. * Parse properties from a JSON object
  48664. * @param serializationObject defines the JSON object
  48665. */
  48666. parse(serializationObject: any): void;
  48667. }
  48668. }
  48669. declare module BABYLON {
  48670. /**
  48671. * Particle emitter emitting particles from the inside of a cone.
  48672. * It emits the particles alongside the cone volume from the base to the particle.
  48673. * The emission direction might be randomized.
  48674. */
  48675. class ConeParticleEmitter implements IParticleEmitterType {
  48676. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48677. directionRandomizer: number;
  48678. private _radius;
  48679. private _angle;
  48680. private _height;
  48681. /**
  48682. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  48683. */
  48684. radiusRange: number;
  48685. /**
  48686. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  48687. */
  48688. heightRange: number;
  48689. /**
  48690. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  48691. */
  48692. emitFromSpawnPointOnly: boolean;
  48693. /**
  48694. * Gets or sets the radius of the emission cone
  48695. */
  48696. radius: number;
  48697. /**
  48698. * Gets or sets the angle of the emission cone
  48699. */
  48700. angle: number;
  48701. private _buildHeight;
  48702. /**
  48703. * Creates a new instance ConeParticleEmitter
  48704. * @param radius the radius of the emission cone (1 by default)
  48705. * @param angles the cone base angle (PI by default)
  48706. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  48707. */
  48708. constructor(radius?: number, angle?: number,
  48709. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48710. directionRandomizer?: number);
  48711. /**
  48712. * Called by the particle System when the direction is computed for the created particle.
  48713. * @param worldMatrix is the world matrix of the particle system
  48714. * @param directionToUpdate is the direction vector to update with the result
  48715. * @param particle is the particle we are computed the direction for
  48716. */
  48717. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48718. /**
  48719. * Called by the particle System when the position is computed for the created particle.
  48720. * @param worldMatrix is the world matrix of the particle system
  48721. * @param positionToUpdate is the position vector to update with the result
  48722. * @param particle is the particle we are computed the position for
  48723. */
  48724. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48725. /**
  48726. * Clones the current emitter and returns a copy of it
  48727. * @returns the new emitter
  48728. */
  48729. clone(): ConeParticleEmitter;
  48730. /**
  48731. * Called by the GPUParticleSystem to setup the update shader
  48732. * @param effect defines the update shader
  48733. */
  48734. applyToShader(effect: Effect): void;
  48735. /**
  48736. * Returns a string to use to update the GPU particles update shader
  48737. * @returns a string containng the defines string
  48738. */
  48739. getEffectDefines(): string;
  48740. /**
  48741. * Returns the string "ConeParticleEmitter"
  48742. * @returns a string containing the class name
  48743. */
  48744. getClassName(): string;
  48745. /**
  48746. * Serializes the particle system to a JSON object.
  48747. * @returns the JSON object
  48748. */
  48749. serialize(): any;
  48750. /**
  48751. * Parse properties from a JSON object
  48752. * @param serializationObject defines the JSON object
  48753. */
  48754. parse(serializationObject: any): void;
  48755. }
  48756. }
  48757. declare module BABYLON {
  48758. /**
  48759. * Particle emitter emitting particles from the inside of a cylinder.
  48760. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  48761. */
  48762. class CylinderParticleEmitter implements IParticleEmitterType {
  48763. /**
  48764. * The radius of the emission cylinder.
  48765. */
  48766. radius: number;
  48767. /**
  48768. * The height of the emission cylinder.
  48769. */
  48770. height: number;
  48771. /**
  48772. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48773. */
  48774. radiusRange: number;
  48775. /**
  48776. * How much to randomize the particle direction [0-1].
  48777. */
  48778. directionRandomizer: number;
  48779. /**
  48780. * Creates a new instance CylinderParticleEmitter
  48781. * @param radius the radius of the emission cylinder (1 by default)
  48782. * @param height the height of the emission cylinder (1 by default)
  48783. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48784. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48785. */
  48786. constructor(
  48787. /**
  48788. * The radius of the emission cylinder.
  48789. */
  48790. radius?: number,
  48791. /**
  48792. * The height of the emission cylinder.
  48793. */
  48794. height?: number,
  48795. /**
  48796. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48797. */
  48798. radiusRange?: number,
  48799. /**
  48800. * How much to randomize the particle direction [0-1].
  48801. */
  48802. directionRandomizer?: number);
  48803. /**
  48804. * Called by the particle System when the direction is computed for the created particle.
  48805. * @param worldMatrix is the world matrix of the particle system
  48806. * @param directionToUpdate is the direction vector to update with the result
  48807. * @param particle is the particle we are computed the direction for
  48808. */
  48809. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48810. /**
  48811. * Called by the particle System when the position is computed for the created particle.
  48812. * @param worldMatrix is the world matrix of the particle system
  48813. * @param positionToUpdate is the position vector to update with the result
  48814. * @param particle is the particle we are computed the position for
  48815. */
  48816. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48817. /**
  48818. * Clones the current emitter and returns a copy of it
  48819. * @returns the new emitter
  48820. */
  48821. clone(): CylinderParticleEmitter;
  48822. /**
  48823. * Called by the GPUParticleSystem to setup the update shader
  48824. * @param effect defines the update shader
  48825. */
  48826. applyToShader(effect: Effect): void;
  48827. /**
  48828. * Returns a string to use to update the GPU particles update shader
  48829. * @returns a string containng the defines string
  48830. */
  48831. getEffectDefines(): string;
  48832. /**
  48833. * Returns the string "CylinderParticleEmitter"
  48834. * @returns a string containing the class name
  48835. */
  48836. getClassName(): string;
  48837. /**
  48838. * Serializes the particle system to a JSON object.
  48839. * @returns the JSON object
  48840. */
  48841. serialize(): any;
  48842. /**
  48843. * Parse properties from a JSON object
  48844. * @param serializationObject defines the JSON object
  48845. */
  48846. parse(serializationObject: any): void;
  48847. }
  48848. /**
  48849. * Particle emitter emitting particles from the inside of a cylinder.
  48850. * It emits the particles randomly between two vectors.
  48851. */
  48852. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  48853. /**
  48854. * The min limit of the emission direction.
  48855. */
  48856. direction1: Vector3;
  48857. /**
  48858. * The max limit of the emission direction.
  48859. */
  48860. direction2: Vector3;
  48861. /**
  48862. * Creates a new instance CylinderDirectedParticleEmitter
  48863. * @param radius the radius of the emission cylinder (1 by default)
  48864. * @param height the height of the emission cylinder (1 by default)
  48865. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48866. * @param direction1 the min limit of the emission direction (up vector by default)
  48867. * @param direction2 the max limit of the emission direction (up vector by default)
  48868. */
  48869. constructor(radius?: number, height?: number, radiusRange?: number,
  48870. /**
  48871. * The min limit of the emission direction.
  48872. */
  48873. direction1?: Vector3,
  48874. /**
  48875. * The max limit of the emission direction.
  48876. */
  48877. direction2?: Vector3);
  48878. /**
  48879. * Called by the particle System when the direction is computed for the created particle.
  48880. * @param worldMatrix is the world matrix of the particle system
  48881. * @param directionToUpdate is the direction vector to update with the result
  48882. * @param particle is the particle we are computed the direction for
  48883. */
  48884. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48885. /**
  48886. * Clones the current emitter and returns a copy of it
  48887. * @returns the new emitter
  48888. */
  48889. clone(): CylinderDirectedParticleEmitter;
  48890. /**
  48891. * Called by the GPUParticleSystem to setup the update shader
  48892. * @param effect defines the update shader
  48893. */
  48894. applyToShader(effect: Effect): void;
  48895. /**
  48896. * Returns a string to use to update the GPU particles update shader
  48897. * @returns a string containng the defines string
  48898. */
  48899. getEffectDefines(): string;
  48900. /**
  48901. * Returns the string "CylinderDirectedParticleEmitter"
  48902. * @returns a string containing the class name
  48903. */
  48904. getClassName(): string;
  48905. /**
  48906. * Serializes the particle system to a JSON object.
  48907. * @returns the JSON object
  48908. */
  48909. serialize(): any;
  48910. /**
  48911. * Parse properties from a JSON object
  48912. * @param serializationObject defines the JSON object
  48913. */
  48914. parse(serializationObject: any): void;
  48915. }
  48916. }
  48917. declare module BABYLON {
  48918. /**
  48919. * Particle emitter emitting particles from the inside of a hemisphere.
  48920. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  48921. */
  48922. class HemisphericParticleEmitter implements IParticleEmitterType {
  48923. /**
  48924. * The radius of the emission hemisphere.
  48925. */
  48926. radius: number;
  48927. /**
  48928. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48929. */
  48930. radiusRange: number;
  48931. /**
  48932. * How much to randomize the particle direction [0-1].
  48933. */
  48934. directionRandomizer: number;
  48935. /**
  48936. * Creates a new instance HemisphericParticleEmitter
  48937. * @param radius the radius of the emission hemisphere (1 by default)
  48938. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48939. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48940. */
  48941. constructor(
  48942. /**
  48943. * The radius of the emission hemisphere.
  48944. */
  48945. radius?: number,
  48946. /**
  48947. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48948. */
  48949. radiusRange?: number,
  48950. /**
  48951. * How much to randomize the particle direction [0-1].
  48952. */
  48953. directionRandomizer?: number);
  48954. /**
  48955. * Called by the particle System when the direction is computed for the created particle.
  48956. * @param worldMatrix is the world matrix of the particle system
  48957. * @param directionToUpdate is the direction vector to update with the result
  48958. * @param particle is the particle we are computed the direction for
  48959. */
  48960. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48961. /**
  48962. * Called by the particle System when the position is computed for the created particle.
  48963. * @param worldMatrix is the world matrix of the particle system
  48964. * @param positionToUpdate is the position vector to update with the result
  48965. * @param particle is the particle we are computed the position for
  48966. */
  48967. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48968. /**
  48969. * Clones the current emitter and returns a copy of it
  48970. * @returns the new emitter
  48971. */
  48972. clone(): HemisphericParticleEmitter;
  48973. /**
  48974. * Called by the GPUParticleSystem to setup the update shader
  48975. * @param effect defines the update shader
  48976. */
  48977. applyToShader(effect: Effect): void;
  48978. /**
  48979. * Returns a string to use to update the GPU particles update shader
  48980. * @returns a string containng the defines string
  48981. */
  48982. getEffectDefines(): string;
  48983. /**
  48984. * Returns the string "HemisphericParticleEmitter"
  48985. * @returns a string containing the class name
  48986. */
  48987. getClassName(): string;
  48988. /**
  48989. * Serializes the particle system to a JSON object.
  48990. * @returns the JSON object
  48991. */
  48992. serialize(): any;
  48993. /**
  48994. * Parse properties from a JSON object
  48995. * @param serializationObject defines the JSON object
  48996. */
  48997. parse(serializationObject: any): void;
  48998. }
  48999. }
  49000. declare module BABYLON {
  49001. /**
  49002. * Particle emitter represents a volume emitting particles.
  49003. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  49004. */
  49005. interface IParticleEmitterType {
  49006. /**
  49007. * Called by the particle System when the direction is computed for the created particle.
  49008. * @param worldMatrix is the world matrix of the particle system
  49009. * @param directionToUpdate is the direction vector to update with the result
  49010. * @param particle is the particle we are computed the direction for
  49011. */
  49012. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49013. /**
  49014. * Called by the particle System when the position is computed for the created particle.
  49015. * @param worldMatrix is the world matrix of the particle system
  49016. * @param positionToUpdate is the position vector to update with the result
  49017. * @param particle is the particle we are computed the position for
  49018. */
  49019. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49020. /**
  49021. * Clones the current emitter and returns a copy of it
  49022. * @returns the new emitter
  49023. */
  49024. clone(): IParticleEmitterType;
  49025. /**
  49026. * Called by the GPUParticleSystem to setup the update shader
  49027. * @param effect defines the update shader
  49028. */
  49029. applyToShader(effect: Effect): void;
  49030. /**
  49031. * Returns a string to use to update the GPU particles update shader
  49032. * @returns the effect defines string
  49033. */
  49034. getEffectDefines(): string;
  49035. /**
  49036. * Returns a string representing the class name
  49037. * @returns a string containing the class name
  49038. */
  49039. getClassName(): string;
  49040. /**
  49041. * Serializes the particle system to a JSON object.
  49042. * @returns the JSON object
  49043. */
  49044. serialize(): any;
  49045. /**
  49046. * Parse properties from a JSON object
  49047. * @param serializationObject defines the JSON object
  49048. */
  49049. parse(serializationObject: any): void;
  49050. }
  49051. }
  49052. declare module BABYLON {
  49053. /**
  49054. * Particle emitter emitting particles from a point.
  49055. * It emits the particles randomly between 2 given directions.
  49056. */
  49057. class PointParticleEmitter implements IParticleEmitterType {
  49058. /**
  49059. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  49060. */
  49061. direction1: Vector3;
  49062. /**
  49063. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  49064. */
  49065. direction2: Vector3;
  49066. /**
  49067. * Creates a new instance PointParticleEmitter
  49068. */
  49069. constructor();
  49070. /**
  49071. * Called by the particle System when the direction is computed for the created particle.
  49072. * @param worldMatrix is the world matrix of the particle system
  49073. * @param directionToUpdate is the direction vector to update with the result
  49074. * @param particle is the particle we are computed the direction for
  49075. */
  49076. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49077. /**
  49078. * Called by the particle System when the position is computed for the created particle.
  49079. * @param worldMatrix is the world matrix of the particle system
  49080. * @param positionToUpdate is the position vector to update with the result
  49081. * @param particle is the particle we are computed the position for
  49082. */
  49083. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49084. /**
  49085. * Clones the current emitter and returns a copy of it
  49086. * @returns the new emitter
  49087. */
  49088. clone(): PointParticleEmitter;
  49089. /**
  49090. * Called by the GPUParticleSystem to setup the update shader
  49091. * @param effect defines the update shader
  49092. */
  49093. applyToShader(effect: Effect): void;
  49094. /**
  49095. * Returns a string to use to update the GPU particles update shader
  49096. * @returns a string containng the defines string
  49097. */
  49098. getEffectDefines(): string;
  49099. /**
  49100. * Returns the string "PointParticleEmitter"
  49101. * @returns a string containing the class name
  49102. */
  49103. getClassName(): string;
  49104. /**
  49105. * Serializes the particle system to a JSON object.
  49106. * @returns the JSON object
  49107. */
  49108. serialize(): any;
  49109. /**
  49110. * Parse properties from a JSON object
  49111. * @param serializationObject defines the JSON object
  49112. */
  49113. parse(serializationObject: any): void;
  49114. }
  49115. }
  49116. declare module BABYLON {
  49117. /**
  49118. * Particle emitter emitting particles from the inside of a sphere.
  49119. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  49120. */
  49121. class SphereParticleEmitter implements IParticleEmitterType {
  49122. /**
  49123. * The radius of the emission sphere.
  49124. */
  49125. radius: number;
  49126. /**
  49127. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49128. */
  49129. radiusRange: number;
  49130. /**
  49131. * How much to randomize the particle direction [0-1].
  49132. */
  49133. directionRandomizer: number;
  49134. /**
  49135. * Creates a new instance SphereParticleEmitter
  49136. * @param radius the radius of the emission sphere (1 by default)
  49137. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  49138. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  49139. */
  49140. constructor(
  49141. /**
  49142. * The radius of the emission sphere.
  49143. */
  49144. radius?: number,
  49145. /**
  49146. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  49147. */
  49148. radiusRange?: number,
  49149. /**
  49150. * How much to randomize the particle direction [0-1].
  49151. */
  49152. directionRandomizer?: number);
  49153. /**
  49154. * Called by the particle System when the direction is computed for the created particle.
  49155. * @param worldMatrix is the world matrix of the particle system
  49156. * @param directionToUpdate is the direction vector to update with the result
  49157. * @param particle is the particle we are computed the direction for
  49158. */
  49159. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49160. /**
  49161. * Called by the particle System when the position is computed for the created particle.
  49162. * @param worldMatrix is the world matrix of the particle system
  49163. * @param positionToUpdate is the position vector to update with the result
  49164. * @param particle is the particle we are computed the position for
  49165. */
  49166. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  49167. /**
  49168. * Clones the current emitter and returns a copy of it
  49169. * @returns the new emitter
  49170. */
  49171. clone(): SphereParticleEmitter;
  49172. /**
  49173. * Called by the GPUParticleSystem to setup the update shader
  49174. * @param effect defines the update shader
  49175. */
  49176. applyToShader(effect: Effect): void;
  49177. /**
  49178. * Returns a string to use to update the GPU particles update shader
  49179. * @returns a string containng the defines string
  49180. */
  49181. getEffectDefines(): string;
  49182. /**
  49183. * Returns the string "SphereParticleEmitter"
  49184. * @returns a string containing the class name
  49185. */
  49186. getClassName(): string;
  49187. /**
  49188. * Serializes the particle system to a JSON object.
  49189. * @returns the JSON object
  49190. */
  49191. serialize(): any;
  49192. /**
  49193. * Parse properties from a JSON object
  49194. * @param serializationObject defines the JSON object
  49195. */
  49196. parse(serializationObject: any): void;
  49197. }
  49198. /**
  49199. * Particle emitter emitting particles from the inside of a sphere.
  49200. * It emits the particles randomly between two vectors.
  49201. */
  49202. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  49203. /**
  49204. * The min limit of the emission direction.
  49205. */
  49206. direction1: Vector3;
  49207. /**
  49208. * The max limit of the emission direction.
  49209. */
  49210. direction2: Vector3;
  49211. /**
  49212. * Creates a new instance SphereDirectedParticleEmitter
  49213. * @param radius the radius of the emission sphere (1 by default)
  49214. * @param direction1 the min limit of the emission direction (up vector by default)
  49215. * @param direction2 the max limit of the emission direction (up vector by default)
  49216. */
  49217. constructor(radius?: number,
  49218. /**
  49219. * The min limit of the emission direction.
  49220. */
  49221. direction1?: Vector3,
  49222. /**
  49223. * The max limit of the emission direction.
  49224. */
  49225. direction2?: Vector3);
  49226. /**
  49227. * Called by the particle System when the direction is computed for the created particle.
  49228. * @param worldMatrix is the world matrix of the particle system
  49229. * @param directionToUpdate is the direction vector to update with the result
  49230. * @param particle is the particle we are computed the direction for
  49231. */
  49232. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  49233. /**
  49234. * Clones the current emitter and returns a copy of it
  49235. * @returns the new emitter
  49236. */
  49237. clone(): SphereDirectedParticleEmitter;
  49238. /**
  49239. * Called by the GPUParticleSystem to setup the update shader
  49240. * @param effect defines the update shader
  49241. */
  49242. applyToShader(effect: Effect): void;
  49243. /**
  49244. * Returns a string to use to update the GPU particles update shader
  49245. * @returns a string containng the defines string
  49246. */
  49247. getEffectDefines(): string;
  49248. /**
  49249. * Returns the string "SphereDirectedParticleEmitter"
  49250. * @returns a string containing the class name
  49251. */
  49252. getClassName(): string;
  49253. /**
  49254. * Serializes the particle system to a JSON object.
  49255. * @returns the JSON object
  49256. */
  49257. serialize(): any;
  49258. /**
  49259. * Parse properties from a JSON object
  49260. * @param serializationObject defines the JSON object
  49261. */
  49262. parse(serializationObject: any): void;
  49263. }
  49264. }
  49265. declare module BABYLON {
  49266. /**
  49267. * AmmoJS Physics plugin
  49268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49269. * @see https://github.com/kripken/ammo.js/
  49270. */
  49271. class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49272. private _useDeltaForWorldStep;
  49273. /**
  49274. * Reference to the Ammo library
  49275. */
  49276. bjsAMMO: any;
  49277. /**
  49278. * Created ammoJS world which physics bodies are added to
  49279. */
  49280. world: any;
  49281. /**
  49282. * Name of the plugin
  49283. */
  49284. name: string;
  49285. private _timeStep;
  49286. private _fixedTimeStep;
  49287. private _maxSteps;
  49288. private _tmpQuaternion;
  49289. private _tmpAmmoTransform;
  49290. private _tmpAmmoQuaternion;
  49291. private _tmpAmmoConcreteContactResultCallback;
  49292. private _collisionConfiguration;
  49293. private _dispatcher;
  49294. private _overlappingPairCache;
  49295. private _solver;
  49296. private _tmpAmmoVectorA;
  49297. private _tmpAmmoVectorB;
  49298. private _tmpAmmoVectorC;
  49299. private _tmpContactCallbackResult;
  49300. private static readonly DISABLE_COLLISION_FLAG;
  49301. private static readonly KINEMATIC_FLAG;
  49302. private static readonly DISABLE_DEACTIVATION_FLAG;
  49303. /**
  49304. * Initializes the ammoJS plugin
  49305. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49306. */
  49307. constructor(_useDeltaForWorldStep?: boolean);
  49308. /**
  49309. * Sets the gravity of the physics world (m/(s^2))
  49310. * @param gravity Gravity to set
  49311. */
  49312. setGravity(gravity: Vector3): void;
  49313. /**
  49314. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49315. * @param timeStep timestep to use in seconds
  49316. */
  49317. setTimeStep(timeStep: number): void;
  49318. /**
  49319. * 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)
  49320. * @param fixedTimeStep fixedTimeStep to use in seconds
  49321. */
  49322. setFixedTimeStep(fixedTimeStep: number): void;
  49323. /**
  49324. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49325. * @param maxSteps the maximum number of steps by the physics engine per frame
  49326. */
  49327. setMaxSteps(maxSteps: number): void;
  49328. /**
  49329. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49330. * @returns the current timestep in seconds
  49331. */
  49332. getTimeStep(): number;
  49333. private _isImpostorInContact;
  49334. private _isImpostorPairInContact;
  49335. private _stepSimulation;
  49336. /**
  49337. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49338. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49339. * After the step the babylon meshes are set to the position of the physics imposters
  49340. * @param delta amount of time to step forward
  49341. * @param impostors array of imposters to update before/after the step
  49342. */
  49343. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49344. /**
  49345. * Applies an implulse on the imposter
  49346. * @param impostor imposter to apply impulse
  49347. * @param force amount of force to be applied to the imposter
  49348. * @param contactPoint the location to apply the impulse on the imposter
  49349. */
  49350. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49351. /**
  49352. * Applies a force on the imposter
  49353. * @param impostor imposter to apply force
  49354. * @param force amount of force to be applied to the imposter
  49355. * @param contactPoint the location to apply the force on the imposter
  49356. */
  49357. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49358. /**
  49359. * Creates a physics body using the plugin
  49360. * @param impostor the imposter to create the physics body on
  49361. */
  49362. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49363. /**
  49364. * Removes the physics body from the imposter and disposes of the body's memory
  49365. * @param impostor imposter to remove the physics body from
  49366. */
  49367. removePhysicsBody(impostor: PhysicsImpostor): void;
  49368. /**
  49369. * Generates a joint
  49370. * @param impostorJoint the imposter joint to create the joint with
  49371. */
  49372. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49373. /**
  49374. * Removes a joint
  49375. * @param impostorJoint the imposter joint to remove the joint from
  49376. */
  49377. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49378. private _addMeshVerts;
  49379. private _createShape;
  49380. /**
  49381. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49382. * @param impostor imposter containing the physics body and babylon object
  49383. */
  49384. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49385. /**
  49386. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49387. * @param impostor imposter containing the physics body and babylon object
  49388. * @param newPosition new position
  49389. * @param newRotation new rotation
  49390. */
  49391. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49392. /**
  49393. * If this plugin is supported
  49394. * @returns true if its supported
  49395. */
  49396. isSupported(): boolean;
  49397. /**
  49398. * Sets the linear velocity of the physics body
  49399. * @param impostor imposter to set the velocity on
  49400. * @param velocity velocity to set
  49401. */
  49402. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49403. /**
  49404. * Sets the angular velocity of the physics body
  49405. * @param impostor imposter to set the velocity on
  49406. * @param velocity velocity to set
  49407. */
  49408. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49409. /**
  49410. * gets the linear velocity
  49411. * @param impostor imposter to get linear velocity from
  49412. * @returns linear velocity
  49413. */
  49414. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49415. /**
  49416. * gets the angular velocity
  49417. * @param impostor imposter to get angular velocity from
  49418. * @returns angular velocity
  49419. */
  49420. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49421. /**
  49422. * Sets the mass of physics body
  49423. * @param impostor imposter to set the mass on
  49424. * @param mass mass to set
  49425. */
  49426. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49427. /**
  49428. * Gets the mass of the physics body
  49429. * @param impostor imposter to get the mass from
  49430. * @returns mass
  49431. */
  49432. getBodyMass(impostor: PhysicsImpostor): number;
  49433. /**
  49434. * Gets friction of the impostor
  49435. * @param impostor impostor to get friction from
  49436. * @returns friction value
  49437. */
  49438. getBodyFriction(impostor: PhysicsImpostor): number;
  49439. /**
  49440. * Sets friction of the impostor
  49441. * @param impostor impostor to set friction on
  49442. * @param friction friction value
  49443. */
  49444. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49445. /**
  49446. * Gets restitution of the impostor
  49447. * @param impostor impostor to get restitution from
  49448. * @returns restitution value
  49449. */
  49450. getBodyRestitution(impostor: PhysicsImpostor): number;
  49451. /**
  49452. * Sets resitution of the impostor
  49453. * @param impostor impostor to set resitution on
  49454. * @param restitution resitution value
  49455. */
  49456. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49457. /**
  49458. * Sleeps the physics body and stops it from being active
  49459. * @param impostor impostor to sleep
  49460. */
  49461. sleepBody(impostor: PhysicsImpostor): void;
  49462. /**
  49463. * Activates the physics body
  49464. * @param impostor impostor to activate
  49465. */
  49466. wakeUpBody(impostor: PhysicsImpostor): void;
  49467. /**
  49468. * Updates the distance parameters of the joint
  49469. * @param joint joint to update
  49470. * @param maxDistance maximum distance of the joint
  49471. * @param minDistance minimum distance of the joint
  49472. */
  49473. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49474. /**
  49475. * Sets a motor on the joint
  49476. * @param joint joint to set motor on
  49477. * @param speed speed of the motor
  49478. * @param maxForce maximum force of the motor
  49479. * @param motorIndex index of the motor
  49480. */
  49481. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49482. /**
  49483. * Sets the motors limit
  49484. * @param joint joint to set limit on
  49485. * @param upperLimit upper limit
  49486. * @param lowerLimit lower limit
  49487. */
  49488. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49489. /**
  49490. * Syncs the position and rotation of a mesh with the impostor
  49491. * @param mesh mesh to sync
  49492. * @param impostor impostor to update the mesh with
  49493. */
  49494. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49495. /**
  49496. * Gets the radius of the impostor
  49497. * @param impostor impostor to get radius from
  49498. * @returns the radius
  49499. */
  49500. getRadius(impostor: PhysicsImpostor): number;
  49501. /**
  49502. * Gets the box size of the impostor
  49503. * @param impostor impostor to get box size from
  49504. * @param result the resulting box size
  49505. */
  49506. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49507. /**
  49508. * Disposes of the impostor
  49509. */
  49510. dispose(): void;
  49511. }
  49512. }
  49513. declare module BABYLON {
  49514. /** @hidden */
  49515. class CannonJSPlugin implements IPhysicsEnginePlugin {
  49516. private _useDeltaForWorldStep;
  49517. world: any;
  49518. name: string;
  49519. private _physicsMaterials;
  49520. private _fixedTimeStep;
  49521. BJSCANNON: any;
  49522. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  49523. setGravity(gravity: Vector3): void;
  49524. setTimeStep(timeStep: number): void;
  49525. getTimeStep(): number;
  49526. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49527. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49528. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49529. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49530. private _processChildMeshes;
  49531. removePhysicsBody(impostor: PhysicsImpostor): void;
  49532. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49533. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49534. private _addMaterial;
  49535. private _checkWithEpsilon;
  49536. private _createShape;
  49537. private _createHeightmap;
  49538. private _minus90X;
  49539. private _plus90X;
  49540. private _tmpPosition;
  49541. private _tmpDeltaPosition;
  49542. private _tmpUnityRotation;
  49543. private _updatePhysicsBodyTransformation;
  49544. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49545. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49546. isSupported(): boolean;
  49547. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49548. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49549. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49550. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49551. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49552. getBodyMass(impostor: PhysicsImpostor): number;
  49553. getBodyFriction(impostor: PhysicsImpostor): number;
  49554. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49555. getBodyRestitution(impostor: PhysicsImpostor): number;
  49556. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49557. sleepBody(impostor: PhysicsImpostor): void;
  49558. wakeUpBody(impostor: PhysicsImpostor): void;
  49559. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49560. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49561. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49562. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49563. getRadius(impostor: PhysicsImpostor): number;
  49564. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49565. dispose(): void;
  49566. private _extendNamespace;
  49567. }
  49568. }
  49569. declare module BABYLON {
  49570. /** @hidden */
  49571. class OimoJSPlugin implements IPhysicsEnginePlugin {
  49572. world: any;
  49573. name: string;
  49574. BJSOIMO: any;
  49575. constructor(iterations?: number);
  49576. setGravity(gravity: Vector3): void;
  49577. setTimeStep(timeStep: number): void;
  49578. getTimeStep(): number;
  49579. private _tmpImpostorsArray;
  49580. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49581. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49582. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49583. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49584. private _tmpPositionVector;
  49585. removePhysicsBody(impostor: PhysicsImpostor): void;
  49586. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49587. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49588. isSupported(): boolean;
  49589. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49590. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49591. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49592. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49593. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49594. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49595. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49596. getBodyMass(impostor: PhysicsImpostor): number;
  49597. getBodyFriction(impostor: PhysicsImpostor): number;
  49598. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49599. getBodyRestitution(impostor: PhysicsImpostor): number;
  49600. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49601. sleepBody(impostor: PhysicsImpostor): void;
  49602. wakeUpBody(impostor: PhysicsImpostor): void;
  49603. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49604. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  49605. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49606. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49607. getRadius(impostor: PhysicsImpostor): number;
  49608. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49609. dispose(): void;
  49610. }
  49611. }
  49612. declare module BABYLON {
  49613. /**
  49614. * This represents a set of one or more post processes in Babylon.
  49615. * A post process can be used to apply a shader to a texture after it is rendered.
  49616. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49617. */
  49618. class PostProcessRenderEffect {
  49619. private _postProcesses;
  49620. private _getPostProcesses;
  49621. private _singleInstance;
  49622. private _cameras;
  49623. private _indicesForCamera;
  49624. /**
  49625. * Name of the effect
  49626. * @hidden
  49627. */
  49628. _name: string;
  49629. /**
  49630. * Instantiates a post process render effect.
  49631. * A post process can be used to apply a shader to a texture after it is rendered.
  49632. * @param engine The engine the effect is tied to
  49633. * @param name The name of the effect
  49634. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  49635. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  49636. */
  49637. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  49638. /**
  49639. * Checks if all the post processes in the effect are supported.
  49640. */
  49641. readonly isSupported: boolean;
  49642. /**
  49643. * Updates the current state of the effect
  49644. * @hidden
  49645. */
  49646. _update(): void;
  49647. /**
  49648. * Attaches the effect on cameras
  49649. * @param cameras The camera to attach to.
  49650. * @hidden
  49651. */
  49652. _attachCameras(cameras: Camera): void;
  49653. /**
  49654. * Attaches the effect on cameras
  49655. * @param cameras The camera to attach to.
  49656. * @hidden
  49657. */
  49658. _attachCameras(cameras: Camera[]): void;
  49659. /**
  49660. * Detatches the effect on cameras
  49661. * @param cameras The camera to detatch from.
  49662. * @hidden
  49663. */
  49664. _detachCameras(cameras: Camera): void;
  49665. /**
  49666. * Detatches the effect on cameras
  49667. * @param cameras The camera to detatch from.
  49668. * @hidden
  49669. */
  49670. _detachCameras(cameras: Camera[]): void;
  49671. /**
  49672. * Enables the effect on given cameras
  49673. * @param cameras The camera to enable.
  49674. * @hidden
  49675. */
  49676. _enable(cameras: Camera): void;
  49677. /**
  49678. * Enables the effect on given cameras
  49679. * @param cameras The camera to enable.
  49680. * @hidden
  49681. */
  49682. _enable(cameras: Nullable<Camera[]>): void;
  49683. /**
  49684. * Disables the effect on the given cameras
  49685. * @param cameras The camera to disable.
  49686. * @hidden
  49687. */
  49688. _disable(cameras: Camera): void;
  49689. /**
  49690. * Disables the effect on the given cameras
  49691. * @param cameras The camera to disable.
  49692. * @hidden
  49693. */
  49694. _disable(cameras: Nullable<Camera[]>): void;
  49695. /**
  49696. * Gets a list of the post processes contained in the effect.
  49697. * @param camera The camera to get the post processes on.
  49698. * @returns The list of the post processes in the effect.
  49699. */
  49700. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  49701. }
  49702. }
  49703. declare module BABYLON {
  49704. /**
  49705. * PostProcessRenderPipeline
  49706. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49707. */
  49708. class PostProcessRenderPipeline {
  49709. private engine;
  49710. private _renderEffects;
  49711. private _renderEffectsForIsolatedPass;
  49712. /**
  49713. * @hidden
  49714. */
  49715. protected _cameras: Camera[];
  49716. /** @hidden */
  49717. _name: string;
  49718. /**
  49719. * Initializes a PostProcessRenderPipeline
  49720. * @param engine engine to add the pipeline to
  49721. * @param name name of the pipeline
  49722. */
  49723. constructor(engine: Engine, name: string);
  49724. /**
  49725. * "PostProcessRenderPipeline"
  49726. * @returns "PostProcessRenderPipeline"
  49727. */
  49728. getClassName(): string;
  49729. /**
  49730. * If all the render effects in the pipeline are support
  49731. */
  49732. readonly isSupported: boolean;
  49733. /**
  49734. * Adds an effect to the pipeline
  49735. * @param renderEffect the effect to add
  49736. */
  49737. addEffect(renderEffect: PostProcessRenderEffect): void;
  49738. /** @hidden */
  49739. _rebuild(): void;
  49740. /** @hidden */
  49741. _enableEffect(renderEffectName: string, cameras: Camera): void;
  49742. /** @hidden */
  49743. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  49744. /** @hidden */
  49745. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49746. /** @hidden */
  49747. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49748. /** @hidden */
  49749. _attachCameras(cameras: Camera, unique: boolean): void;
  49750. /** @hidden */
  49751. _attachCameras(cameras: Camera[], unique: boolean): void;
  49752. /** @hidden */
  49753. _detachCameras(cameras: Camera): void;
  49754. /** @hidden */
  49755. _detachCameras(cameras: Nullable<Camera[]>): void;
  49756. /** @hidden */
  49757. _update(): void;
  49758. /** @hidden */
  49759. _reset(): void;
  49760. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  49761. /**
  49762. * Disposes of the pipeline
  49763. */
  49764. dispose(): void;
  49765. }
  49766. }
  49767. declare module BABYLON {
  49768. /**
  49769. * PostProcessRenderPipelineManager class
  49770. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49771. */
  49772. class PostProcessRenderPipelineManager {
  49773. private _renderPipelines;
  49774. /**
  49775. * Initializes a PostProcessRenderPipelineManager
  49776. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49777. */
  49778. constructor();
  49779. /**
  49780. * Adds a pipeline to the manager
  49781. * @param renderPipeline The pipeline to add
  49782. */
  49783. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  49784. /**
  49785. * Attaches a camera to the pipeline
  49786. * @param renderPipelineName The name of the pipeline to attach to
  49787. * @param cameras the camera to attach
  49788. * @param unique if the camera can be attached multiple times to the pipeline
  49789. */
  49790. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  49791. /**
  49792. * Detaches a camera from the pipeline
  49793. * @param renderPipelineName The name of the pipeline to detach from
  49794. * @param cameras the camera to detach
  49795. */
  49796. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  49797. /**
  49798. * Enables an effect by name on a pipeline
  49799. * @param renderPipelineName the name of the pipeline to enable the effect in
  49800. * @param renderEffectName the name of the effect to enable
  49801. * @param cameras the cameras that the effect should be enabled on
  49802. */
  49803. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49804. /**
  49805. * Disables an effect by name on a pipeline
  49806. * @param renderPipelineName the name of the pipeline to disable the effect in
  49807. * @param renderEffectName the name of the effect to disable
  49808. * @param cameras the cameras that the effect should be disabled on
  49809. */
  49810. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49811. /**
  49812. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  49813. */
  49814. update(): void;
  49815. /** @hidden */
  49816. _rebuild(): void;
  49817. /**
  49818. * Disposes of the manager and pipelines
  49819. */
  49820. dispose(): void;
  49821. }
  49822. }
  49823. declare module BABYLON {
  49824. interface Scene {
  49825. /** @hidden (Backing field) */
  49826. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49827. /**
  49828. * Gets the postprocess render pipeline manager
  49829. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49830. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49831. */
  49832. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49833. }
  49834. /**
  49835. * Defines the Render Pipeline scene component responsible to rendering pipelines
  49836. */
  49837. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  49838. /**
  49839. * The component name helpfull to identify the component in the list of scene components.
  49840. */
  49841. readonly name: string;
  49842. /**
  49843. * The scene the component belongs to.
  49844. */
  49845. scene: Scene;
  49846. /**
  49847. * Creates a new instance of the component for the given scene
  49848. * @param scene Defines the scene to register the component in
  49849. */
  49850. constructor(scene: Scene);
  49851. /**
  49852. * Registers the component in a given scene
  49853. */
  49854. register(): void;
  49855. /**
  49856. * Rebuilds the elements related to this component in case of
  49857. * context lost for instance.
  49858. */
  49859. rebuild(): void;
  49860. /**
  49861. * Disposes the component and the associated ressources
  49862. */
  49863. dispose(): void;
  49864. private _gatherRenderTargets;
  49865. }
  49866. }
  49867. declare module BABYLON {
  49868. /**
  49869. * Helper class dealing with the extraction of spherical polynomial dataArray
  49870. * from a cube map.
  49871. */
  49872. class CubeMapToSphericalPolynomialTools {
  49873. private static FileFaces;
  49874. /**
  49875. * Converts a texture to the according Spherical Polynomial data.
  49876. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49877. *
  49878. * @param texture The texture to extract the information from.
  49879. * @return The Spherical Polynomial data.
  49880. */
  49881. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49882. /**
  49883. * Converts a cubemap to the according Spherical Polynomial data.
  49884. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49885. *
  49886. * @param cubeInfo The Cube map to extract the information from.
  49887. * @return The Spherical Polynomial data.
  49888. */
  49889. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49890. }
  49891. }
  49892. declare module BABYLON {
  49893. /**
  49894. * Header information of HDR texture files.
  49895. */
  49896. interface HDRInfo {
  49897. /**
  49898. * The height of the texture in pixels.
  49899. */
  49900. height: number;
  49901. /**
  49902. * The width of the texture in pixels.
  49903. */
  49904. width: number;
  49905. /**
  49906. * The index of the beginning of the data in the binary file.
  49907. */
  49908. dataPosition: number;
  49909. }
  49910. /**
  49911. * This groups tools to convert HDR texture to native colors array.
  49912. */
  49913. class HDRTools {
  49914. private static Ldexp;
  49915. private static Rgbe2float;
  49916. private static readStringLine;
  49917. /**
  49918. * Reads header information from an RGBE texture stored in a native array.
  49919. * More information on this format are available here:
  49920. * https://en.wikipedia.org/wiki/RGBE_image_format
  49921. *
  49922. * @param uint8array The binary file stored in native array.
  49923. * @return The header information.
  49924. */
  49925. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49926. /**
  49927. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49928. * This RGBE texture needs to store the information as a panorama.
  49929. *
  49930. * More information on this format are available here:
  49931. * https://en.wikipedia.org/wiki/RGBE_image_format
  49932. *
  49933. * @param buffer The binary file stored in an array buffer.
  49934. * @param size The expected size of the extracted cubemap.
  49935. * @return The Cube Map information.
  49936. */
  49937. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49938. /**
  49939. * Returns the pixels data extracted from an RGBE texture.
  49940. * This pixels will be stored left to right up to down in the R G B order in one array.
  49941. *
  49942. * More information on this format are available here:
  49943. * https://en.wikipedia.org/wiki/RGBE_image_format
  49944. *
  49945. * @param uint8array The binary file stored in an array buffer.
  49946. * @param hdrInfo The header information of the file.
  49947. * @return The pixels data in RGB right to left up to down order.
  49948. */
  49949. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49950. private static RGBE_ReadPixels_RLE;
  49951. }
  49952. }
  49953. declare module BABYLON {
  49954. /**
  49955. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49956. */
  49957. interface CubeMapInfo {
  49958. /**
  49959. * The pixel array for the front face.
  49960. * This is stored in format, left to right, up to down format.
  49961. */
  49962. front: Nullable<ArrayBufferView>;
  49963. /**
  49964. * The pixel array for the back face.
  49965. * This is stored in format, left to right, up to down format.
  49966. */
  49967. back: Nullable<ArrayBufferView>;
  49968. /**
  49969. * The pixel array for the left face.
  49970. * This is stored in format, left to right, up to down format.
  49971. */
  49972. left: Nullable<ArrayBufferView>;
  49973. /**
  49974. * The pixel array for the right face.
  49975. * This is stored in format, left to right, up to down format.
  49976. */
  49977. right: Nullable<ArrayBufferView>;
  49978. /**
  49979. * The pixel array for the up face.
  49980. * This is stored in format, left to right, up to down format.
  49981. */
  49982. up: Nullable<ArrayBufferView>;
  49983. /**
  49984. * The pixel array for the down face.
  49985. * This is stored in format, left to right, up to down format.
  49986. */
  49987. down: Nullable<ArrayBufferView>;
  49988. /**
  49989. * The size of the cubemap stored.
  49990. *
  49991. * Each faces will be size * size pixels.
  49992. */
  49993. size: number;
  49994. /**
  49995. * The format of the texture.
  49996. *
  49997. * RGBA, RGB.
  49998. */
  49999. format: number;
  50000. /**
  50001. * The type of the texture data.
  50002. *
  50003. * UNSIGNED_INT, FLOAT.
  50004. */
  50005. type: number;
  50006. /**
  50007. * Specifies whether the texture is in gamma space.
  50008. */
  50009. gammaSpace: boolean;
  50010. }
  50011. /**
  50012. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  50013. */
  50014. class PanoramaToCubeMapTools {
  50015. private static FACE_FRONT;
  50016. private static FACE_BACK;
  50017. private static FACE_RIGHT;
  50018. private static FACE_LEFT;
  50019. private static FACE_DOWN;
  50020. private static FACE_UP;
  50021. /**
  50022. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  50023. *
  50024. * @param float32Array The source data.
  50025. * @param inputWidth The width of the input panorama.
  50026. * @param inputHeight The height of the input panorama.
  50027. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  50028. * @return The cubemap data
  50029. */
  50030. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  50031. private static CreateCubemapTexture;
  50032. private static CalcProjectionSpherical;
  50033. }
  50034. }
  50035. declare module BABYLON {
  50036. }
  50037. declare module BABYLON {
  50038. }
  50039. declare module BABYLON {
  50040. }
  50041. declare module BABYLON {
  50042. }
  50043. declare module BABYLON {
  50044. /**
  50045. * 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.
  50046. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50047. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50048. */
  50049. class CustomProceduralTexture extends ProceduralTexture {
  50050. private _animate;
  50051. private _time;
  50052. private _config;
  50053. private _texturePath;
  50054. /**
  50055. * Instantiates a new Custom Procedural Texture.
  50056. * 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.
  50057. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50058. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50059. * @param name Define the name of the texture
  50060. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50061. * @param size Define the size of the texture to create
  50062. * @param scene Define the scene the texture belongs to
  50063. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50064. * @param generateMipMaps Define if the texture should creates mip maps or not
  50065. */
  50066. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50067. private _loadJson;
  50068. /**
  50069. * Is the texture ready to be used ? (rendered at least once)
  50070. * @returns true if ready, otherwise, false.
  50071. */
  50072. isReady(): boolean;
  50073. /**
  50074. * Render the texture to its associated render target.
  50075. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50076. */
  50077. render(useCameraPostProcess?: boolean): void;
  50078. /**
  50079. * Update the list of dependant textures samplers in the shader.
  50080. */
  50081. updateTextures(): void;
  50082. /**
  50083. * Update the uniform values of the procedural texture in the shader.
  50084. */
  50085. updateShaderUniforms(): void;
  50086. /**
  50087. * Define if the texture animates or not.
  50088. */
  50089. animate: boolean;
  50090. }
  50091. }
  50092. declare module BABYLON {
  50093. /**
  50094. * Class used to generate noise procedural textures
  50095. */
  50096. class NoiseProceduralTexture extends ProceduralTexture {
  50097. private _time;
  50098. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50099. brightness: number;
  50100. /** Defines the number of octaves to process */
  50101. octaves: number;
  50102. /** Defines the level of persistence (0.8 by default) */
  50103. persistence: number;
  50104. /** Gets or sets animation speed factor (default is 1) */
  50105. animationSpeedFactor: number;
  50106. /**
  50107. * Creates a new NoiseProceduralTexture
  50108. * @param name defines the name fo the texture
  50109. * @param size defines the size of the texture (default is 256)
  50110. * @param scene defines the hosting scene
  50111. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50112. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50113. */
  50114. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50115. private _updateShaderUniforms;
  50116. protected _getDefines(): string;
  50117. /** Generate the current state of the procedural texture */
  50118. render(useCameraPostProcess?: boolean): void;
  50119. /**
  50120. * Serializes this noise procedural texture
  50121. * @returns a serialized noise procedural texture object
  50122. */
  50123. serialize(): any;
  50124. /**
  50125. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50126. * @param parsedTexture defines parsed texture data
  50127. * @param scene defines the current scene
  50128. * @param rootUrl defines the root URL containing noise procedural texture information
  50129. * @returns a parsed NoiseProceduralTexture
  50130. */
  50131. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  50132. }
  50133. }
  50134. declare module BABYLON {
  50135. /**
  50136. * 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.
  50137. * This is the base class of any Procedural texture and contains most of the shareable code.
  50138. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50139. */
  50140. class ProceduralTexture extends Texture {
  50141. isCube: boolean;
  50142. /**
  50143. * Define if the texture is enabled or not (disabled texture will not render)
  50144. */
  50145. isEnabled: boolean;
  50146. /**
  50147. * Define if the texture must be cleared before rendering (default is true)
  50148. */
  50149. autoClear: boolean;
  50150. /**
  50151. * Callback called when the texture is generated
  50152. */
  50153. onGenerated: () => void;
  50154. /**
  50155. * Event raised when the texture is generated
  50156. */
  50157. onGeneratedObservable: Observable<ProceduralTexture>;
  50158. /** @hidden */
  50159. _generateMipMaps: boolean;
  50160. /** @hidden **/
  50161. _effect: Effect;
  50162. /** @hidden */
  50163. _textures: {
  50164. [key: string]: Texture;
  50165. };
  50166. private _size;
  50167. private _currentRefreshId;
  50168. private _refreshRate;
  50169. private _vertexBuffers;
  50170. private _indexBuffer;
  50171. private _uniforms;
  50172. private _samplers;
  50173. private _fragment;
  50174. private _floats;
  50175. private _ints;
  50176. private _floatsArrays;
  50177. private _colors3;
  50178. private _colors4;
  50179. private _vectors2;
  50180. private _vectors3;
  50181. private _matrices;
  50182. private _fallbackTexture;
  50183. private _fallbackTextureUsed;
  50184. private _engine;
  50185. private _cachedDefines;
  50186. private _contentUpdateId;
  50187. private _contentData;
  50188. /**
  50189. * Instantiates a new procedural texture.
  50190. * 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.
  50191. * This is the base class of any Procedural texture and contains most of the shareable code.
  50192. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50193. * @param name Define the name of the texture
  50194. * @param size Define the size of the texture to create
  50195. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  50196. * @param scene Define the scene the texture belongs to
  50197. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50198. * @param generateMipMaps Define if the texture should creates mip maps or not
  50199. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  50200. */
  50201. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  50202. /**
  50203. * The effect that is created when initializing the post process.
  50204. * @returns The created effect corrisponding the the postprocess.
  50205. */
  50206. getEffect(): Effect;
  50207. /**
  50208. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  50209. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  50210. */
  50211. getContent(): Nullable<ArrayBufferView>;
  50212. private _createIndexBuffer;
  50213. /** @hidden */
  50214. _rebuild(): void;
  50215. /**
  50216. * Resets the texture in order to recreate its associated resources.
  50217. * This can be called in case of context loss
  50218. */
  50219. reset(): void;
  50220. protected _getDefines(): string;
  50221. /**
  50222. * Is the texture ready to be used ? (rendered at least once)
  50223. * @returns true if ready, otherwise, false.
  50224. */
  50225. isReady(): boolean;
  50226. /**
  50227. * Resets the refresh counter of the texture and start bak from scratch.
  50228. * Could be useful to regenerate the texture if it is setup to render only once.
  50229. */
  50230. resetRefreshCounter(): void;
  50231. /**
  50232. * Set the fragment shader to use in order to render the texture.
  50233. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  50234. */
  50235. setFragment(fragment: any): void;
  50236. /**
  50237. * Define the refresh rate of the texture or the rendering frequency.
  50238. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  50239. */
  50240. refreshRate: number;
  50241. /** @hidden */
  50242. _shouldRender(): boolean;
  50243. /**
  50244. * Get the size the texture is rendering at.
  50245. * @returns the size (texture is always squared)
  50246. */
  50247. getRenderSize(): number;
  50248. /**
  50249. * Resize the texture to new value.
  50250. * @param size Define the new size the texture should have
  50251. * @param generateMipMaps Define whether the new texture should create mip maps
  50252. */
  50253. resize(size: number, generateMipMaps: boolean): void;
  50254. private _checkUniform;
  50255. /**
  50256. * Set a texture in the shader program used to render.
  50257. * @param name Define the name of the uniform samplers as defined in the shader
  50258. * @param texture Define the texture to bind to this sampler
  50259. * @return the texture itself allowing "fluent" like uniform updates
  50260. */
  50261. setTexture(name: string, texture: Texture): ProceduralTexture;
  50262. /**
  50263. * Set a float in the shader.
  50264. * @param name Define the name of the uniform as defined in the shader
  50265. * @param value Define the value to give to the uniform
  50266. * @return the texture itself allowing "fluent" like uniform updates
  50267. */
  50268. setFloat(name: string, value: number): ProceduralTexture;
  50269. /**
  50270. * Set a int in the shader.
  50271. * @param name Define the name of the uniform as defined in the shader
  50272. * @param value Define the value to give to the uniform
  50273. * @return the texture itself allowing "fluent" like uniform updates
  50274. */
  50275. setInt(name: string, value: number): ProceduralTexture;
  50276. /**
  50277. * Set an array of floats in the shader.
  50278. * @param name Define the name of the uniform as defined in the shader
  50279. * @param value Define the value to give to the uniform
  50280. * @return the texture itself allowing "fluent" like uniform updates
  50281. */
  50282. setFloats(name: string, value: number[]): ProceduralTexture;
  50283. /**
  50284. * Set a vec3 in the shader from a Color3.
  50285. * @param name Define the name of the uniform as defined in the shader
  50286. * @param value Define the value to give to the uniform
  50287. * @return the texture itself allowing "fluent" like uniform updates
  50288. */
  50289. setColor3(name: string, value: Color3): ProceduralTexture;
  50290. /**
  50291. * Set a vec4 in the shader from a Color4.
  50292. * @param name Define the name of the uniform as defined in the shader
  50293. * @param value Define the value to give to the uniform
  50294. * @return the texture itself allowing "fluent" like uniform updates
  50295. */
  50296. setColor4(name: string, value: Color4): ProceduralTexture;
  50297. /**
  50298. * Set a vec2 in the shader from a Vector2.
  50299. * @param name Define the name of the uniform as defined in the shader
  50300. * @param value Define the value to give to the uniform
  50301. * @return the texture itself allowing "fluent" like uniform updates
  50302. */
  50303. setVector2(name: string, value: Vector2): ProceduralTexture;
  50304. /**
  50305. * Set a vec3 in the shader from a Vector3.
  50306. * @param name Define the name of the uniform as defined in the shader
  50307. * @param value Define the value to give to the uniform
  50308. * @return the texture itself allowing "fluent" like uniform updates
  50309. */
  50310. setVector3(name: string, value: Vector3): ProceduralTexture;
  50311. /**
  50312. * Set a mat4 in the shader from a MAtrix.
  50313. * @param name Define the name of the uniform as defined in the shader
  50314. * @param value Define the value to give to the uniform
  50315. * @return the texture itself allowing "fluent" like uniform updates
  50316. */
  50317. setMatrix(name: string, value: Matrix): ProceduralTexture;
  50318. /**
  50319. * Render the texture to its associated render target.
  50320. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50321. */
  50322. render(useCameraPostProcess?: boolean): void;
  50323. /**
  50324. * Clone the texture.
  50325. * @returns the cloned texture
  50326. */
  50327. clone(): ProceduralTexture;
  50328. /**
  50329. * Dispose the texture and release its asoociated resources.
  50330. */
  50331. dispose(): void;
  50332. }
  50333. }
  50334. declare module BABYLON {
  50335. interface AbstractScene {
  50336. /**
  50337. * The list of procedural textures added to the scene
  50338. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  50339. */
  50340. proceduralTextures: Array<ProceduralTexture>;
  50341. }
  50342. /**
  50343. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  50344. * in a given scene.
  50345. */
  50346. class ProceduralTextureSceneComponent implements ISceneComponent {
  50347. /**
  50348. * The component name helpfull to identify the component in the list of scene components.
  50349. */
  50350. readonly name: string;
  50351. /**
  50352. * The scene the component belongs to.
  50353. */
  50354. scene: Scene;
  50355. /**
  50356. * Creates a new instance of the component for the given scene
  50357. * @param scene Defines the scene to register the component in
  50358. */
  50359. constructor(scene: Scene);
  50360. /**
  50361. * Registers the component in a given scene
  50362. */
  50363. register(): void;
  50364. /**
  50365. * Rebuilds the elements related to this component in case of
  50366. * context lost for instance.
  50367. */
  50368. rebuild(): void;
  50369. /**
  50370. * Disposes the component and the associated ressources.
  50371. */
  50372. dispose(): void;
  50373. private _beforeClear;
  50374. }
  50375. }
  50376. declare module BABYLON {
  50377. /**
  50378. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  50379. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  50380. */
  50381. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50382. private _scene;
  50383. private _camerasToBeAttached;
  50384. /**
  50385. * ID of the sharpen post process,
  50386. */
  50387. private readonly SharpenPostProcessId;
  50388. /**
  50389. * @ignore
  50390. * ID of the image processing post process;
  50391. */
  50392. readonly ImageProcessingPostProcessId: string;
  50393. /**
  50394. * @ignore
  50395. * ID of the Fast Approximate Anti-Aliasing post process;
  50396. */
  50397. readonly FxaaPostProcessId: string;
  50398. /**
  50399. * ID of the chromatic aberration post process,
  50400. */
  50401. private readonly ChromaticAberrationPostProcessId;
  50402. /**
  50403. * ID of the grain post process
  50404. */
  50405. private readonly GrainPostProcessId;
  50406. /**
  50407. * Sharpen post process which will apply a sharpen convolution to enhance edges
  50408. */
  50409. sharpen: SharpenPostProcess;
  50410. private _sharpenEffect;
  50411. private bloom;
  50412. /**
  50413. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  50414. */
  50415. depthOfField: DepthOfFieldEffect;
  50416. /**
  50417. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50418. */
  50419. fxaa: FxaaPostProcess;
  50420. /**
  50421. * Image post processing pass used to perform operations such as tone mapping or color grading.
  50422. */
  50423. imageProcessing: ImageProcessingPostProcess;
  50424. /**
  50425. * Chromatic aberration post process which will shift rgb colors in the image
  50426. */
  50427. chromaticAberration: ChromaticAberrationPostProcess;
  50428. private _chromaticAberrationEffect;
  50429. /**
  50430. * Grain post process which add noise to the image
  50431. */
  50432. grain: GrainPostProcess;
  50433. private _grainEffect;
  50434. /**
  50435. * Glow post process which adds a glow to emmisive areas of the image
  50436. */
  50437. private _glowLayer;
  50438. /**
  50439. * Animations which can be used to tweak settings over a period of time
  50440. */
  50441. animations: Animation[];
  50442. private _imageProcessingConfigurationObserver;
  50443. private _sharpenEnabled;
  50444. private _bloomEnabled;
  50445. private _depthOfFieldEnabled;
  50446. private _depthOfFieldBlurLevel;
  50447. private _fxaaEnabled;
  50448. private _imageProcessingEnabled;
  50449. private _defaultPipelineTextureType;
  50450. private _bloomScale;
  50451. private _chromaticAberrationEnabled;
  50452. private _grainEnabled;
  50453. private _buildAllowed;
  50454. /**
  50455. * Enable or disable the sharpen process from the pipeline
  50456. */
  50457. sharpenEnabled: boolean;
  50458. private _resizeObserver;
  50459. private _hardwareScaleLevel;
  50460. private _bloomKernel;
  50461. /**
  50462. * Specifies the size of the bloom blur kernel, relative to the final output size
  50463. */
  50464. bloomKernel: number;
  50465. /**
  50466. * Specifies the weight of the bloom in the final rendering
  50467. */
  50468. private _bloomWeight;
  50469. /**
  50470. * Specifies the luma threshold for the area that will be blurred by the bloom
  50471. */
  50472. private _bloomThreshold;
  50473. private _hdr;
  50474. /**
  50475. * The strength of the bloom.
  50476. */
  50477. bloomWeight: number;
  50478. /**
  50479. * The strength of the bloom.
  50480. */
  50481. bloomThreshold: number;
  50482. /**
  50483. * The scale of the bloom, lower value will provide better performance.
  50484. */
  50485. bloomScale: number;
  50486. /**
  50487. * Enable or disable the bloom from the pipeline
  50488. */
  50489. bloomEnabled: boolean;
  50490. private _rebuildBloom;
  50491. /**
  50492. * If the depth of field is enabled.
  50493. */
  50494. depthOfFieldEnabled: boolean;
  50495. /**
  50496. * Blur level of the depth of field effect. (Higher blur will effect performance)
  50497. */
  50498. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  50499. /**
  50500. * If the anti aliasing is enabled.
  50501. */
  50502. fxaaEnabled: boolean;
  50503. private _samples;
  50504. /**
  50505. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50506. */
  50507. samples: number;
  50508. /**
  50509. * If image processing is enabled.
  50510. */
  50511. imageProcessingEnabled: boolean;
  50512. /**
  50513. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  50514. */
  50515. glowLayerEnabled: boolean;
  50516. /**
  50517. * Enable or disable the chromaticAberration process from the pipeline
  50518. */
  50519. chromaticAberrationEnabled: boolean;
  50520. /**
  50521. * Enable or disable the grain process from the pipeline
  50522. */
  50523. grainEnabled: boolean;
  50524. /**
  50525. * @constructor
  50526. * @param name - The rendering pipeline name (default: "")
  50527. * @param hdr - If high dynamic range textures should be used (default: true)
  50528. * @param scene - The scene linked to this pipeline (default: the last created scene)
  50529. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  50530. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  50531. */
  50532. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  50533. /**
  50534. * Force the compilation of the entire pipeline.
  50535. */
  50536. prepare(): void;
  50537. private _hasCleared;
  50538. private _prevPostProcess;
  50539. private _prevPrevPostProcess;
  50540. private _setAutoClearAndTextureSharing;
  50541. private _depthOfFieldSceneObserver;
  50542. private _buildPipeline;
  50543. private _disposePostProcesses;
  50544. /**
  50545. * Adds a camera to the pipeline
  50546. * @param camera the camera to be added
  50547. */
  50548. addCamera(camera: Camera): void;
  50549. /**
  50550. * Removes a camera from the pipeline
  50551. * @param camera the camera to remove
  50552. */
  50553. removeCamera(camera: Camera): void;
  50554. /**
  50555. * Dispose of the pipeline and stop all post processes
  50556. */
  50557. dispose(): void;
  50558. /**
  50559. * Serialize the rendering pipeline (Used when exporting)
  50560. * @returns the serialized object
  50561. */
  50562. serialize(): any;
  50563. /**
  50564. * Parse the serialized pipeline
  50565. * @param source Source pipeline.
  50566. * @param scene The scene to load the pipeline to.
  50567. * @param rootUrl The URL of the serialized pipeline.
  50568. * @returns An instantiated pipeline from the serialized object.
  50569. */
  50570. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  50571. }
  50572. }
  50573. declare module BABYLON {
  50574. /**
  50575. * BABYLON.JS Chromatic Aberration GLSL Shader
  50576. * Author: Olivier Guyot
  50577. * Separates very slightly R, G and B colors on the edges of the screen
  50578. * Inspired by Francois Tarlier & Martins Upitis
  50579. */
  50580. class LensRenderingPipeline extends PostProcessRenderPipeline {
  50581. /**
  50582. * @ignore
  50583. * The chromatic aberration PostProcess id in the pipeline
  50584. */
  50585. LensChromaticAberrationEffect: string;
  50586. /**
  50587. * @ignore
  50588. * The highlights enhancing PostProcess id in the pipeline
  50589. */
  50590. HighlightsEnhancingEffect: string;
  50591. /**
  50592. * @ignore
  50593. * The depth-of-field PostProcess id in the pipeline
  50594. */
  50595. LensDepthOfFieldEffect: string;
  50596. private _scene;
  50597. private _depthTexture;
  50598. private _grainTexture;
  50599. private _chromaticAberrationPostProcess;
  50600. private _highlightsPostProcess;
  50601. private _depthOfFieldPostProcess;
  50602. private _edgeBlur;
  50603. private _grainAmount;
  50604. private _chromaticAberration;
  50605. private _distortion;
  50606. private _highlightsGain;
  50607. private _highlightsThreshold;
  50608. private _dofDistance;
  50609. private _dofAperture;
  50610. private _dofDarken;
  50611. private _dofPentagon;
  50612. private _blurNoise;
  50613. /**
  50614. * @constructor
  50615. *
  50616. * Effect parameters are as follow:
  50617. * {
  50618. * chromatic_aberration: number; // from 0 to x (1 for realism)
  50619. * edge_blur: number; // from 0 to x (1 for realism)
  50620. * distortion: number; // from 0 to x (1 for realism)
  50621. * grain_amount: number; // from 0 to 1
  50622. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  50623. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  50624. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  50625. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  50626. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  50627. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  50628. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  50629. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  50630. * }
  50631. * Note: if an effect parameter is unset, effect is disabled
  50632. *
  50633. * @param name The rendering pipeline name
  50634. * @param parameters - An object containing all parameters (see above)
  50635. * @param scene The scene linked to this pipeline
  50636. * @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)
  50637. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50638. */
  50639. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  50640. /**
  50641. * Sets the amount of blur at the edges
  50642. * @param amount blur amount
  50643. */
  50644. setEdgeBlur(amount: number): void;
  50645. /**
  50646. * Sets edge blur to 0
  50647. */
  50648. disableEdgeBlur(): void;
  50649. /**
  50650. * Sets the amout of grain
  50651. * @param amount Amount of grain
  50652. */
  50653. setGrainAmount(amount: number): void;
  50654. /**
  50655. * Set grain amount to 0
  50656. */
  50657. disableGrain(): void;
  50658. /**
  50659. * Sets the chromatic aberration amount
  50660. * @param amount amount of chromatic aberration
  50661. */
  50662. setChromaticAberration(amount: number): void;
  50663. /**
  50664. * Sets chromatic aberration amount to 0
  50665. */
  50666. disableChromaticAberration(): void;
  50667. /**
  50668. * Sets the EdgeDistortion amount
  50669. * @param amount amount of EdgeDistortion
  50670. */
  50671. setEdgeDistortion(amount: number): void;
  50672. /**
  50673. * Sets edge distortion to 0
  50674. */
  50675. disableEdgeDistortion(): void;
  50676. /**
  50677. * Sets the FocusDistance amount
  50678. * @param amount amount of FocusDistance
  50679. */
  50680. setFocusDistance(amount: number): void;
  50681. /**
  50682. * Disables depth of field
  50683. */
  50684. disableDepthOfField(): void;
  50685. /**
  50686. * Sets the Aperture amount
  50687. * @param amount amount of Aperture
  50688. */
  50689. setAperture(amount: number): void;
  50690. /**
  50691. * Sets the DarkenOutOfFocus amount
  50692. * @param amount amount of DarkenOutOfFocus
  50693. */
  50694. setDarkenOutOfFocus(amount: number): void;
  50695. /**
  50696. * Creates a pentagon bokeh effect
  50697. */
  50698. enablePentagonBokeh(): void;
  50699. /**
  50700. * Disables the pentagon bokeh effect
  50701. */
  50702. disablePentagonBokeh(): void;
  50703. /**
  50704. * Enables noise blur
  50705. */
  50706. enableNoiseBlur(): void;
  50707. /**
  50708. * Disables noise blur
  50709. */
  50710. disableNoiseBlur(): void;
  50711. /**
  50712. * Sets the HighlightsGain amount
  50713. * @param amount amount of HighlightsGain
  50714. */
  50715. setHighlightsGain(amount: number): void;
  50716. /**
  50717. * Sets the HighlightsThreshold amount
  50718. * @param amount amount of HighlightsThreshold
  50719. */
  50720. setHighlightsThreshold(amount: number): void;
  50721. /**
  50722. * Disables highlights
  50723. */
  50724. disableHighlights(): void;
  50725. /**
  50726. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  50727. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  50728. */
  50729. dispose(disableDepthRender?: boolean): void;
  50730. private _createChromaticAberrationPostProcess;
  50731. private _createHighlightsPostProcess;
  50732. private _createDepthOfFieldPostProcess;
  50733. private _createGrainTexture;
  50734. }
  50735. }
  50736. declare module BABYLON {
  50737. /**
  50738. * Render pipeline to produce ssao effect
  50739. */
  50740. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  50741. /**
  50742. * @ignore
  50743. * The PassPostProcess id in the pipeline that contains the original scene color
  50744. */
  50745. SSAOOriginalSceneColorEffect: string;
  50746. /**
  50747. * @ignore
  50748. * The SSAO PostProcess id in the pipeline
  50749. */
  50750. SSAORenderEffect: string;
  50751. /**
  50752. * @ignore
  50753. * The horizontal blur PostProcess id in the pipeline
  50754. */
  50755. SSAOBlurHRenderEffect: string;
  50756. /**
  50757. * @ignore
  50758. * The vertical blur PostProcess id in the pipeline
  50759. */
  50760. SSAOBlurVRenderEffect: string;
  50761. /**
  50762. * @ignore
  50763. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50764. */
  50765. SSAOCombineRenderEffect: string;
  50766. /**
  50767. * The output strength of the SSAO post-process. Default value is 1.0.
  50768. */
  50769. totalStrength: number;
  50770. /**
  50771. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50772. */
  50773. maxZ: number;
  50774. /**
  50775. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50776. */
  50777. minZAspect: number;
  50778. private _samples;
  50779. /**
  50780. * Number of samples used for the SSAO calculations. Default value is 8
  50781. */
  50782. samples: number;
  50783. private _textureSamples;
  50784. /**
  50785. * Number of samples to use for antialiasing
  50786. */
  50787. textureSamples: number;
  50788. /**
  50789. * Ratio object used for SSAO ratio and blur ratio
  50790. */
  50791. private _ratio;
  50792. /**
  50793. * Dynamically generated sphere sampler.
  50794. */
  50795. private _sampleSphere;
  50796. /**
  50797. * Blur filter offsets
  50798. */
  50799. private _samplerOffsets;
  50800. private _expensiveBlur;
  50801. /**
  50802. * If bilateral blur should be used
  50803. */
  50804. expensiveBlur: boolean;
  50805. /**
  50806. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50807. */
  50808. radius: number;
  50809. /**
  50810. * The base color of the SSAO post-process
  50811. * The final result is "base + ssao" between [0, 1]
  50812. */
  50813. base: number;
  50814. /**
  50815. * Support test.
  50816. */
  50817. static readonly IsSupported: boolean;
  50818. private _scene;
  50819. private _depthTexture;
  50820. private _normalTexture;
  50821. private _randomTexture;
  50822. private _originalColorPostProcess;
  50823. private _ssaoPostProcess;
  50824. private _blurHPostProcess;
  50825. private _blurVPostProcess;
  50826. private _ssaoCombinePostProcess;
  50827. private _firstUpdate;
  50828. /**
  50829. * @constructor
  50830. * @param name The rendering pipeline name
  50831. * @param scene The scene linked to this pipeline
  50832. * @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 }
  50833. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50834. */
  50835. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50836. /**
  50837. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50838. */
  50839. dispose(disableGeometryBufferRenderer?: boolean): void;
  50840. private _createBlurPostProcess;
  50841. /** @hidden */
  50842. _rebuild(): void;
  50843. private _bits;
  50844. private _radicalInverse_VdC;
  50845. private _hammersley;
  50846. private _hemisphereSample_uniform;
  50847. private _generateHemisphere;
  50848. private _createSSAOPostProcess;
  50849. private _createSSAOCombinePostProcess;
  50850. private _createRandomTexture;
  50851. /**
  50852. * Serialize the rendering pipeline (Used when exporting)
  50853. * @returns the serialized object
  50854. */
  50855. serialize(): any;
  50856. /**
  50857. * Parse the serialized pipeline
  50858. * @param source Source pipeline.
  50859. * @param scene The scene to load the pipeline to.
  50860. * @param rootUrl The URL of the serialized pipeline.
  50861. * @returns An instantiated pipeline from the serialized object.
  50862. */
  50863. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50864. }
  50865. }
  50866. declare module BABYLON {
  50867. /**
  50868. * Render pipeline to produce ssao effect
  50869. */
  50870. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50871. /**
  50872. * @ignore
  50873. * The PassPostProcess id in the pipeline that contains the original scene color
  50874. */
  50875. SSAOOriginalSceneColorEffect: string;
  50876. /**
  50877. * @ignore
  50878. * The SSAO PostProcess id in the pipeline
  50879. */
  50880. SSAORenderEffect: string;
  50881. /**
  50882. * @ignore
  50883. * The horizontal blur PostProcess id in the pipeline
  50884. */
  50885. SSAOBlurHRenderEffect: string;
  50886. /**
  50887. * @ignore
  50888. * The vertical blur PostProcess id in the pipeline
  50889. */
  50890. SSAOBlurVRenderEffect: string;
  50891. /**
  50892. * @ignore
  50893. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50894. */
  50895. SSAOCombineRenderEffect: string;
  50896. /**
  50897. * The output strength of the SSAO post-process. Default value is 1.0.
  50898. */
  50899. totalStrength: number;
  50900. /**
  50901. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50902. */
  50903. radius: number;
  50904. /**
  50905. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50906. * Must not be equal to fallOff and superior to fallOff.
  50907. * Default value is 0.975
  50908. */
  50909. area: number;
  50910. /**
  50911. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50912. * Must not be equal to area and inferior to area.
  50913. * Default value is 0.0
  50914. */
  50915. fallOff: number;
  50916. /**
  50917. * The base color of the SSAO post-process
  50918. * The final result is "base + ssao" between [0, 1]
  50919. */
  50920. base: number;
  50921. private _scene;
  50922. private _depthTexture;
  50923. private _randomTexture;
  50924. private _originalColorPostProcess;
  50925. private _ssaoPostProcess;
  50926. private _blurHPostProcess;
  50927. private _blurVPostProcess;
  50928. private _ssaoCombinePostProcess;
  50929. private _firstUpdate;
  50930. /**
  50931. * @constructor
  50932. * @param name - The rendering pipeline name
  50933. * @param scene - The scene linked to this pipeline
  50934. * @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 }
  50935. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  50936. */
  50937. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50938. /**
  50939. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50940. */
  50941. dispose(disableDepthRender?: boolean): void;
  50942. private _createBlurPostProcess;
  50943. /** @hidden */
  50944. _rebuild(): void;
  50945. private _createSSAOPostProcess;
  50946. private _createSSAOCombinePostProcess;
  50947. private _createRandomTexture;
  50948. }
  50949. }
  50950. declare module BABYLON {
  50951. /**
  50952. * Standard rendering pipeline
  50953. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50954. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  50955. */
  50956. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50957. /**
  50958. * Public members
  50959. */
  50960. /**
  50961. * Post-process which contains the original scene color before the pipeline applies all the effects
  50962. */
  50963. originalPostProcess: Nullable<PostProcess>;
  50964. /**
  50965. * Post-process used to down scale an image x4
  50966. */
  50967. downSampleX4PostProcess: Nullable<PostProcess>;
  50968. /**
  50969. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  50970. */
  50971. brightPassPostProcess: Nullable<PostProcess>;
  50972. /**
  50973. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  50974. */
  50975. blurHPostProcesses: PostProcess[];
  50976. /**
  50977. * Post-process array storing all the vertical blur post-processes used by the pipeline
  50978. */
  50979. blurVPostProcesses: PostProcess[];
  50980. /**
  50981. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  50982. */
  50983. textureAdderPostProcess: Nullable<PostProcess>;
  50984. /**
  50985. * Post-process used to create volumetric lighting effect
  50986. */
  50987. volumetricLightPostProcess: Nullable<PostProcess>;
  50988. /**
  50989. * Post-process used to smooth the previous volumetric light post-process on the X axis
  50990. */
  50991. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  50992. /**
  50993. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  50994. */
  50995. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  50996. /**
  50997. * Post-process used to merge the volumetric light effect and the real scene color
  50998. */
  50999. volumetricLightMergePostProces: Nullable<PostProcess>;
  51000. /**
  51001. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  51002. */
  51003. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  51004. /**
  51005. * Base post-process used to calculate the average luminance of the final image for HDR
  51006. */
  51007. luminancePostProcess: Nullable<PostProcess>;
  51008. /**
  51009. * Post-processes used to create down sample post-processes in order to get
  51010. * the average luminance of the final image for HDR
  51011. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  51012. */
  51013. luminanceDownSamplePostProcesses: PostProcess[];
  51014. /**
  51015. * Post-process used to create a HDR effect (light adaptation)
  51016. */
  51017. hdrPostProcess: Nullable<PostProcess>;
  51018. /**
  51019. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  51020. */
  51021. textureAdderFinalPostProcess: Nullable<PostProcess>;
  51022. /**
  51023. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  51024. */
  51025. lensFlareFinalPostProcess: Nullable<PostProcess>;
  51026. /**
  51027. * Post-process used to merge the final HDR post-process and the real scene color
  51028. */
  51029. hdrFinalPostProcess: Nullable<PostProcess>;
  51030. /**
  51031. * Post-process used to create a lens flare effect
  51032. */
  51033. lensFlarePostProcess: Nullable<PostProcess>;
  51034. /**
  51035. * Post-process that merges the result of the lens flare post-process and the real scene color
  51036. */
  51037. lensFlareComposePostProcess: Nullable<PostProcess>;
  51038. /**
  51039. * Post-process used to create a motion blur effect
  51040. */
  51041. motionBlurPostProcess: Nullable<PostProcess>;
  51042. /**
  51043. * Post-process used to create a depth of field effect
  51044. */
  51045. depthOfFieldPostProcess: Nullable<PostProcess>;
  51046. /**
  51047. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  51048. */
  51049. fxaaPostProcess: Nullable<FxaaPostProcess>;
  51050. /**
  51051. * Represents the brightness threshold in order to configure the illuminated surfaces
  51052. */
  51053. brightThreshold: number;
  51054. /**
  51055. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  51056. */
  51057. blurWidth: number;
  51058. /**
  51059. * Sets if the blur for highlighted surfaces must be only horizontal
  51060. */
  51061. horizontalBlur: boolean;
  51062. /**
  51063. * Sets the overall exposure used by the pipeline
  51064. */
  51065. exposure: number;
  51066. /**
  51067. * Texture used typically to simulate "dirty" on camera lens
  51068. */
  51069. lensTexture: Nullable<Texture>;
  51070. /**
  51071. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  51072. */
  51073. volumetricLightCoefficient: number;
  51074. /**
  51075. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  51076. */
  51077. volumetricLightPower: number;
  51078. /**
  51079. * Used the set the blur intensity to smooth the volumetric lights
  51080. */
  51081. volumetricLightBlurScale: number;
  51082. /**
  51083. * Light (spot or directional) used to generate the volumetric lights rays
  51084. * The source light must have a shadow generate so the pipeline can get its
  51085. * depth map
  51086. */
  51087. sourceLight: Nullable<SpotLight | DirectionalLight>;
  51088. /**
  51089. * For eye adaptation, represents the minimum luminance the eye can see
  51090. */
  51091. hdrMinimumLuminance: number;
  51092. /**
  51093. * For eye adaptation, represents the decrease luminance speed
  51094. */
  51095. hdrDecreaseRate: number;
  51096. /**
  51097. * For eye adaptation, represents the increase luminance speed
  51098. */
  51099. hdrIncreaseRate: number;
  51100. /**
  51101. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  51102. */
  51103. lensColorTexture: Nullable<Texture>;
  51104. /**
  51105. * The overall strengh for the lens flare effect
  51106. */
  51107. lensFlareStrength: number;
  51108. /**
  51109. * Dispersion coefficient for lens flare ghosts
  51110. */
  51111. lensFlareGhostDispersal: number;
  51112. /**
  51113. * Main lens flare halo width
  51114. */
  51115. lensFlareHaloWidth: number;
  51116. /**
  51117. * Based on the lens distortion effect, defines how much the lens flare result
  51118. * is distorted
  51119. */
  51120. lensFlareDistortionStrength: number;
  51121. /**
  51122. * Lens star texture must be used to simulate rays on the flares and is available
  51123. * in the documentation
  51124. */
  51125. lensStarTexture: Nullable<Texture>;
  51126. /**
  51127. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  51128. * flare effect by taking account of the dirt texture
  51129. */
  51130. lensFlareDirtTexture: Nullable<Texture>;
  51131. /**
  51132. * Represents the focal length for the depth of field effect
  51133. */
  51134. depthOfFieldDistance: number;
  51135. /**
  51136. * Represents the blur intensity for the blurred part of the depth of field effect
  51137. */
  51138. depthOfFieldBlurWidth: number;
  51139. /**
  51140. * For motion blur, defines how much the image is blurred by the movement
  51141. */
  51142. motionStrength: number;
  51143. /**
  51144. * List of animations for the pipeline (IAnimatable implementation)
  51145. */
  51146. animations: Animation[];
  51147. /**
  51148. * Private members
  51149. */
  51150. private _scene;
  51151. private _currentDepthOfFieldSource;
  51152. private _basePostProcess;
  51153. private _hdrCurrentLuminance;
  51154. private _floatTextureType;
  51155. private _ratio;
  51156. private _bloomEnabled;
  51157. private _depthOfFieldEnabled;
  51158. private _vlsEnabled;
  51159. private _lensFlareEnabled;
  51160. private _hdrEnabled;
  51161. private _motionBlurEnabled;
  51162. private _fxaaEnabled;
  51163. private _motionBlurSamples;
  51164. private _volumetricLightStepsCount;
  51165. private _samples;
  51166. /**
  51167. * @ignore
  51168. * Specifies if the bloom pipeline is enabled
  51169. */
  51170. BloomEnabled: boolean;
  51171. /**
  51172. * @ignore
  51173. * Specifies if the depth of field pipeline is enabed
  51174. */
  51175. DepthOfFieldEnabled: boolean;
  51176. /**
  51177. * @ignore
  51178. * Specifies if the lens flare pipeline is enabed
  51179. */
  51180. LensFlareEnabled: boolean;
  51181. /**
  51182. * @ignore
  51183. * Specifies if the HDR pipeline is enabled
  51184. */
  51185. HDREnabled: boolean;
  51186. /**
  51187. * @ignore
  51188. * Specifies if the volumetric lights scattering effect is enabled
  51189. */
  51190. VLSEnabled: boolean;
  51191. /**
  51192. * @ignore
  51193. * Specifies if the motion blur effect is enabled
  51194. */
  51195. MotionBlurEnabled: boolean;
  51196. /**
  51197. * Specifies if anti-aliasing is enabled
  51198. */
  51199. fxaaEnabled: boolean;
  51200. /**
  51201. * Specifies the number of steps used to calculate the volumetric lights
  51202. * Typically in interval [50, 200]
  51203. */
  51204. volumetricLightStepsCount: number;
  51205. /**
  51206. * Specifies the number of samples used for the motion blur effect
  51207. * Typically in interval [16, 64]
  51208. */
  51209. motionBlurSamples: number;
  51210. /**
  51211. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  51212. */
  51213. samples: number;
  51214. /**
  51215. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  51216. * @constructor
  51217. * @param name The rendering pipeline name
  51218. * @param scene The scene linked to this pipeline
  51219. * @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)
  51220. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  51221. * @param cameras The array of cameras that the rendering pipeline will be attached to
  51222. */
  51223. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  51224. private _buildPipeline;
  51225. private _createDownSampleX4PostProcess;
  51226. private _createBrightPassPostProcess;
  51227. private _createBlurPostProcesses;
  51228. private _createTextureAdderPostProcess;
  51229. private _createVolumetricLightPostProcess;
  51230. private _createLuminancePostProcesses;
  51231. private _createHdrPostProcess;
  51232. private _createLensFlarePostProcess;
  51233. private _createDepthOfFieldPostProcess;
  51234. private _createMotionBlurPostProcess;
  51235. private _getDepthTexture;
  51236. private _disposePostProcesses;
  51237. /**
  51238. * Dispose of the pipeline and stop all post processes
  51239. */
  51240. dispose(): void;
  51241. /**
  51242. * Serialize the rendering pipeline (Used when exporting)
  51243. * @returns the serialized object
  51244. */
  51245. serialize(): any;
  51246. /**
  51247. * Parse the serialized pipeline
  51248. * @param source Source pipeline.
  51249. * @param scene The scene to load the pipeline to.
  51250. * @param rootUrl The URL of the serialized pipeline.
  51251. * @returns An instantiated pipeline from the serialized object.
  51252. */
  51253. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  51254. /**
  51255. * Luminance steps
  51256. */
  51257. static LuminanceSteps: number;
  51258. }
  51259. }